diff --git a/samples/demo-authorizationserver/samples-demo-authorizationserver.gradle b/samples/demo-authorizationserver/samples-demo-authorizationserver.gradle index f761b82e..d8f5beb1 100644 --- a/samples/demo-authorizationserver/samples-demo-authorizationserver.gradle +++ b/samples/demo-authorizationserver/samples-demo-authorizationserver.gradle @@ -21,8 +21,8 @@ dependencies { implementation "org.springframework.boot:spring-boot-starter-jdbc" implementation project(":spring-security-oauth2-authorization-server") implementation "org.webjars:webjars-locator-core" - implementation "org.webjars:bootstrap:3.4.1" - implementation "org.webjars:jquery:3.4.1" + implementation "org.webjars:bootstrap:5.2.3" + implementation "org.webjars:jquery:3.6.4" runtimeOnly "com.h2database:h2" testImplementation "org.springframework.boot:spring-boot-starter-test" diff --git a/samples/demo-authorizationserver/src/main/java/sample/web/DefaultErrorController.java b/samples/demo-authorizationserver/src/main/java/sample/web/DefaultErrorController.java index f4e55c6e..f0fc8a26 100644 --- a/samples/demo-authorizationserver/src/main/java/sample/web/DefaultErrorController.java +++ b/samples/demo-authorizationserver/src/main/java/sample/web/DefaultErrorController.java @@ -15,15 +15,13 @@ */ package sample.web; -import java.util.Map; - import jakarta.servlet.RequestDispatcher; import jakarta.servlet.http.HttpServletRequest; import org.springframework.boot.web.servlet.error.ErrorController; import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.servlet.ModelAndView; /** * @author Steve Riesenberg @@ -33,12 +31,16 @@ import org.springframework.web.servlet.ModelAndView; public class DefaultErrorController implements ErrorController { @RequestMapping("/error") - public ModelAndView handleError(HttpServletRequest request) { - String message = getErrorMessage(request); - if (message.startsWith("[access_denied]")) { - return new ModelAndView("access-denied"); + public String handleError(Model model, HttpServletRequest request) { + String errorMessage = getErrorMessage(request); + if (errorMessage.startsWith("[access_denied]")) { + model.addAttribute("errorTitle", "Access Denied"); + model.addAttribute("errorMessage", "You have denied access."); + } else { + model.addAttribute("errorTitle", "Error"); + model.addAttribute("errorMessage", errorMessage); } - return new ModelAndView("error", Map.of("message", message)); + return "error"; } private String getErrorMessage(HttpServletRequest request) { diff --git a/samples/demo-authorizationserver/src/main/java/sample/web/DeviceController.java b/samples/demo-authorizationserver/src/main/java/sample/web/DeviceController.java index fae0429e..b9cc9ee8 100644 --- a/samples/demo-authorizationserver/src/main/java/sample/web/DeviceController.java +++ b/samples/demo-authorizationserver/src/main/java/sample/web/DeviceController.java @@ -31,17 +31,17 @@ public class DeviceController { if (userCode != null) { return "redirect:/oauth2/device_verification?user_code=" + userCode; } - return "activate"; + return "device-activate"; } @GetMapping("/activated") public String activated() { - return "activated"; + return "device-activated"; } @GetMapping(value = "/", params = "success") public String success() { - return "activated"; + return "device-activated"; } } diff --git a/samples/demo-authorizationserver/src/main/resources/static/assets/css/signin.css b/samples/demo-authorizationserver/src/main/resources/static/assets/css/signin.css new file mode 100644 index 00000000..2ee098f2 --- /dev/null +++ b/samples/demo-authorizationserver/src/main/resources/static/assets/css/signin.css @@ -0,0 +1,32 @@ +html, +body { + height: 100%; +} + +body { + display: flex; + align-items: start; + padding-top: 100px; + background-color: #f5f5f5; +} + +.form-signin { + max-width: 330px; + padding: 15px; +} + +.form-signin .form-floating:focus-within { + z-index: 2; +} + +.form-signin input[type="username"] { + margin-bottom: -1px; + border-bottom-right-radius: 0; + border-bottom-left-radius: 0; +} + +.form-signin input[type="password"] { + margin-bottom: 10px; + border-top-left-radius: 0; + border-top-right-radius: 0; +} diff --git a/samples/demo-authorizationserver/src/main/resources/static/assets/css/style.css b/samples/demo-authorizationserver/src/main/resources/static/assets/css/style.css deleted file mode 100644 index d50ee00e..00000000 --- a/samples/demo-authorizationserver/src/main/resources/static/assets/css/style.css +++ /dev/null @@ -1,13 +0,0 @@ -html, body, .container, .jumbotron { - height: 100%; -} -.jumbotron { - margin-bottom: 0; -} -.gap { - margin-top: 70px; -} -.code { - font-size: 2em; - letter-spacing: 2rem; -} \ No newline at end of file diff --git a/samples/demo-authorizationserver/src/main/resources/static/assets/img/devices.png b/samples/demo-authorizationserver/src/main/resources/static/assets/img/devices.png new file mode 100644 index 00000000..fda6b12e Binary files /dev/null and b/samples/demo-authorizationserver/src/main/resources/static/assets/img/devices.png differ diff --git a/samples/demo-authorizationserver/src/main/resources/static/assets/img/github.png b/samples/demo-authorizationserver/src/main/resources/static/assets/img/github.png new file mode 100644 index 00000000..e28a8373 Binary files /dev/null and b/samples/demo-authorizationserver/src/main/resources/static/assets/img/github.png differ diff --git a/samples/demo-authorizationserver/src/main/resources/static/assets/img/google.png b/samples/demo-authorizationserver/src/main/resources/static/assets/img/google.png new file mode 100644 index 00000000..795dea31 Binary files /dev/null and b/samples/demo-authorizationserver/src/main/resources/static/assets/img/google.png differ diff --git a/samples/demo-authorizationserver/src/main/resources/templates/access-denied.html b/samples/demo-authorizationserver/src/main/resources/templates/access-denied.html deleted file mode 100644 index c358bc7b..00000000 --- a/samples/demo-authorizationserver/src/main/resources/templates/access-denied.html +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - Spring Security Example - - - - -
-
-
-

Access Denied

-

You have denied access.

-
-
-
- - diff --git a/samples/demo-authorizationserver/src/main/resources/templates/activate.html b/samples/demo-authorizationserver/src/main/resources/templates/activate.html deleted file mode 100644 index 4607e0de..00000000 --- a/samples/demo-authorizationserver/src/main/resources/templates/activate.html +++ /dev/null @@ -1,33 +0,0 @@ - - - - - - Device Grant Example - - - - -
-
-
-
-
-

Device Activation

-

Enter the activation code to authorize the device.

-

Activation Code

-
- - -
- -
-
-
- Devices -
-
-
-
- - diff --git a/samples/demo-authorizationserver/src/main/resources/templates/activated.html b/samples/demo-authorizationserver/src/main/resources/templates/activated.html deleted file mode 100644 index 02598da2..00000000 --- a/samples/demo-authorizationserver/src/main/resources/templates/activated.html +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - Device Grant Example - - - - -
-
-
-
-

Success!

-

You have successfully activated your device. Please return to your device to continue.

-
-
- Devices -
-
-
-
- - \ No newline at end of file diff --git a/samples/demo-authorizationserver/src/main/resources/templates/consent.html b/samples/demo-authorizationserver/src/main/resources/templates/consent.html index 5c32c534..5a4a5f6e 100644 --- a/samples/demo-authorizationserver/src/main/resources/templates/consent.html +++ b/samples/demo-authorizationserver/src/main/resources/templates/consent.html @@ -1,44 +1,48 @@ - + - - - + + Custom consent page - Consent required - + +
-
+

App permissions

The application - + wants to access your account - +

-

You have provided the code - . +

+ 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.

+
+

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

+
@@ -47,33 +51,37 @@ -
+
- +

-

You have already granted the following permissions to the above app:

-
+

+ You have already granted the following permissions to the above app: +

+
- +

-
+
-
+
@@ -85,8 +93,8 @@

- Your consent to provide access is required. -
If you do not approve, click Cancel, in which case no information will be shared with the app. + Your consent to provide access is required.
+ If you do not approve, click Cancel, in which case no information will be shared with the app.

diff --git a/samples/demo-authorizationserver/src/main/resources/templates/device-activate.html b/samples/demo-authorizationserver/src/main/resources/templates/device-activate.html new file mode 100644 index 00000000..bea73929 --- /dev/null +++ b/samples/demo-authorizationserver/src/main/resources/templates/device-activate.html @@ -0,0 +1,33 @@ + + + + + + Spring Authorization Server sample + + + +
+
+
+

Device Activation

+

Enter the activation code to authorize the device.

+
+
+
+ + +
+
+ +
+
+
+
+
+ Devices +
+
+
+ + diff --git a/samples/demo-authorizationserver/src/main/resources/templates/device-activated.html b/samples/demo-authorizationserver/src/main/resources/templates/device-activated.html new file mode 100644 index 00000000..ef180ba2 --- /dev/null +++ b/samples/demo-authorizationserver/src/main/resources/templates/device-activated.html @@ -0,0 +1,25 @@ + + + + + + Spring Authorization Server sample + + + +
+
+
+

Success!

+

+ You have successfully activated your device.
+ Please return to your device to continue. +

+
+
+ Devices +
+
+
+ + diff --git a/samples/demo-authorizationserver/src/main/resources/templates/error.html b/samples/demo-authorizationserver/src/main/resources/templates/error.html index 7bf6baae..eceb5ce0 100644 --- a/samples/demo-authorizationserver/src/main/resources/templates/error.html +++ b/samples/demo-authorizationserver/src/main/resources/templates/error.html @@ -1,20 +1,19 @@ - - - - Spring Security Example - - - - -
-
-
-

Error

-

-
-
+ + + + Spring Authorization Server sample + + + +
+
+
+

+

- +
+
+ diff --git a/samples/demo-authorizationserver/src/main/resources/templates/login.html b/samples/demo-authorizationserver/src/main/resources/templates/login.html index 7c8323f5..353315ab 100644 --- a/samples/demo-authorizationserver/src/main/resources/templates/login.html +++ b/samples/demo-authorizationserver/src/main/resources/templates/login.html @@ -1,41 +1,42 @@ - + - - - Spring Security Example - - + + + Spring Authorization Server sample + +
-
- \ No newline at end of file +