Hi, I learn the below way to customize the authority prefix and claim name. Would like to suggest provide configuration properties to allow developer to easily customize the JwtAuthenticationConverter, so that developer does not have to write these boilerplate codes
@Bean
public JwtAuthenticationConverter jwtAuthenticationConverter() {
JwtGrantedAuthoritiesConverter grantedAuthoritiesConverter = new JwtGrantedAuthoritiesConverter();
grantedAuthoritiesConverter.setAuthorityPrefix("");
//grantedAuthoritiesConverter.setAuthoritiesClaimName("role");
JwtAuthenticationConverter jwtAuthenticationConverter = new JwtAuthenticationConverter();
jwtAuthenticationConverter.setJwtGrantedAuthoritiesConverter(grantedAuthoritiesConverter);
return jwtAuthenticationConverter;
}
Comment From: wilkinsona
Thanks for the suggestion. It looks like we could auto-configure a JwtAuthenticationConverter bean if there's no such existing bean in the context and a property has been set for the principal claim name, the authority prefix, or the authorities claim name.
Comment From: mhalbritter
Superseded by https://github.com/spring-projects/spring-boot/pull/38105.