simple-sso/src/ssso_config.lua

39 lines
1.1 KiB
Lua

local json = require("cjson.safe")
local conf = {}
local function load_conf(prefix)
local name_suffix = "/global.json"
local file = assert(io.open(prefix .. name_suffix, "r"), "File " .. prefix .. name_suffix .. " not found")
conf = json.decode(file:read("*all"))
file:close()
assert(conf["auth"], "Simple-SSO configuration is missing an `auth` entry")
assert(conf["sso_host"], "Simple-SSO configuration is missing a `sso_host` entry")
assert(conf["sso_prefix"], "Simple-SSO configuration is missing a `sso_prefix` entry")
assert(conf["session_seconds"], "Simple-SSO configuration is missing a `session_seconds` entry")
end
local function get_auth_commands()
return conf["auth"]
end
local function get_sso_host()
return conf["sso_host"]
end
local function get_sso_prefix()
return conf["sso_prefix"]
end
local function get_session_seconds()
return conf["session_seconds"]
end
return {
get_auth_commands = get_auth_commands,
get_session_seconds = get_session_seconds,
get_sso_host = get_sso_host,
get_sso_prefix = get_sso_prefix,
load_conf = load_conf,
}