mirror of
https://github.com/YunoHost/SSOwat.git
synced 2024-09-03 20:06:27 +02:00
[fix] Load libraries locally to avoid caching
This commit is contained in:
parent
71e9ff1f68
commit
0ebddc079a
3 changed files with 24 additions and 15 deletions
13
access.lua
13
access.lua
|
@ -7,7 +7,7 @@
|
|||
--
|
||||
|
||||
-- Get the `cache` persistent shared table
|
||||
cache = ngx.shared.cache
|
||||
local cache = ngx.shared.cache
|
||||
|
||||
-- Generate a unique token if it has not been generated yet
|
||||
srvkey = cache:get("srvkey")
|
||||
|
@ -17,14 +17,10 @@ if not srvkey then
|
|||
end
|
||||
|
||||
-- Initialize and get configuration
|
||||
config = require "config"
|
||||
conf = config.get_config()
|
||||
|
||||
-- Initialize the non-persistent cookie table
|
||||
cookies = {}
|
||||
local conf = config.get_config()
|
||||
|
||||
-- Import helpers
|
||||
hlp = require "helpers"
|
||||
local hlp = require "helpers"
|
||||
|
||||
-- Just a note for the client to know that he passed through the SSO
|
||||
ngx.header["X-SSO-WAT"] = "You've just been SSOed"
|
||||
|
@ -99,8 +95,7 @@ then
|
|||
-- current one, create a redirection with a CDA key
|
||||
if not string.match(back_url, "^http[s]?://"..ngx.var.host.."/")
|
||||
and not string.match(back_url, ".*"..conf.login_arg.."=%d+$") then
|
||||
cda_key = random_string()
|
||||
cache:set(cda_key, ngx.var.cookie_SSOwAuthUser, 10)
|
||||
local cda_key = hlp.set_cda_key()
|
||||
if string.match(back_url, ".*?.*") then
|
||||
back_url = back_url.."&"
|
||||
else
|
||||
|
|
13
helpers.lua
13
helpers.lua
|
@ -7,6 +7,11 @@
|
|||
|
||||
module('helpers', package.seeall)
|
||||
|
||||
local cache = ngx.shared.cache
|
||||
local conf = config.get_config()
|
||||
local cookies = {}
|
||||
|
||||
|
||||
-- Read a FS stored file
|
||||
function read_file(file)
|
||||
local f = io.open(file, "rb")
|
||||
|
@ -80,6 +85,14 @@ function uri_args_string (args)
|
|||
end
|
||||
|
||||
|
||||
-- Set the Cross-Domain-Authentication key for a specific user
|
||||
function set_cda_key ()
|
||||
local cda_key = random_string()
|
||||
cache:set(cda_key, ngx.var.cookie_SSOwAuthUser, 10)
|
||||
return cda_key
|
||||
end
|
||||
|
||||
|
||||
-- Compute and set the authentication cookie
|
||||
--
|
||||
-- Sets 3 cookies containing:
|
||||
|
|
13
init.lua
13
init.lua
|
@ -15,12 +15,13 @@ script_path = string.sub(debug.getinfo(1).source, 2, -9)
|
|||
package.path = package.path .. ";"..script_path.."?.lua"
|
||||
|
||||
-- Load libraries
|
||||
json = require "json"
|
||||
lualdap = require "lualdap"
|
||||
math = require "math"
|
||||
hige = require "hige"
|
||||
lfs = require "lfs"
|
||||
socket = require "socket"
|
||||
local json = require "json"
|
||||
local lualdap = require "lualdap"
|
||||
local math = require "math"
|
||||
local hige = require "hige"
|
||||
local lfs = require "lfs"
|
||||
local socket = require "socket"
|
||||
local config = require "config"
|
||||
|
||||
-- Persistent shared table
|
||||
flashs = {}
|
||||
|
|
Loading…
Reference in a new issue