mirror of
https://github.com/YunoHost/SSOwat.git
synced 2024-09-03 20:06:27 +02:00
[enh] Use PCRE to match configurations patterns
This commit is contained in:
parent
df9e179ef1
commit
4759f534d6
1 changed files with 12 additions and 9 deletions
21
access.lua
21
access.lua
|
@ -22,6 +22,9 @@ local conf = config.get_config()
|
||||||
-- Import helpers
|
-- Import helpers
|
||||||
local hlp = require "helpers"
|
local hlp = require "helpers"
|
||||||
|
|
||||||
|
-- Import Perl regular expressions library
|
||||||
|
local rex = require "rex_pcre"
|
||||||
|
|
||||||
-- Just a note for the client to know that he passed through the SSO
|
-- Just a note for the client to know that he passed through the SSO
|
||||||
ngx.header["X-SSO-WAT"] = "You've just been SSOed"
|
ngx.header["X-SSO-WAT"] = "You've just been SSOed"
|
||||||
|
|
||||||
|
@ -177,9 +180,9 @@ end
|
||||||
|
|
||||||
if conf["redirected_regex"] then
|
if conf["redirected_regex"] then
|
||||||
for regex, redirect_url in pairs(conf["redirected_regex"]) do
|
for regex, redirect_url in pairs(conf["redirected_regex"]) do
|
||||||
if string.match(ngx.var.host..ngx.var.uri..hlp.uri_args_string(), regex)
|
if rex.match(ngx.var.host..ngx.var.uri..hlp.uri_args_string(), regex)
|
||||||
or string.match(ngx.var.scheme.."://"..ngx.var.host..ngx.var.uri..hlp.uri_args_string(), regex)
|
or rex.match(ngx.var.scheme.."://"..ngx.var.host..ngx.var.uri..hlp.uri_args_string(), regex)
|
||||||
or string.match(ngx.var.uri..hlp.uri_args_string(), regex) then
|
or rex.match(ngx.var.uri..hlp.uri_args_string(), regex) then
|
||||||
detect_redirection(redirect_url)
|
detect_redirection(redirect_url)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -210,8 +213,8 @@ function is_protected()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
for _, regex in ipairs(conf["protected_regex"]) do
|
for _, regex in ipairs(conf["protected_regex"]) do
|
||||||
if string.match(ngx.var.host..ngx.var.uri, regex)
|
if rex.match(ngx.var.host..ngx.var.uri, regex)
|
||||||
or string.match(ngx.var.uri, regex) then
|
or rex.match(ngx.var.uri, regex) then
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -240,8 +243,8 @@ end
|
||||||
|
|
||||||
if conf["skipped_regex"] then
|
if conf["skipped_regex"] then
|
||||||
for _, regex in ipairs(conf["skipped_regex"]) do
|
for _, regex in ipairs(conf["skipped_regex"]) do
|
||||||
if (string.match(ngx.var.host..ngx.var.uri..hlp.uri_args_string(), regex)
|
if (rex.match(ngx.var.host..ngx.var.uri..hlp.uri_args_string(), regex)
|
||||||
or string.match(ngx.var.uri..hlp.uri_args_string(), regex))
|
or rex.match(ngx.var.uri..hlp.uri_args_string(), regex))
|
||||||
and not is_protected() then
|
and not is_protected() then
|
||||||
return hlp.pass()
|
return hlp.pass()
|
||||||
end
|
end
|
||||||
|
@ -277,8 +280,8 @@ end
|
||||||
|
|
||||||
if conf["unprotected_regex"] then
|
if conf["unprotected_regex"] then
|
||||||
for _, regex in ipairs(conf["unprotected_regex"]) do
|
for _, regex in ipairs(conf["unprotected_regex"]) do
|
||||||
if (string.match(ngx.var.host..ngx.var.uri..hlp.uri_args_string(), regex)
|
if (rex.match(ngx.var.host..ngx.var.uri..hlp.uri_args_string(), regex)
|
||||||
or string.match(ngx.var.uri..hlp.uri_args_string(), regex))
|
or rex.match(ngx.var.uri..hlp.uri_args_string(), regex))
|
||||||
and not is_protected() then
|
and not is_protected() then
|
||||||
if hlp.is_logged_in() then
|
if hlp.is_logged_in() then
|
||||||
hlp.set_headers()
|
hlp.set_headers()
|
||||||
|
|
Loading…
Add table
Reference in a new issue