changeset 5614:7565298aa197

mod_http_oauth2: Allow a shorter form of the device grant in config Long URI is long
author Kim Alvefur <zash@zash.se>
date Fri, 21 Jul 2023 00:37:34 +0200
parents a9682cad0e67
children 308b5b117379
files mod_http_oauth2/README.markdown mod_http_oauth2/mod_http_oauth2.lua
diffstat 2 files changed, 7 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mod_http_oauth2/README.markdown	Fri Jul 21 00:29:24 2023 +0200
+++ b/mod_http_oauth2/README.markdown	Fri Jul 21 00:37:34 2023 +0200
@@ -224,7 +224,7 @@
 -- These examples reflect the defaults
 allowed_oauth2_grant_types = {
 	"authorization_code"; -- authorization code grant
-	"urn:ietf:params:oauth:grant-type:device_code";
+	"device_code";
 	"password"; -- resource owner password grant
 }
 
--- a/mod_http_oauth2/mod_http_oauth2.lua	Fri Jul 21 00:29:24 2023 +0200
+++ b/mod_http_oauth2/mod_http_oauth2.lua	Fri Jul 21 00:37:34 2023 +0200
@@ -747,6 +747,12 @@
 	"refresh_token";
 	device_uri;
 })
+if allowed_grant_type_handlers:contains("device_code") then
+	-- expand short form because that URI is long
+	module:log("debug", "Expanding %q to %q in '%s'", "device_code", device_uri, "allowed_oauth2_grant_types");
+	allowed_grant_type_handlers:remove("device_code");
+	allowed_grant_type_handlers:add(device_uri);
+end
 for handler_type in pairs(grant_type_handlers) do
 	if not allowed_grant_type_handlers:contains(handler_type) then
 		module:log("debug", "Grant type %q disabled", handler_type);