use of org.keycloak.adapters.springsecurity.token.KeycloakAuthenticationToken in project shinyproxy by openanalytics.
the class KeycloakAuthenticationBackend method keycloakAuthenticationProvider.
protected KeycloakAuthenticationProvider keycloakAuthenticationProvider() {
return new KeycloakAuthenticationProvider() {
@Override
public Authentication authenticate(Authentication authentication) throws AuthenticationException {
KeycloakAuthenticationToken token = (KeycloakAuthenticationToken) super.authenticate(authentication);
List<GrantedAuthority> auth = token.getAuthorities().stream().map(t -> t.getAuthority().toUpperCase()).map(a -> a.startsWith("ROLE_") ? a : "ROLE_" + a).map(a -> new KeycloakRole(a)).collect(Collectors.toList());
return new KeycloakAuthenticationToken2(token.getAccount(), auth);
}
};
}
Aggregations