mod_http_auth_check/mod_http_auth_check.lua
changeset 2890 5ca6d53d3186
parent 2888 16e9f37b3f82
equal deleted inserted replaced
2889:88b16084eda7 2890:5ca6d53d3186
    12 local function authenticate (event, path)
    12 local function authenticate (event, path)
    13 	local request = event.request;
    13 	local request = event.request;
    14 	local response = event.response;
    14 	local response = event.response;
    15 	local headers = request.headers;
    15 	local headers = request.headers;
    16 	if not headers.authorization then
    16 	if not headers.authorization then
    17 		return 400
    17 		response.headers.www_authenticate = ("Basic realm=%q"):format(realm);
       
    18 		return 401
    18 	end
    19 	end
    19 	local from_jid, password = b64_decode(headers.authorization:match"[^ ]*$"):match"([^:]*):(.*)";
    20 	local from_jid, password = b64_decode(headers.authorization:match"[^ ]*$"):match"([^:]*):(.*)";
    20 	from_jid = jid_prep(from_jid);
    21 	from_jid = jid_prep(from_jid);
    21 	password = saslprep(password);
    22 	password = saslprep(password);
    22 	if from_jid and password then
    23 	if from_jid and password then