Skip to content

Commit 9a75c0b

Browse files
authored
Merge pull request #18418 from Psynbiotik/patch-1
Have authenticationConverter use the interface AuthoritiesConverter
2 parents 9c129b0 + b1fdf13 commit 9a75c0b

File tree

2 files changed

+2
-3
lines changed
  • spring-boot-modules/spring-boot-keycloak

2 files changed

+2
-3
lines changed

spring-boot-modules/spring-boot-keycloak/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ The <em>AuthoritiesConverter</em> interface is a tip for the bean factory becaus
247247
As we configured Keycloak as an OpenID Provider by providing just its <em>issuer-uri</em>, what we get as input in the <em>GrantedAuthoritiesMapper</em> are <em>OidcUserAuthority</em> instances:
248248
<pre><code class="language-java">@Bean
249249
GrantedAuthoritiesMapper authenticationConverter(
250-
Converter&lt;Map&lt;String, Object&gt;, Collection&lt;GrantedAuthority&gt;&gt; realmRolesAuthoritiesConverter) {
250+
AuthoritiesConverter realmRolesAuthoritiesConverter) {
251251
return (authorities) -&gt; authorities.stream().filter(authority -&gt; authority instanceof OidcUserAuthority)
252252
.map(OidcUserAuthority.class::cast).map(OidcUserAuthority::getIdToken).map(OidcIdToken::getClaims)
253253
.map(realmRolesAuthoritiesConverter::convert)

spring-boot-modules/spring-boot-keycloak/spring-boot-resource-server/src/main/java/com/baeldung/boot/keycloak/resourceserver/SecurityConfig.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,7 @@ AuthoritiesConverter realmRolesAuthoritiesConverter() {
4242
}
4343

4444
@Bean
45-
JwtAuthenticationConverter authenticationConverter(
46-
Converter<Map<String, Object>, Collection<GrantedAuthority>> authoritiesConverter) {
45+
JwtAuthenticationConverter authenticationConverter(AuthoritiesConverter authoritiesConverter) {
4746
JwtAuthenticationConverter jwtAuthenticationConverter = new JwtAuthenticationConverter();
4847
jwtAuthenticationConverter
4948
.setJwtGrantedAuthoritiesConverter(jwt -> authoritiesConverter.convert(jwt.getClaims()));

0 commit comments

Comments
 (0)