Software / code / prosody-modules
Changeset
6281:9d88c3d9eea5
mod_http_oauth2: Enforce the registered grant types
Thus a client can limit itself to certain grant types.
Not sure if this prevents any attacks, but what was the point of
including this in the registration if it was not going to be enforced?
This became easier to do with client_id being available earlier.
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Mon, 02 Jun 2025 20:55:20 +0200 |
| parents | 6280:4b52d579bc70 |
| children | 6282:7b3316ac24b3 |
| files | mod_http_oauth2/mod_http_oauth2.lua |
| diffstat | 1 files changed, 13 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/mod_http_oauth2/mod_http_oauth2.lua Mon Jun 02 12:59:32 2025 +0100 +++ b/mod_http_oauth2/mod_http_oauth2.lua Mon Jun 02 20:55:20 2025 +0200 @@ -878,6 +878,19 @@ if not grant_handler then return oauth_error("invalid_request", "No such grant type."); end + + local grant_type_allowed = false; + for _, client_grant_type in ipairs(client.grant_types or { "authorization_code" }) do + if client_grant_type == grant_type then + grant_type_allowed = true; + break + end + end + + if not grant_type_allowed then + return oauth_error("invalid_request", "'grant_type' not registered"); + end + return grant_handler(params, client); end