Mercurial > prosody-modules
view mod_http_authentication/mod_http_authentication.lua @ 6411:b00638d74f46
mod_unified_push: Allow additional CORS headers for unified push (fixes #1985)
- Request header "TTL" is mandated by the HTTP Push specification
RFC 8030: https://datatracker.ietf.org/doc/html/rfc8030#section-5
- Firefox sends "Content-Encoding" with a HTTP form submission,
so it is required when using the Unified Push testing tool
at https://unifiedpush.org/test_wp.html
(with the full URL being delivered by the UP-Example Android app)
Adding both headers makes the Unified Push testing tool work from
the browser.
Resolves: https://issues.prosody.im/1985
| author | Christian Weiske <cweiske@cweiske.de> |
|---|---|
| date | Sat, 21 Feb 2026 19:13:08 +0100 |
| parents | 05725785e3a6 |
| children |
line wrap: on
line source
module:set_global(); local b64_decode = require "util.encodings".base64.decode; local server = require "net.http.server"; local credentials = module:get_option_string("http_credentials", "username:secretpassword"); local unauthed_endpoints = module:get_option_set("unauthenticated_http_endpoints", { "/http-bind", "/http-bind/" })._items; module:wrap_object_event(server._events, false, function (handlers, event_name, event_data) local request = event_data.request; if event_name ~= "http-error" and request and not unauthed_endpoints[request.path] then local response = event_data.response; local headers = request.headers; if not headers.authorization then response.headers.www_authenticate = ("Basic realm=%q"):format(module.host.."/"..module.name); return 401; end local user_password = b64_decode(headers.authorization:match("%s(%S*)$")); if user_password ~= credentials then return 401; end end return handlers(event_name, event_data); end);
