Mercurial > prosody-modules
comparison mod_http_authentication/mod_http_authentication.lua @ 3442:05725785e3a6
mod_http_authentication: Allow HTTP error events to pass through (fixes #1293)
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Tue, 15 Jan 2019 15:01:04 +0100 |
| parents | c6e86b74f62e |
| children |
comparison
equal
deleted
inserted
replaced
| 3441:0bff7d5ca81d | 3442:05725785e3a6 |
|---|---|
| 7 local credentials = module:get_option_string("http_credentials", "username:secretpassword"); | 7 local credentials = module:get_option_string("http_credentials", "username:secretpassword"); |
| 8 local unauthed_endpoints = module:get_option_set("unauthenticated_http_endpoints", { "/http-bind", "/http-bind/" })._items; | 8 local unauthed_endpoints = module:get_option_set("unauthenticated_http_endpoints", { "/http-bind", "/http-bind/" })._items; |
| 9 | 9 |
| 10 module:wrap_object_event(server._events, false, function (handlers, event_name, event_data) | 10 module:wrap_object_event(server._events, false, function (handlers, event_name, event_data) |
| 11 local request = event_data.request; | 11 local request = event_data.request; |
| 12 if request and not unauthed_endpoints[request.path] then | 12 if event_name ~= "http-error" and request and not unauthed_endpoints[request.path] then |
| 13 local response = event_data.response; | 13 local response = event_data.response; |
| 14 local headers = request.headers; | 14 local headers = request.headers; |
| 15 if not headers.authorization then | 15 if not headers.authorization then |
| 16 response.headers.www_authenticate = ("Basic realm=%q"):format(module.host.."/"..module.name); | 16 response.headers.www_authenticate = ("Basic realm=%q"):format(module.host.."/"..module.name); |
| 17 return 401; | 17 return 401; |
