Skip to content

Commit 95b2cdf

Browse files
committed
Clarify JavaDoc
Removed note about DelegatingJwtGrantedAuthoritiesConverter from ExpressionJwtGrantedAuthoritiesConverter and further explained in DelegatingJwtGrantedAuthoritiesConverter where it comes in handy. Issue gh-18300 Signed-off-by: Josh Cummings <3627351+jzheaux@users.noreply.github.com>
1 parent 3ecf848 commit 95b2cdf

2 files changed

Lines changed: 17 additions & 3 deletions

File tree

oauth2/oauth2-resource-server/src/main/java/org/springframework/security/oauth2/server/resource/authentication/DelegatingJwtGrantedAuthoritiesConverter.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,23 @@
3030
* A {@link Jwt} to {@link GrantedAuthority} {@link Converter} that is a composite of
3131
* converters.
3232
*
33+
* <p>
34+
* This is handy when needing to read authorities from multiple locations in a JWT; each
35+
* underlying converter is called in series and the results are aggregated into a single
36+
* collection of authorities.
37+
*
38+
* <p>
39+
* For example, you might have a claim called "scope" and another called "roles". With
40+
* {@link DelegatingJwtGrantedAuthoritiesConverter}, you can do:
41+
*
42+
* <code>
43+
* JwtGrantedAuthoritiesConverter scopes = new JwtGrantedAuthoritiesConverter();
44+
* JwtGrantedAuthoritiesConverter roles = new JwtGrantedAUthoritiesConverter();
45+
* roles.setAuthoritiesClaimName("roles");
46+
* roles.setAuthorityPrefix("ROLE_");
47+
* return new DelegatingJwtGrantedAuthoritiesConverter(scopes, roles);
48+
* </code>
49+
*
3350
* @author Laszlo Stahorszki
3451
* @author Josh Cummings
3552
* @since 5.5

oauth2/oauth2-resource-server/src/main/java/org/springframework/security/oauth2/server/resource/authentication/ExpressionJwtGrantedAuthoritiesConverter.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,6 @@
3636
* Uses an expression for extracting the token claim value to use for mapping
3737
* {@link GrantedAuthority authorities}.
3838
*
39-
* Note this can be used in combination with a
40-
* {@link DelegatingJwtGrantedAuthoritiesConverter}.
41-
*
4239
* @author Thomas Darimont
4340
* @since 6.4
4441
*/

0 commit comments

Comments
 (0)