comparison mod_auth_oauth_external/mod_auth_oauth_external.lua @ 5440:82a14082be3f

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.
author Kim Alvefur <zash@zash.se>
date Wed, 10 May 2023 13:52:31 +0200
parents 721f79ac88d8
children 7480dde4cd2e
comparison
equal deleted inserted replaced
5439:721f79ac88d8 5440:82a14082be3f
69 end 69 end
70 if not (ret.code >= 200 and ret.code < 300) then 70 if not (ret.code >= 200 and ret.code < 300) then
71 return false, nil; 71 return false, nil;
72 end 72 end
73 local response = json.decode(ret.body); 73 local response = json.decode(ret.body);
74 if type(response) ~= "table" or (response[username_field]) ~= username then 74 if type(response) ~= "table" then
75 return false, nil, nil;
76 elseif type(response[username_field]) ~= "string" then
75 return false, nil, nil; 77 return false, nil, nil;
76 end 78 end
79 self.username = jid.escape(response[username_field]);
77 self.token_info = response; 80 self.token_info = response;
78 return true, true; 81 return true, true;
79 end 82 end
80 end 83 end
81 if validation_endpoint then 84 if validation_endpoint then