[keycloak-user] Redirect Programmatically to the Loginpage

LEONARDO NUNES leo.nunes at gjccorp.com.br
Thu Jul 28 10:58:23 EDT 2016


Hi Alex,

You can redirect the user to the URL below when the login button is pressed.

Direct link to Login:
http://keycloak-domain:8080/auth/realms/your-realm-name/protocol/openid-connect/auth?client_id=your-client-id&response_mode=fragment&response_type=code&login=true&redirect_uri=http://your-application-domain.com/page-you-want-to-return

Direct link to Registration:
http://keycloak-domain:8080/auth/realms/your-realm-name/protocol/openid-connect/registrations?client_id=your-client-id&response_mode=fragment&response_type=code&redirect_uri=http://your-application-domain.com/page-you-want-to-return

You could also call request.authenticate(response), but in this case you won’t be able to specify the redirect_uri and there’s no way to indicate you want to go directly to login page or registration page.

I think we have the same situation as yours.
Some of our pages are partially visible when the user is not logged in, so we can’t protect it with url pattern.
There’s a bug when you login and get redirected to a page that it’s url is not protected.
The user session data will not be available until you navigate to a page that has the url protected.
We had to do a workaround to solve a part of the problem.
When we go to the login page our redirect_uri is a servlet that is protected, this servlet only redirects back to my page that is not protected.
There’s an issue open at: https://issues.jboss.org/browse/KEYCLOAK-2784

Please let me know if this solved your problem, or if you found a better solution.



--
Leonardo Nunes




On 27/07/16 07:56, "keycloak-user-bounces at lists.jboss.org<mailto:keycloak-user-bounces at lists.jboss.org> on behalf of Bruno Oliveira" <keycloak-user-bounces at lists.jboss.org<mailto:keycloak-user-bounces at lists.jboss.org> on behalf of bruno at abstractj.org<mailto:bruno at abstractj.org>> wrote:

Hi Alex, please take a look a the examples here[1].

[1] - https://github.com/redhat-developer/redhat-sso-quickstarts

On 2016-07-26, Alex Fernandes wrote:
Hi,

Im green to KeyCloak; Wanted to thank the community for it, so far looking
great.

I have an issue where I want to redirect the user the loginpage on the
KeyCloak server programmatically in Java;

the UseCase is:

We have a page that is partially visible and partiallly not (when not
logged in), so I can't protect it with url pattern;

We have a login button on that page that when the user is not logged and
pressed the button, we want to redirect to the loginpage (on keycloak) and
back to the page again.

I'm using the KeyCloak adapter core (running on tomcat8)

[image: Inline afbeelding 2]


I coppied this code from the: KeycloakOIDCFilter (
https://github.com/keycloak/keycloak/blob/master/adapters/oidc/servlet-filter/src/main/java/org/keycloak/adapters/servlet/KeycloakOIDCFilter.java
)

it does show a 302 in the logs but the page doesn't redirect;

Anyone has a clue about how to go about this?

Much Appreciated,
Cheers!

Alex



_______________________________________________
keycloak-user mailing list
keycloak-user at lists.jboss.org<mailto:keycloak-user at lists.jboss.org>
https://lists.jboss.org/mailman/listinfo/keycloak-user


--

abstractj
PGP: 0x84DC9914
_______________________________________________
keycloak-user mailing list
keycloak-user at lists.jboss.org<mailto:keycloak-user at lists.jboss.org>
https://lists.jboss.org/mailman/listinfo/keycloak-user
________________________________
Esta mensagem pode conter informação confidencial e/ou privilegiada. Se você não for o destinatário ou a pessoa autorizada a receber esta mensagem, não poderá usar, copiar ou divulgar as informações nela contidas ou tomar qualquer ação baseada nessas informações. Se você recebeu esta mensagem por engano, por favor avise imediatamente o remetente, respondendo o e-mail e em seguida apague-o. Agradecemos sua cooperação.

This message may contain confidential and/or privileged information. If you are not the addressee or authorized to receive this for the addressee, you must not use, copy, disclose or take any action based on this message or any information herein. If you have received this message in error, please advise the sender immediately by reply e-mail and delete this message. Thank you for your cooperation

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/keycloak-user/attachments/20160728/827c221f/attachment-0001.html 


More information about the keycloak-user mailing list