File tree Expand file tree Collapse file tree 1 file changed +11
-4
lines changed
docs/manual/src/docs/asciidoc/_includes/servlet/preface Expand file tree Collapse file tree 1 file changed +11
-4
lines changed Original file line number Diff line number Diff line change @@ -706,17 +706,24 @@ public class DirectlyConfiguredJwkSetUri extends WebSecurityConfigurerAdapter {
706
706
}
707
707
708
708
Converter<Jwt, AbstractAuthenticationToken> grantedAuthoritiesExtractor() {
709
- return new GrantedAuthoritiesExtractor();
709
+ JwtAuthenticationConverter jwtAuthenticationConverter =
710
+ new JwtAuthenticationConverter();
711
+ jwtAuthenticationConverter.setJwtGrantedAuthoritiesConverter
712
+ (new GrantedAuthoritiesExtractor());
713
+ return jwtAuthenticationConveter;
710
714
}
711
715
```
712
716
713
717
which is responsible for converting a `Jwt` into an `Authentication`.
718
+ As part of its configuration, we can supply a subsidiary converter to go from `Jwt` to a `Collection` of `GrantedAuthority`s.
714
719
715
- We can override this quite simply to alter the way granted authorities are derived :
720
+ That final converter might be something like `GrantedAuthoritiesExtractor` below :
716
721
717
722
```java
718
- static class GrantedAuthoritiesExtractor extends JwtAuthenticationConverter {
719
- protected Collection<GrantedAuthority> extractAuthorities(Jwt jwt) {
723
+ static class GrantedAuthoritiesExtractor
724
+ implements Converter<Jwt, Collection<GrantedAuthority>> {
725
+
726
+ public Collection<GrantedAuthority> convert(Jwt jwt) {
720
727
Collection<String> authorities = (Collection<String>)
721
728
jwt.getClaims().get("mycustomclaim");
722
729
You can’t perform that action at this time.
0 commit comments