mirror of
https://github.com/YunoHost/SSOwat.git
synced 2024-09-03 20:06:27 +02:00
Avoid unnecessarily reloading the config file
This commit is contained in:
parent
77afe5cf09
commit
8cc2bd4b28
2 changed files with 11 additions and 12 deletions
|
@ -16,12 +16,13 @@ if not srvkey then
|
||||||
cache:add("srvkey", srvkey)
|
cache:add("srvkey", srvkey)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Initialize and get configuration
|
|
||||||
local conf = config.get_config()
|
|
||||||
|
|
||||||
-- Import helpers
|
-- Import helpers
|
||||||
local hlp = require "helpers"
|
local hlp = require "helpers"
|
||||||
|
|
||||||
|
-- Initialize and get configuration
|
||||||
|
hlp.refresh_config()
|
||||||
|
local conf = hlp.get_config()
|
||||||
|
|
||||||
-- Load logging module
|
-- Load logging module
|
||||||
local logger = require("log")
|
local logger = require("log")
|
||||||
|
|
||||||
|
@ -107,7 +108,6 @@ then
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Get managed domains
|
-- Get managed domains
|
||||||
conf = config.get_config()
|
|
||||||
local managed_domain = false
|
local managed_domain = false
|
||||||
for _, domain in ipairs(conf["domains"]) do
|
for _, domain in ipairs(conf["domains"]) do
|
||||||
local escaped_domain = domain:gsub("-", "%%-") -- escape dash for pattern matching
|
local escaped_domain = domain:gsub("-", "%%-") -- escape dash for pattern matching
|
||||||
|
|
15
helpers.lua
15
helpers.lua
|
@ -17,6 +17,13 @@ local url_parser = require "socket.url"
|
||||||
-- Import Perl regular expressions library
|
-- Import Perl regular expressions library
|
||||||
local rex = require "rex_pcre"
|
local rex = require "rex_pcre"
|
||||||
|
|
||||||
|
function refresh_config()
|
||||||
|
conf = config.get_config()
|
||||||
|
end
|
||||||
|
|
||||||
|
function get_config()
|
||||||
|
return conf
|
||||||
|
end
|
||||||
|
|
||||||
-- The 'match' function uses PCRE regex as default
|
-- The 'match' function uses PCRE regex as default
|
||||||
-- If '%.' is found in the regex, we assume it's a LUA regex (legacy code)
|
-- If '%.' is found in the regex, we assume it's a LUA regex (legacy code)
|
||||||
|
@ -183,8 +190,6 @@ end
|
||||||
|
|
||||||
-- Expires the 3 session cookies
|
-- Expires the 3 session cookies
|
||||||
function delete_cookie()
|
function delete_cookie()
|
||||||
conf = config.get_config()
|
|
||||||
|
|
||||||
local expired_time = "Thu, 01 Jan 1970 00:00:00 UTC"
|
local expired_time = "Thu, 01 Jan 1970 00:00:00 UTC"
|
||||||
for _, domain in ipairs(conf["domains"]) do
|
for _, domain in ipairs(conf["domains"]) do
|
||||||
local cookie_str = "; Domain=."..domain..
|
local cookie_str = "; Domain=."..domain..
|
||||||
|
@ -372,8 +377,6 @@ end
|
||||||
-- address.
|
-- address.
|
||||||
-- Reminder: conf["ldap_identifier"] is "uid" by default
|
-- Reminder: conf["ldap_identifier"] is "uid" by default
|
||||||
function authenticate(user, password)
|
function authenticate(user, password)
|
||||||
conf = config.get_config()
|
|
||||||
|
|
||||||
-- Try to find the username from an email address by openning an anonymous
|
-- Try to find the username from an email address by openning an anonymous
|
||||||
-- LDAP connection and check if the email address exists
|
-- LDAP connection and check if the email address exists
|
||||||
if conf["allow_mail_authentication"] and string.find(user, "@") then
|
if conf["allow_mail_authentication"] and string.find(user, "@") then
|
||||||
|
@ -635,7 +638,6 @@ end
|
||||||
-- title, the flash notifications' content and the translated strings.
|
-- title, the flash notifications' content and the translated strings.
|
||||||
function get_data_for(view)
|
function get_data_for(view)
|
||||||
local user = authUser
|
local user = authUser
|
||||||
conf = config.get_config()
|
|
||||||
|
|
||||||
-- For the login page we only need the page title
|
-- For the login page we only need the page title
|
||||||
if view == "login.html" then
|
if view == "login.html" then
|
||||||
|
@ -711,7 +713,6 @@ end
|
||||||
-- if it's not the case, it migrates the password to this new hash algorithm
|
-- if it's not the case, it migrates the password to this new hash algorithm
|
||||||
function ensure_user_password_uses_strong_hash(ldap, user, password)
|
function ensure_user_password_uses_strong_hash(ldap, user, password)
|
||||||
local current_hashed_password = nil
|
local current_hashed_password = nil
|
||||||
conf = config.get_config()
|
|
||||||
|
|
||||||
for dn, attrs in ldap:search {
|
for dn, attrs in ldap:search {
|
||||||
base = conf['ldap_group'],
|
base = conf['ldap_group'],
|
||||||
|
@ -761,8 +762,6 @@ end
|
||||||
-- It has to update cached information and edit the LDAP user entry
|
-- It has to update cached information and edit the LDAP user entry
|
||||||
-- according to the changes detected.
|
-- according to the changes detected.
|
||||||
function edit_user()
|
function edit_user()
|
||||||
conf = config.get_config()
|
|
||||||
|
|
||||||
-- We need these calls since we are in a POST request
|
-- We need these calls since we are in a POST request
|
||||||
ngx.req.read_body()
|
ngx.req.read_body()
|
||||||
local args = ngx.req.get_post_args()
|
local args = ngx.req.get_post_args()
|
||||||
|
|
Loading…
Reference in a new issue