[keycloak-user] Java Spring Boot: possible inject user info?

Dana Danet Dana.Danet at Evisions.com
Fri Jul 14 17:09:34 EDT 2017


Dennis,

Add a Security Config class.  Then auto wire your accessToken where needed.


@Configuration
public class SecurityConfig {

    @Bean
    @Scope(scopeName = WebApplicationContext.SCOPE_REQUEST, proxyMode = ScopedProxyMode.TARGET_CLASS)
    public AccessToken getAccessToken() {

        HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.currentRequestAttributes()).getRequest();
        return ((KeycloakPrincipal) request.getUserPrincipal()).getKeycloakSecurityContext().getToken();
    }

}

-dana


On Jul 14, 2017, at 9:27 AM, Dennis H <dennishonders at gmail.com<mailto:dennishonders at gmail.com>> wrote:

Does the keycloak java spring boot library provide a service, that contains
the user info, which can be injected in a class?

If not, how to retrieve the user info from the request?

I can't find this in the docs.
_______________________________________________
keycloak-user mailing list
keycloak-user at lists.jboss.org<mailto:keycloak-user at lists.jboss.org>
https://lists.jboss.org/mailman/listinfo/keycloak-user



More information about the keycloak-user mailing list