Quick update - I did some further experiments with this...
I added /redirect path to the a org.keycloak.services.resources.RealmsResource
like: @Path("{realm}/{client-id}/redirect")
see code fragment below.
This allows keycloak to initiate a redirect to the browser with the actual
target url of the client. Other clients now only need to now the realm and clientId
to generate a link that eventually redirects to the target application.
Usage:
Any chance to get this in as a PR?
Cheers,
Thomas
@GET
@Path("{realm}/{client-id}/redirect")
public Response getRedirect(final @PathParam("realm") String realmName, final @PathParam("client-id") String clientId) throws Exception{
RealmModel realm = init(realmName);
if (realm == null){
return null;
}
ClientModel client = realm.getClientByClientId(clientId);
if (client == null){
return null;
}
if (client.getRootUrl() == null){
return Response.temporaryRedirect(uriInfo.getAbsolutePathBuilder().replacePath(client.getBaseUrl()).build()).build();
}
return Response.temporaryRedirect(URI.create(client.getRootUrl() + client.getBaseUrl())).build();
}