equal
deleted
inserted
replaced
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 |