File tree Expand file tree Collapse file tree 5 files changed +97
-6
lines changed
samples/device-grant-authorizationserver/src/main Expand file tree Collapse file tree 5 files changed +97
-6
lines changed Original file line number Diff line number Diff line change @@ -66,6 +66,9 @@ public class SecurityConfig {
66
66
public SecurityFilterChain authorizationServerSecurityFilterChain (HttpSecurity http ) throws Exception {
67
67
OAuth2AuthorizationServerConfiguration .applyDefaultSecurity (http );
68
68
http .getConfigurer (OAuth2AuthorizationServerConfigurer .class )
69
+ .deviceAuthorizationEndpoint ((deviceAuthorizationEndpoint ) -> deviceAuthorizationEndpoint
70
+ .deviceVerificationUri ("/activate" )
71
+ )
69
72
.oidc (Customizer .withDefaults ()); // Enable OpenID Connect 1.0
70
73
71
74
// @formatter:off
Original file line number Diff line number Diff line change 16
16
17
17
package sample .web ;
18
18
19
- import java .util .Map ;
20
-
19
+ import org .springframework .stereotype .Controller ;
21
20
import org .springframework .web .bind .annotation .GetMapping ;
22
- import org .springframework .web .bind .annotation .RestController ;
21
+ import org .springframework .web .bind .annotation .RequestParam ;
23
22
24
23
/**
25
24
* @author Steve Riesenberg
26
25
*/
27
- @ RestController
26
+ @ Controller
28
27
public class DeviceController {
29
28
29
+ @ GetMapping (value = "/activate" , params = "!code" )
30
+ public String activate () {
31
+ return "activate" ;
32
+ }
33
+
34
+ @ GetMapping (value = "/activate" , params = "code" )
35
+ public String activateCode (@ RequestParam ("code" ) String userCode ) {
36
+ return "redirect:/oauth2/device_verification?user_code=" + userCode ;
37
+ }
38
+
39
+ @ GetMapping ("/activated" )
40
+ public String activated () {
41
+ return "activated" ;
42
+ }
43
+
30
44
@ GetMapping (value = "/" , params = "success" )
31
- public Map < String , String > success () {
32
- return Map . of ( "message" , "You have successfully activated your device." ) ;
45
+ public String success () {
46
+ return " activated" ;
33
47
}
34
48
35
49
}
Original file line number Diff line number Diff line change
1
+ <!DOCTYPE html>
2
+ < html lang ="en " xmlns ="http://www.w3.org/1999/xhtml " xmlns:th ="https://www.thymeleaf.org ">
3
+ < head >
4
+ < meta charset ="utf-8 ">
5
+ < meta name ="viewport " content ="width=device-width, initial-scale=1, shrink-to-fit=no ">
6
+ < title > Device Grant Example</ title >
7
+ < link rel ="stylesheet " href ="/webjars/bootstrap/css/bootstrap.css " th:href ="@{/webjars/bootstrap/css/bootstrap.css} " />
8
+ < style rel ="stylesheet ">
9
+ html , body , .container , .jumbotron {
10
+ height : 100% ;
11
+ }
12
+ .jumbotron {
13
+ margin-bottom : 0 ;
14
+ }
15
+ .gap {
16
+ margin-top : 70px ;
17
+ }
18
+ </ style >
19
+ </ head >
20
+ < body >
21
+ < div class ="jumbotron ">
22
+ < div class ="container ">
23
+ < div class ="row ">
24
+ < div class ="col-md-8 ">
25
+ < form th:action ="@{/oauth2/device_verification} " method ="get ">
26
+ < p > Enter the activation code to authorize the device.</ p >
27
+ < p class ="gap "> Activation Code</ p >
28
+ < div class ="form-group ">
29
+ < label class ="sr-only " for ="user_code "> Activation Code</ label >
30
+ < input type ="text " class ="form-control " id ="user_code " name ="user_code " placeholder ="Activation Code " autofocus >
31
+ </ div >
32
+ < button type ="submit " class ="btn btn-default "> Submit</ button >
33
+ </ form >
34
+ </ div >
35
+ < div class ="col-md-4 ">
36
+ < img src ="/assets/img/devices.png " th:src ="@{/assets/img/devices.png} " class ="img-responsive " alt ="Devices ">
37
+ </ div >
38
+ </ div >
39
+ </ div >
40
+ </ div >
41
+ </ body >
42
+ </ html >
Original file line number Diff line number Diff line change
1
+ <!DOCTYPE html>
2
+ < html lang ="en " xmlns ="http://www.w3.org/1999/xhtml " xmlns:th ="https://www.thymeleaf.org ">
3
+ < head >
4
+ < meta charset ="utf-8 ">
5
+ < meta name ="viewport " content ="width=device-width, initial-scale=1, shrink-to-fit=no ">
6
+ < title > Device Grant Example</ title >
7
+ < link rel ="stylesheet " href ="/webjars/bootstrap/css/bootstrap.css " th:href ="@{/webjars/bootstrap/css/bootstrap.css} " />
8
+ < style rel ="stylesheet ">
9
+ html , body , .container , .jumbotron {
10
+ height : 100% ;
11
+ }
12
+ .jumbotron {
13
+ margin-bottom : 0 ;
14
+ }
15
+ </ style >
16
+ </ head >
17
+ < body >
18
+ < div class ="jumbotron ">
19
+ < div class ="container ">
20
+ < div class ="row ">
21
+ < div class ="col-md-8 ">
22
+ < h2 > Success!</ h2 >
23
+ < p > You have successfully activated your device. Please return to your device to continue.</ p >
24
+ </ div >
25
+ < div class ="col-md-4 ">
26
+ < img src ="/assets/img/devices.png " th:src ="@{/assets/img/devices.png} " class ="img-responsive " alt ="Devices ">
27
+ </ div >
28
+ </ div >
29
+ </ div >
30
+ </ div >
31
+ </ body >
32
+ </ html >
You can’t perform that action at this time.
0 commit comments