You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/modules/ROOT/pages/servlet/oauth2/resource-server/jwt.adoc
+18Lines changed: 18 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -961,7 +961,11 @@ By default, Spring Security will wire the `JwtAuthenticationProvider` with a def
961
961
962
962
As part of configuring a `JwtAuthenticationConverter`, you can supply a subsidiary converter to go from `Jwt` to a `Collection` of granted authorities.
963
963
964
+
[[jwt-granted-authorities-custom-claim-name]]
965
+
==== Using a Custom Claim Name
966
+
964
967
Let's say that your authorization server communicates authorities in a custom claim called `authorities`.
968
+
965
969
In that case, you can configure the claim that <<oauth2resourceserver-jwt-architecture-jwtauthenticationconverter,`JwtAuthenticationConverter`>> should inspect, like so:
966
970
967
971
.Authorities Claim Configuration
@@ -1022,6 +1026,9 @@ Xml::
1022
1026
----
1023
1027
======
1024
1028
1029
+
[[jwt-granted-authorities-custom-scope-prefix]]
1030
+
==== Using a Custom Scope Prefix
1031
+
1025
1032
You can also configure the authority prefix to be different as well.
1026
1033
Instead of prefixing each authority with `SCOPE_`, you can change it to `ROLE_` like so:
1027
1034
@@ -1153,6 +1160,17 @@ class CustomAuthenticationConverterConfig {
1153
1160
----
1154
1161
======
1155
1162
1163
+
[[jwt-granted-authorities-spel-expression]]
1164
+
==== Using a SpEL Expression
1165
+
1166
+
In circumstances where the location of scopes is nested or complex in some other way, you can use `ExpressionJwtGrantedAuthoritiesConverter` with a SpEL expression to extract the scopes.
1167
+
1168
+
For example, if your JWT has a claim called `nested` and, inside of that, it has a claim called `scopes`, you can do:
0 commit comments