Mercurial > prosody-modules
comparison mod_auth_oauth_external/mod_auth_oauth_external.lua @ 5437:49306afbf722
mod_auth_oauth_external: Expect XEP-0106 escaped username in PLAIN
This allows entering an email address as username in some clients by
escaping the @ as \40, enabling authentication against Mastodon
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Wed, 10 May 2023 12:55:13 +0200 |
parents | e7d99bacd0e8 |
children | 53f34e17d590 |
comparison
equal
deleted
inserted
replaced
5436:e7d99bacd0e8 | 5437:49306afbf722 |
---|---|
35 profile.http_client = http.default; -- TODO configurable | 35 profile.http_client = http.default; -- TODO configurable |
36 local extra = { oidc_discovery_url = oidc_discovery_url }; | 36 local extra = { oidc_discovery_url = oidc_discovery_url }; |
37 if token_endpoint and allow_plain then | 37 if token_endpoint and allow_plain then |
38 local map_username = function (username, _realm) return username; end; --jid.join; -- TODO configurable | 38 local map_username = function (username, _realm) return username; end; --jid.join; -- TODO configurable |
39 function profile:plain_test(username, password, realm) | 39 function profile:plain_test(username, password, realm) |
40 username = jid.unescape(username); -- COMPAT Mastodon | |
40 local tok, err = async.wait_for(self.profile.http_client:request(token_endpoint, { | 41 local tok, err = async.wait_for(self.profile.http_client:request(token_endpoint, { |
41 headers = { ["Content-Type"] = "application/x-www-form-urlencoded; charset=utf-8"; ["Accept"] = "application/json" }; | 42 headers = { ["Content-Type"] = "application/x-www-form-urlencoded; charset=utf-8"; ["Accept"] = "application/json" }; |
42 body = http.formencode({ | 43 body = http.formencode({ |
43 grant_type = "password"; | 44 grant_type = "password"; |
44 client_id = client_id; | 45 client_id = client_id; |