Mercurial > prosody-modules
diff mod_rest/mod_rest.lua @ 5934:667ce80937fa
mod_rest: Fix authentication
The :contains check failed because case normalization was applied after
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Mon, 15 Jul 2024 16:24:20 +0200 |
parents | 2739d3db591f |
children | eef6cb08f9e7 |
line wrap: on
line diff
--- a/mod_rest/mod_rest.lua Sun Jul 14 18:01:24 2024 +0200 +++ b/mod_rest/mod_rest.lua Mon Jul 15 16:24:20 2024 +0200 @@ -53,10 +53,10 @@ local function check_credentials(request) -- > session | boolean, error local auth_type, auth_data = string.match(request.headers.authorization, "^(%S+)%s(.+)$"); + auth_type = auth_type and auth_type:lower(); if not (auth_type and auth_data) or not auth_mechanisms:contains(auth_type) then return nil, post_errors.new("noauthz", { request = request }); end - auth_type = auth_type:lower(); if auth_type == "basic" then local creds = base64.decode(auth_data);