diff --git a/samples/featured-authorizationserver/src/main/java/sample/config/AuthorizationServerConfig.java b/samples/featured-authorizationserver/src/main/java/sample/config/AuthorizationServerConfig.java index 60865ad1..f8ffd3f6 100644 --- a/samples/featured-authorizationserver/src/main/java/sample/config/AuthorizationServerConfig.java +++ b/samples/featured-authorizationserver/src/main/java/sample/config/AuthorizationServerConfig.java @@ -102,6 +102,9 @@ public class AuthorizationServerConfig { .deviceAuthorizationEndpoint(deviceAuthorizationEndpoint -> deviceAuthorizationEndpoint.verificationUri("/activate") ) + .deviceVerificationEndpoint(deviceVerificationEndpoint -> + deviceVerificationEndpoint.consentPage(CUSTOM_CONSENT_PAGE_URI) + ) .clientAuthentication(clientAuthentication -> clientAuthentication .authenticationConverter(deviceClientAuthenticationConverter) diff --git a/samples/featured-authorizationserver/src/main/java/sample/web/AuthorizationConsentController.java b/samples/featured-authorizationserver/src/main/java/sample/web/AuthorizationConsentController.java index c1c8f298..c21e6e87 100644 --- a/samples/featured-authorizationserver/src/main/java/sample/web/AuthorizationConsentController.java +++ b/samples/featured-authorizationserver/src/main/java/sample/web/AuthorizationConsentController.java @@ -52,7 +52,8 @@ public class AuthorizationConsentController { public String consent(Principal principal, Model model, @RequestParam(OAuth2ParameterNames.CLIENT_ID) String clientId, @RequestParam(OAuth2ParameterNames.SCOPE) String scope, - @RequestParam(OAuth2ParameterNames.STATE) String state) { + @RequestParam(OAuth2ParameterNames.STATE) String state, + @RequestParam(name = OAuth2ParameterNames.USER_CODE, required = false) String userCode) { // Remove scopes that were already approved Set scopesToApprove = new HashSet<>(); @@ -82,6 +83,12 @@ public class AuthorizationConsentController { model.addAttribute("scopes", withDescription(scopesToApprove)); model.addAttribute("previouslyApprovedScopes", withDescription(previouslyApprovedScopes)); model.addAttribute("principalName", principal.getName()); + model.addAttribute("userCode", userCode); + if (StringUtils.hasText(userCode)) { + model.addAttribute("requestURI", "/oauth2/device_verification"); + } else { + model.addAttribute("requestURI", "/oauth2/authorize"); + } return "consent"; } diff --git a/samples/featured-authorizationserver/src/main/resources/templates/consent.html b/samples/featured-authorizationserver/src/main/resources/templates/consent.html index fbfc8a37..5c32c534 100644 --- a/samples/featured-authorizationserver/src/main/resources/templates/consent.html +++ b/samples/featured-authorizationserver/src/main/resources/templates/consent.html @@ -28,15 +28,24 @@

+
+
+

You have provided the code + . + Verify that this code matches what is shown on your device. +

+
+

The following permissions are requested by the above app.
Please review these and consent if you approve.

-
+ +