mirror of
https://github.com/YunoHost/SSOwat.git
synced 2024-09-03 20:06:27 +02:00
Iterate on previous security fixes: ignore Auth header on PROPFIND routes, and don't drop Auth header which are not Basic auth
This commit is contained in:
parent
8621a1e1a3
commit
92f1e0505a
1 changed files with 11 additions and 2 deletions
13
helpers.lua
13
helpers.lua
|
@ -266,7 +266,9 @@ function refresh_logged_in()
|
|||
|
||||
local auth_header = ngx.req.get_headers()["Authorization"] or ngx.req.get_headers()["Proxy-Authorization"]
|
||||
|
||||
if auth_header then
|
||||
-- Ignore this for PROPFIND routes used by Nextcloud (et al.?) which also rely on basic auth with totally yunohost-unrelated credentials ...
|
||||
if auth_header and ngx.var.request_method ~= "PROPFIND" then
|
||||
logger.debug(auth_header)
|
||||
_, _, b64_cred = string.find(auth_header, "^Basic%s+(.+)$")
|
||||
if b64_cred == nil then
|
||||
return is_logged_in
|
||||
|
@ -418,7 +420,14 @@ end
|
|||
-- - app requests that no authentication headers be sent
|
||||
-- Prevents user from pretending to be someone else on public apps
|
||||
function clear_headers()
|
||||
ngx.req.clear_header("Authorization")
|
||||
-- Clear auth header only if it's a 'Basic' auth stuff, not 'Bearer' stuff
|
||||
-- Also ignore PROPFIND routes used by Nextcloud (et al.?)
|
||||
if ngx.var.request_method ~= "PROPFIND" and ngx.req.get_headers()["Authorization"] then
|
||||
_, _, b64_cred = string.find(auth_header, "^Basic%s+(.+)$")
|
||||
if b64_cred ~= nil then
|
||||
ngx.req.clear_header("Authorization")
|
||||
end
|
||||
end
|
||||
for k, v in pairs(conf["additional_headers"]) do
|
||||
ngx.req.clear_header(k)
|
||||
end
|
||||
|
|
Loading…
Add table
Reference in a new issue