mod_auth_oauth_external: Allow different username in PLAIN vs final JID
Mastodon for example having email addresses usernames in login, but a
different username in the service itself.
Thanks to @tcit@social.tcit.fr for the pointer to a usable validation
endpoint for Mastodon, allowing this to be tested.
--- a/mod_auth_oauth_external/mod_auth_oauth_external.lua Wed May 10 13:45:28 2023 +0200
+++ b/mod_auth_oauth_external/mod_auth_oauth_external.lua Wed May 10 13:52:31 2023 +0200
@@ -71,9 +71,12 @@
return false, nil;
end
local response = json.decode(ret.body);
- if type(response) ~= "table" or (response[username_field]) ~= username then
+ if type(response) ~= "table" then
+ return false, nil, nil;
+ elseif type(response[username_field]) ~= "string" then
return false, nil, nil;
end
+ self.username = jid.escape(response[username_field]);
self.token_info = response;
return true, true;
end