[keycloak-user] How to obtain KeycloakDeployment instance in wf10?

Thomas Darimont thomas.darimont at googlemail.com
Tue Mar 29 15:19:59 EDT 2016


Hello Hristo,

you should be able to access a KeycloakSecurityContext from the
(Servlet)HttpRequest:
KeycloakSecurityContext securityContext = (KeycloakSecurityContext)
httpRequest.getAttribute(KeycloakSecurityContext.class.getName());
KeycloakSecurityContext gives you access to the IDToken as well as the
AccessToken.

You should also be able to cast securityContext to
RefreshableKeycloakSecurityContext. This gives you access to
the KeycloakDeployment configuration.
org.keycloak.adapters.RefreshableKeycloakSecurityContext#getDeployment

See:
https://github.com/keycloak/keycloak/blob/master/examples/demo-template/database-service/src/main/java/org/keycloak/example/oauth/CustomerService.java#L48

Cheers,
Thomas

2016-03-29 20:43 GMT+02:00 Hristo Stoyanov <hr.stoyanov at peruncs.com>:

> Hi,
> I configure KC via my WF10 standalone.xml
> file rather than changing my war package. How do I obtain
> KeycloakDeployment instance in my app, so I can place rest calls as my
> service account, using the secret and app id?
> Any code sample is appreciated!
>
> /Hristo Stoyanov
>
> _______________________________________________
> keycloak-user mailing list
> keycloak-user at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/keycloak-user
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/keycloak-user/attachments/20160329/81d5e945/attachment.html 


More information about the keycloak-user mailing list