aboutsummaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2023-03-16 12:18:23 +0100
committerKim Alvefur <zash@zash.se>2023-03-16 12:18:23 +0100
commit566a991f8499d815314b695cb52959f334bcb9e9 (patch)
tree09b7f104dff8548c555e62e9199633917f789596 /plugins
parent944c25f3522f0ae649b2e9d04729bf2278387744 (diff)
downloadprosody-566a991f8499d815314b695cb52959f334bcb9e9.tar.gz
prosody-566a991f8499d815314b695cb52959f334bcb9e9.zip
util.sasl.oauthbearer: Return username from callback instead using authzid (BC)
RFC 6120 states that > If the initiating entity does not wish to act on behalf of another > entity, it MUST NOT provide an authorization identity. Thus it seems weird to require it here. We can instead expect an username from the token data passed back from the profile. This follows the practice of util.sasl.external where the profile callback returns the selected username, making the authentication module responsible for extracting the username from the token.
Diffstat (limited to 'plugins')
-rw-r--r--plugins/mod_tokenauth.lua12
1 files changed, 7 insertions, 5 deletions
diff --git a/plugins/mod_tokenauth.lua b/plugins/mod_tokenauth.lua
index 03f6b961..f1bd084a 100644
--- a/plugins/mod_tokenauth.lua
+++ b/plugins/mod_tokenauth.lua
@@ -125,19 +125,21 @@ function revoke_token(token)
end
function sasl_handler(auth_provider, purpose, extra)
- return function (_, username, token, realm)
+ return function (sasl, token, realm, _authzid)
local token_info, err = get_token_info(token);
if not token_info then
module:log("debug", "SASL handler failed to verify token: %s", err);
return nil, nil, extra;
end
- local token_user, token_host = jid.split(token_info.jid);
- if username ~= token_user or realm ~= token_host or (purpose and token_info.purpose ~= purpose) then
+ local token_user, token_host, resource = jid.split(token_info.jid);
+ if realm ~= token_host or (purpose and token_info.purpose ~= purpose) then
return nil, nil, extra;
end
- if auth_provider.is_enabled and not auth_provider.is_enabled(username) then
+ if auth_provider.is_enabled and not auth_provider.is_enabled(token_user) then
return true, false, token_info;
end
- return true, true, token_info;
+ sasl.resource = resource;
+ sasl.token_info = token_info;
+ return token_user, true, token_info;
end;
end