<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">
<div>
<div>
<div style="widows: 1; "><font face="Calibri,sans-serif">I didn't use&nbsp;</font><span style="widows: 1; "><font face="Calibri,sans-serif">HttpServletRequest.authenticate() because&nbsp;I&nbsp;didn't find a way to&nbsp;specify&nbsp;with&nbsp;I&nbsp;want to go to the Login page or to the Registration
 page directly.</font></span></div>
<div style="widows: 1; "><span style="widows: 1; "><font face="Calibri,sans-serif"><br>
</font></span></div>
<div style="color: rgb(0, 0, 0); font-family: Calibri, sans-serif; font-size: 16px; ">
<br>
</div>
<div style="color: rgb(0, 0, 0); font-family: Calibri, sans-serif; font-size: 16px; ">
<div>
<div>--&nbsp;</div>
<div>Leonardo</div>
</div>
<div><br>
</div>
</div>
</div>
</div>
<div style="color: rgb(0, 0, 0); font-family: Calibri, sans-serif; font-size: 16px; ">
<br>
</div>
<span id="OLK_SRC_BODY_SECTION" style="color: rgb(0, 0, 0); font-family: Calibri, sans-serif; font-size: 16px; ">
<div style="font-family:Calibri; font-size:11pt; text-align:left; color:black; BORDER-BOTTOM: medium none; BORDER-LEFT: medium none; PADDING-BOTTOM: 0in; PADDING-LEFT: 0in; PADDING-RIGHT: 0in; BORDER-TOP: #b5c4df 1pt solid; BORDER-RIGHT: medium none; PADDING-TOP: 3pt">
<span style="font-weight:bold">From: </span>Leonardo Nunes &lt;<a href="mailto:leo.nunes@gjccorp.com.br">leo.nunes@gjccorp.com.br</a>&gt;<br>
<span style="font-weight:bold">Date: </span>sexta-feira, 1 de abril de 2016 15:34<br>
<span style="font-weight:bold">To: </span>&quot;<a href="mailto:keycloak-user@lists.jboss.org">keycloak-user@lists.jboss.org</a>&quot; &lt;<a href="mailto:keycloak-user@lists.jboss.org">keycloak-user@lists.jboss.org</a>&gt;, &quot;<a href="mailto:bburke@redhat.com">bburke@redhat.com</a>&quot;
 &lt;<a href="mailto:bburke@redhat.com">bburke@redhat.com</a>&gt;<br>
<span style="font-weight:bold">Subject: </span>Re: req.getUserPrincipal() returns NULL before navigating to a restricted url (after login)<br>
</div>
<div><br>
</div>
<div>
<div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; color: rgb(0, 0, 0); font-size: 16px; font-family: Calibri, sans-serif; ">
<div>
<div>I'm using with Tomcat 8 Adapter and with Spring Boot Adapter.</div>
<div>On both i'm using Keycloak version 1.9.1.Final.</div>
<div><br>
</div>
<div>The Login button calls this URL:</div>
<div>
<div><a href="http://localhost:8180/auth/realms/accounts/protocol/openid-connect/auth?client_id=accounts-teste&amp;redirect_uri=http://localhost:8088/accounts-teste/&amp;response_mode=fragment&amp;response_type=code">http://localhost:8180/auth/realms/accounts/protocol/openid-connect/auth?client_id=accounts-teste&amp;redirect_uri=http://localhost:8088/accounts-teste/&amp;response_mode=fragment&amp;response_type=code</a></div>
<div><br>
</div>
<div>The Register button calls this URL:</div>
<div><a href="http://localhost:8180/auth/realms/accounts/protocol/openid-connect/registrations?client_id=accounts-teste&amp;redirect_uri=http://localhost:8088/accounts-teste/&amp;response_mode=fragment&amp;response_type=code">http://localhost:8180/auth/realms/accounts/protocol/openid-connect/registrations?client_id=accounts-teste&amp;redirect_uri=http://localhost:8088/accounts-teste/&amp;response_mode=fragment&amp;response_type=code</a></div>
</div>
<div><br>
</div>
<div><br>
</div>
<div><br>
</div>
<div>
<div>
<div>--&nbsp;</div>
<div>Leonardo</div>
</div>
</div>
</div>
</div>
</div>
</span>
<div><br>
</div>
<span id="OLK_SRC_BODY_SECTION" style="color: rgb(0, 0, 0); font-family: Calibri, sans-serif; font-size: 16px; ">
<div>
<div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; color: rgb(0, 0, 0); font-size: 16px; font-family: Calibri, sans-serif; ">
<div><br>
</div>
<span id="OLK_SRC_BODY_SECTION">
<div style="font-family:Calibri; font-size:11pt; text-align:left; color:black; BORDER-BOTTOM: medium none; BORDER-LEFT: medium none; PADDING-BOTTOM: 0in; PADDING-LEFT: 0in; PADDING-RIGHT: 0in; BORDER-TOP: #b5c4df 1pt solid; BORDER-RIGHT: medium none; PADDING-TOP: 3pt">
<span style="font-weight:bold">From: </span>Leonardo Nunes &lt;<a href="mailto:leo.nunes@gjccorp.com.br">leo.nunes@gjccorp.com.br</a>&gt;<br>
<span style="font-weight:bold">Date: </span>quinta-feira, 31 de março de 2016 18:01<br>
<span style="font-weight:bold">To: </span>&quot;<a href="mailto:keycloak-user@lists.jboss.org">keycloak-user@lists.jboss.org</a>&quot; &lt;<a href="mailto:keycloak-user@lists.jboss.org">keycloak-user@lists.jboss.org</a>&gt;<br>
<span style="font-weight:bold">Subject: </span>req.getUserPrincipal() returns NULL before navigating to a restricted url (after login)<br>
</div>
<div><br>
</div>
<div>
<div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; color: rgb(0, 0, 0); font-size: 16px; font-family: Calibri, sans-serif; ">
<div>Hi everyone,</div>
<div><br>
</div>
<div>I have a page1 that it's access is not restricted, at the page1 I have a Login button that directs to Keycloak and the redirect_uri is the page1.</div>
<div>After I login and get redirect to page1, I try to access the logged in user information with&nbsp;req.getUserPrincipal() but this method returns NULL at this moment.</div>
<div>If I navigate to a page that it's url is restricted and then return to the non-restricted page, then&nbsp;req.getUserPrincipal() returns the user object.</div>
<div><br>
</div>
<div>I noticed that I have to go to a restricted page before being able to access the user information at a non-restricted page.</div>
<div><br>
</div>
<div>The ticket below solved the problem of not accessing the user information at a non-restricted page, but still have this case when the user logged in at non-restricted page.</div>
<div><a href="https://issues.jboss.org/browse/KEYCLOAK-2518">https://issues.jboss.org/browse/KEYCLOAK-2518</a></div>
<div><br>
</div>
<div><br>
</div>
<div><br>
</div>
<div>
<div>
<div>--&nbsp;</div>
</div>
</div>
<div>Leonardo</div>
</div>
</div>
</span></div>
</div>
</span>
<hr style="height:1px;color:#C4C4C4;">
<div style="font-family:Arial;color:#848484;font-size:11px;"><i>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.
<br>
<br>
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<i></div>
</i></i>
</body>
</html>