Software /
code /
prosody
Changeset
11326:1ecda954fe97
mod_http_file_share: Strip authorization type prefix a bit earlier
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Wed, 27 Jan 2021 18:26:24 +0100 |
parents | 11325:76fc73d39092 |
children | 11327:6f2b69469060 |
files | plugins/mod_http_file_share.lua |
diffstat | 1 files changed, 5 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/plugins/mod_http_file_share.lua Wed Jan 27 18:13:15 2021 +0100 +++ b/plugins/mod_http_file_share.lua Wed Jan 27 18:26:24 2021 +0100 @@ -152,11 +152,14 @@ function handle_upload(event, path) -- PUT /upload/:slot local request = event.request; local authz = request.headers.authorization; - if not authz or not authz:find"^Bearer ." then + if authz then + authz = authz:match("^Bearer (.*)") + end + if not authz then module:log("debug", "Missing Authorization"); return 403; end - local authed, upload_info = jwt.verify(secret, authz:match("^Bearer (.*)")); + local authed, upload_info = jwt.verify(secret, authz); if not (authed and type(upload_info) == "table" and type(upload_info.exp) == "number") then module:log("debug", "Unauthorized or invalid token: %s, %q", authed, upload_info); return 401;