Return 401 with correct realm when no user/pass is provided
authorNicolas Cedilnik <nicoco@nicoco.fr>
Tue, 20 Feb 2018 17:30:17 +0100
changeset 2890 5ca6d53d3186
parent 2889 88b16084eda7
child 2891 65082d91950e
Return 401 with correct realm when no user/pass is provided
mod_http_auth_check/mod_http_auth_check.lua
--- a/mod_http_auth_check/mod_http_auth_check.lua	Tue Feb 20 14:59:03 2018 +0000
+++ b/mod_http_auth_check/mod_http_auth_check.lua	Tue Feb 20 17:30:17 2018 +0100
@@ -14,7 +14,8 @@
 	local response = event.response;
 	local headers = request.headers;
 	if not headers.authorization then
-		return 400
+		response.headers.www_authenticate = ("Basic realm=%q"):format(realm);
+		return 401
 	end
 	local from_jid, password = b64_decode(headers.authorization:match"[^ ]*$"):match"([^:]*):(.*)";
 	from_jid = jid_prep(from_jid);