[keycloak-dev] getAuthorizationContext from RefreshableKeycloakSecurityContext with Spring Security

Ignacio Ocampo nafiux at gmail.com
Mon Nov 21 14:43:08 EST 2016


Hello Team,

I've an Spring Boot application with Spring Security Core, everything is
working fine in terms of authentication.

The next step is to setup the authorization with "Authorization enabled" in
the Client.

I've a problem trying to obtain the authorizationContext from
RefreshableKeycloakSecurityContext

KeycloakSecurityContext keycloakSecurityContext = (KeycloakSecurityContext)
request.getAttribute(KeycloakSecurityContext.class.getName());

> org.keycloak.adapters.RefreshableKeycloakSecurityContext at 69d7e12b
>

AuthorizationContext authzContext =
keycloakSecurityContext.getAuthorizationContext();

> null
>
Could you please help me to understand how I can get the authorization
context?

In my keycloak.json I have:

{
>   "realm": "MyRealName",
>   "auth-server-url": "http://myendpoint/auth",
>   "ssl-required": "none",
>   "resource": "serviceName",
>   "credentials": {
>     "secret": "XXX-XXX-XXX"
>   },
>   "policy-enforcer": {
>   "enforcement-mode" : "ENFORCING"
>   }
> }


Thanks

Regards.

-- 
Ignacio Ocampo Millán


More information about the keycloak-dev mailing list