<div dir="ltr">Hello,<div><br></div><div>any ideas regarding this?<div><br></div><div>We need to link to a default application from several applications and it would be helpful if keycloak would provide said redirect mechanism, such that</div><div>each application would only need to know the clientId of the default client application and keycloak performs the proper redirect to the actual target application.</div><div><br></div><div>The example posted earlier works like a charm. This could even be extended to the point that in case no clientId is given keycloak can decide which client to redirect to.</div><div><br></div><div>Cheers,</div><div>Thomas</div></div></div><div class="gmail_extra"><br><div class="gmail_quote">2016-02-05 19:05 GMT+01:00 Thomas Darimont <span dir="ltr"><<a href="mailto:thomas.darimont@googlemail.com" target="_blank">thomas.darimont@googlemail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>Quick update - I did some further experiments with this...</div><div><br></div><div>I added /redirect path to the a org.keycloak.services.resources.RealmsResource</div><div>like: @Path("{realm}/{client-id}/redirect")</div><div>see code fragment below.</div><div><br></div><div>This allows keycloak to initiate a redirect to the browser with the actual</div><div>target url of the client. Other clients now only need to now the realm and clientId</div><div>to generate a link that eventually redirects to the target application.</div><div><br></div><div>Usage:</div><div>GET <a href="http://localhost:8081/auth/realms/master/launchpad/redirect" target="_blank">http://localhost:8081/auth/realms/master/launchpad/redirect</a> -> 302 response with location: <a href="http://apps.corp.local/launchpad" target="_blank">http://apps.corp.local/launchpad</a></div><div><br></div><div>Any chance to get this in as a PR?</div><div><br></div><div>Cheers,</div><div>Thomas</div><div><br></div><div> @GET</div><div> @Path("{realm}/{client-id}/redirect")</div><div> public Response getRedirect(final @PathParam("realm") String realmName, final @PathParam("client-id") String clientId) throws Exception{</div><div><br></div><div> RealmModel realm = init(realmName);</div><div><br></div><div> if (realm == null){</div><div> return null;</div><div> }</div><div><br></div><div> ClientModel client = realm.getClientByClientId(clientId);</div><div><br></div><div> if (client == null){</div><div> return null;</div><div> }</div><div><br></div><div> if (client.getRootUrl() == null){</div><div> return Response.temporaryRedirect(uriInfo.getAbsolutePathBuilder().replacePath(client.getBaseUrl()).build()).build();</div><div> }</div><div><br></div><div> return Response.temporaryRedirect(URI.create(client.getRootUrl() + client.getBaseUrl())).build();</div><div> }</div></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">2016-02-05 16:23 GMT+01:00 Thomas Darimont <span dir="ltr"><<a href="mailto:thomas.darimont@googlemail.com" target="_blank">thomas.darimont@googlemail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra">Hello,</div><div class="gmail_extra"><br><div class="gmail_quote"><span>2016-02-05 15:22 GMT+01:00 Thomas Raehalme <span dir="ltr"><<a href="mailto:thomas.raehalme@aitiofinland.com" target="_blank">thomas.raehalme@aitiofinland.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">I understand this as well, but it has not been uncommon to encounter a situation where the user needs to know where to go next, because Keycloak doesn't have a link available. </blockquote><div><br></div></span><div>with a redirect facility as outlined above - one could render a link to the "$KEYCLOAK_BASE_URL/redirect" or </div><div>lookup the "default" client in order to render the client base url link with a proper label (client name).</div><div><br></div><div>Cheers,</div><div>Thomas </div></div><br><br></div></div>
</blockquote></div><br></div>
</div></div></blockquote></div><br></div>