Realm has to be a part of user account url. That's built into Keycloak server, and how its service endpoints are structured.

Within your application you can use HttpServletRequest attributes to get to KeycloakDeployment, which contains information about the realm your application was configured with:

KeycloakSecurityContext ctx = (KeycloakSecurityContext) request.getAttribute(KeycloakSecurityContext.class.getName());
KeycloakDeployment deployment = ((RefreshableKeycloakSecurityContext) ctx).getDeployment();
String realm = deployment.getRealm();

You can now use this realm to construct user account URL. I'm not sure if this is part of our public API. There is realm on KeycloakSecurityContext, but that one is only available if user is currently logged in.


On Fri, Feb 19, 2016 at 9:17 PM, Bill Simakis <smacksnr@hotmail.com> wrote:
Marko,

Thanks but is there a way without having to hard-code the realm name? 

Thanks,

Bill

----------------------------------------
> Date: Tue, 16 Feb 2016 22:08:21 +0100
> Subject: Re: [keycloak-user] User Account access from client
> From: mstrukel@redhat.com
> To: smacksnr@hotmail.com
> CC: keycloak-user@lists.jboss.org
>
> You can take a look at how example demo app does this:
>
> https://github.com/keycloak/keycloak/blob/1.9.0.CR1/examples/demo-template/customer-app/src/main/webapp/customers/view.jsp#L16
>
> On Tue, Feb 16, 2016 at 5:44 PM, Bill Simakis <smacksnr@hotmail.com> wrote:
>> I have a web app using the spring security adapter which I have successfully integrated for the authentication/Authorization with KeyCloak.
>> We wanted to make the user's life a little easier by providing a link within our app to allow an authenticated user to go to their Account page in KeyCloak. As this link is realm specific, is there a way we could get the url dynamically?
>>
>> Thanks
>>
>> Bill
>> _______________________________________________
>> keycloak-user mailing list
>> keycloak-user@lists.jboss.org
>> https://lists.jboss.org/mailman/listinfo/keycloak-user