simple-sso/src/do_init.lua

29 lines
958 B
Lua
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

-- Load this file in `nginx.conf`:
--
-- ```
-- http {
-- init_by_lua_file /path/to/do_init.lua;
-- …
-- }
-- ```
-- strip initial `@` and final `/do_init.lua` from this files path, and add it to `package.path`
local here = debug.getinfo(1).source:sub(2, -13)
package.path = here .. "/?.lua;" .. package.path
-- modules using singleton-style configuration → load and init them
local config = require("ssso_config") -- init required from storage
local _ = require("ssso_crypto") -- init required for a shared secret
local login = require("ssso_login") -- init required from storage
local portal = require("ssso_portal") -- init required from storage
local sites = require("ssso_sites") -- init required from storage
config.load_conf(here)
login.set_root(here)
portal.set_root(here)
sites.load_sites(here)
-- modules used for _each_ page access → load them in memory
local _ = require("ssso_nginx")
local _ = require("ssso_sessions")