File tree 2 files changed +21
-3
lines changed
samples/boot/saml2login/src/main 2 files changed +21
-3
lines changed Original file line number Diff line number Diff line change 1
1
/*
2
- * Copyright 2002-2019 the original author or authors.
2
+ * Copyright 2002-2020 the original author or authors.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
16
16
17
17
package sample ;
18
18
19
+ import org .springframework .security .core .annotation .AuthenticationPrincipal ;
20
+ import org .springframework .security .saml2 .provider .service .authentication .Saml2AuthenticatedPrincipal ;
19
21
import org .springframework .stereotype .Controller ;
22
+ import org .springframework .ui .Model ;
20
23
import org .springframework .web .bind .annotation .GetMapping ;
21
24
22
25
@ Controller
23
26
public class IndexController {
24
27
25
28
@ GetMapping ("/" )
26
- public String index () {
29
+ public String index (Model model ,
30
+ @ AuthenticationPrincipal Saml2AuthenticatedPrincipal principal ) {
31
+ String emailAddress = principal .getFirstAttribute ("emailAddress" );
32
+ model .addAttribute ("emailAddress" , emailAddress );
33
+ model .addAttribute ("userAttributes" , principal .getAttributes ());
27
34
return "index" ;
28
35
}
29
36
}
Original file line number Diff line number Diff line change 19
19
< head >
20
20
< title > Spring Security - SAML 2.0 Login</ title >
21
21
< meta charset ="utf-8 " />
22
+ < style >
23
+ span , dt {
24
+ font-weight : bold;
25
+ }
26
+ </ style >
22
27
</ head >
23
28
< body >
24
29
< div >
30
35
</ a >
31
36
</ div >
32
37
< h1 > SAML 2.0 Login with Spring Security</ h1 >
33
- < div > You are successfully logged in as < span sec:authentication ="name "> </ span > </ div >
38
+ < p > You are successfully logged in as < span sec:authentication ="name "> </ span > </ p >
39
+ < p > You're email address is < span th:text ="${emailAddress} "> </ span > </ p >
40
+ < h2 > All Your Attributes</ h2 >
41
+ < dl th:each ="userAttribute : ${userAttributes} ">
42
+ < dt th:text ="${userAttribute.key} "> </ dt >
43
+ < dd th:text ="${userAttribute.value} "> </ dd >
44
+ </ dl >
34
45
</ body >
35
46
</ html >
You can’t perform that action at this time.
0 commit comments