<div dir="ltr">with regard to protection on post, then what is the point of having the link on our application if the user cannot use the self serve functionality by changing their account details themselves? We would need this to be seamless for the end user right?<div><br></div><div>To protect the post in use cases such as what you described, shouldn&#39;t we just check the referrer in the request with the permitted redirect_url&#39;s for the application and then allow post based on that?</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Oct 10, 2014 at 6:13 PM, Stian Thorgersen <span dir="ltr">&lt;<a href="mailto:stian@redhat.com" target="_blank">stian@redhat.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class=""><br>
<br>
----- Original Message -----<br>
&gt; From: &quot;Travis De Silva&quot; &lt;<a href="mailto:traviskds@gmail.com">traviskds@gmail.com</a>&gt;<br>
&gt; To: &quot;Stian Thorgersen&quot; &lt;<a href="mailto:stian@redhat.com">stian@redhat.com</a>&gt;<br>
</span><span class="">&gt; Cc: &quot;Rodrigo Sasaki&quot; &lt;<a href="mailto:rodrigopsasaki@gmail.com">rodrigopsasaki@gmail.com</a>&gt;, <a href="mailto:keycloak-user@lists.jboss.org">keycloak-user@lists.jboss.org</a><br>
&gt; Sent: Friday, 10 October, 2014 5:20:54 AM<br>
&gt; Subject: Re: [keycloak-user] Link to Account Page<br>
&gt;<br>
</span><span class="">&gt; How I handle this issue is by having KeyCloak behind my Apache Reverse<br>
&gt; proxy. That way, the domain and port of my application and keycloak both<br>
&gt; are the same so there is no issue.<br>
<br>
</span>That works, but there shouldn&#39;t be a requirement that Keycloak is on the same domain as your application.<br>
<span class=""><br>
&gt;<br>
&gt; Also not sure why you want to prevent a post because won&#39;t you have a use<br>
&gt; case why an end user can go into the account page that is linked from an<br>
&gt; application and change their info such as their credentials. I would assume<br>
&gt; that is a post action on the keycloak account forms.<br>
<br>
</span>If there&#39;s no protection on post, then an external page can create a link that when clicked will change your account (if you&#39;re logged-in that is). For example to change your email address so they can then hijack your account.<br>
<div class="HOEnZb"><div class="h5"><br>
&gt;<br>
&gt; On Fri, Oct 10, 2014 at 1:07 AM, Stian Thorgersen &lt;<a href="mailto:stian@redhat.com">stian@redhat.com</a>&gt; wrote:<br>
&gt;<br>
&gt; &gt; I reckon request.getHttpMethod should be what&#39;s needed<br>
&gt; &gt;<br>
&gt; &gt; ----- Original Message -----<br>
&gt; &gt; &gt; From: &quot;Rodrigo Sasaki&quot; &lt;<a href="mailto:rodrigopsasaki@gmail.com">rodrigopsasaki@gmail.com</a>&gt;<br>
&gt; &gt; &gt; To: &quot;Stian Thorgersen&quot; &lt;<a href="mailto:stian@redhat.com">stian@redhat.com</a>&gt;<br>
&gt; &gt; &gt; Cc: <a href="mailto:keycloak-user@lists.jboss.org">keycloak-user@lists.jboss.org</a><br>
&gt; &gt; &gt; Sent: Thursday, 9 October, 2014 3:54:07 PM<br>
&gt; &gt; &gt; Subject: Re: [keycloak-user] Link to Account Page<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; JIRA created: <a href="https://issues.jboss.org/browse/KEYCLOAK-746" target="_blank">https://issues.jboss.org/browse/KEYCLOAK-746</a><br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; Just out of curiosity, how would that be fixed? A simple test on<br>
&gt; &gt; &gt; request.getHttpMethod? or with something a little more complex?<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; On Thu, Oct 9, 2014 at 10:33 AM, Stian Thorgersen &lt;<a href="mailto:stian@redhat.com">stian@redhat.com</a>&gt;<br>
&gt; &gt; wrote:<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt; That&#39;s a bug, it should only be checking that if it&#39;s a post. Can you<br>
&gt; &gt; &gt; &gt; create a jira please?<br>
&gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt; ----- Original Message -----<br>
&gt; &gt; &gt; &gt; &gt; From: &quot;Rodrigo Sasaki&quot; &lt;<a href="mailto:rodrigopsasaki@gmail.com">rodrigopsasaki@gmail.com</a>&gt;<br>
&gt; &gt; &gt; &gt; &gt; To: &quot;Stian Thorgersen&quot; &lt;<a href="mailto:stian@redhat.com">stian@redhat.com</a>&gt;<br>
&gt; &gt; &gt; &gt; &gt; Cc: <a href="mailto:keycloak-user@lists.jboss.org">keycloak-user@lists.jboss.org</a><br>
&gt; &gt; &gt; &gt; &gt; Sent: Thursday, 9 October, 2014 3:27:12 PM<br>
&gt; &gt; &gt; &gt; &gt; Subject: Re: [keycloak-user] Link to Account Page<br>
&gt; &gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt; &gt; When I invoke that URL it calles the init() method, inside<br>
&gt; &gt; &gt; &gt; &gt; AccountService.java and inside that method there is this<br>
&gt; &gt; verification:<br>
&gt; &gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt; &gt; String referrer = headers.getRequestHeaders().getFirst(&quot;Referer&quot;);<br>
&gt; &gt; &gt; &gt; &gt; if (referrer != null &amp;&amp;<br>
&gt; &gt; &gt; &gt; &gt; !requestOrigin.equals(UriUtils.getOrigin(referrer))) {<br>
&gt; &gt; &gt; &gt; &gt;     throw new ForbiddenException();<br>
&gt; &gt; &gt; &gt; &gt; }<br>
&gt; &gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt; &gt; the referrer is from our server, but the requestOrigin points to the<br>
&gt; &gt; &gt; &gt; &gt; keycloak server, so they never match<br>
&gt; &gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt; &gt; On Thu, Oct 9, 2014 at 5:45 AM, Stian Thorgersen &lt;<a href="mailto:stian@redhat.com">stian@redhat.com</a>&gt;<br>
&gt; &gt; &gt; &gt; wrote:<br>
&gt; &gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt; &gt; &gt; You can link to the account page with the following link:<br>
&gt; &gt; &gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt; &gt; &gt;   https://&lt;KEYCLOAK SERVER&gt;/auth/realms/&lt;REALM NAME&gt;/account<br>
&gt; &gt; &gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt; &gt; &gt; You can also have an option to get a link back to your application<br>
&gt; &gt; by<br>
&gt; &gt; &gt; &gt; &gt; &gt; adding either referrer or referrer_uri query param:<br>
&gt; &gt; &gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt; &gt; &gt; * referrer - your applications id (this requires &quot;Default Redirect<br>
&gt; &gt; &gt; &gt; URL&quot; to<br>
&gt; &gt; &gt; &gt; &gt; &gt; be set for your application)<br>
&gt; &gt; &gt; &gt; &gt; &gt; * referrer_uri - the uri to return to (this requires referrer_uri<br>
&gt; &gt; to<br>
&gt; &gt; &gt; &gt; be a<br>
&gt; &gt; &gt; &gt; &gt; &gt; valid redirect uri for your application)<br>
&gt; &gt; &gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt; &gt; &gt; We do this in the admin console, so you can look at how it works<br>
&gt; &gt; there.<br>
&gt; &gt; &gt; &gt; &gt; &gt; Login to the admin console, click on your username in the top-right<br>
&gt; &gt; &gt; &gt; corner,<br>
&gt; &gt; &gt; &gt; &gt; &gt; and click on &#39;Manage account&#39;. In the account management there&#39;s<br>
&gt; &gt; now<br>
&gt; &gt; &gt; &gt; in the<br>
&gt; &gt; &gt; &gt; &gt; &gt; top-right corner &#39;Back to security-admin-console&#39;. If you try edit<br>
&gt; &gt; the<br>
&gt; &gt; &gt; &gt; url<br>
&gt; &gt; &gt; &gt; &gt; &gt; to remove &#39;?referrer=security-admin-console&#39; you&#39;ll see this link<br>
&gt; &gt; is no<br>
&gt; &gt; &gt; &gt; &gt; &gt; longer there.<br>
&gt; &gt; &gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt; &gt; &gt; I&#39;ve got no idea what validation you&#39;re talking about that that<br>
&gt; &gt; checks<br>
&gt; &gt; &gt; &gt; the<br>
&gt; &gt; &gt; &gt; &gt; &gt; referrer is the same as the server. Maybe it&#39;s the fact that for an<br>
&gt; &gt; &gt; &gt; update<br>
&gt; &gt; &gt; &gt; &gt; &gt; (post) we only allow a post originating from the Keycloak server?<br>
&gt; &gt; That<br>
&gt; &gt; &gt; &gt; &gt; &gt; doesn&#39;t stop you from linking to the account page, but it stops you<br>
&gt; &gt; &gt; &gt; from<br>
&gt; &gt; &gt; &gt; &gt; &gt; posting to it.<br>
&gt; &gt; &gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt; &gt; &gt; ----- Original Message -----<br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt; From: &quot;Rodrigo Sasaki&quot; &lt;<a href="mailto:rodrigopsasaki@gmail.com">rodrigopsasaki@gmail.com</a>&gt;<br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt; To: <a href="mailto:keycloak-user@lists.jboss.org">keycloak-user@lists.jboss.org</a><br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt; Sent: Wednesday, 8 October, 2014 11:29:17 PM<br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt; Subject: [keycloak-user] Link to Account Page<br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt; Hello,<br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt; I am trying to create a link on our application to go directly to<br>
&gt; &gt; &gt; &gt; &gt; &gt; Keycloak&#39;s<br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt; Account Page, so the user can alter his information, but it<br>
&gt; &gt; doesn&#39;t<br>
&gt; &gt; &gt; &gt; work.<br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt; I saw that there is a validation that assures that the referrer<br>
&gt; &gt; is<br>
&gt; &gt; &gt; &gt; the<br>
&gt; &gt; &gt; &gt; &gt; &gt; same<br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt; as the server, for example: I can only access the account app<br>
&gt; &gt; inside<br>
&gt; &gt; &gt; &gt; my<br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt; localhost:8080 if the referrer is also in localhost:8080.<br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt; Is it supposed to be like this? Is there a way for me to create a<br>
&gt; &gt; &gt; &gt; &gt; &gt; hyperlink<br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt; from my application directly to Keycloak&#39;s Account Page? Given<br>
&gt; &gt; that<br>
&gt; &gt; &gt; &gt; my<br>
&gt; &gt; &gt; &gt; &gt; &gt; own<br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt; application is secured by Keycloak, I think it should be<br>
&gt; &gt; possible.<br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt; Is this the correct behavior?<br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt; Thanks again!<br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt; --<br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt; Rodrigo Sasaki<br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt; _______________________________________________<br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt; keycloak-user mailing list<br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt; <a href="mailto:keycloak-user@lists.jboss.org">keycloak-user@lists.jboss.org</a><br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt; <a href="https://lists.jboss.org/mailman/listinfo/keycloak-user" target="_blank">https://lists.jboss.org/mailman/listinfo/keycloak-user</a><br>
&gt; &gt; &gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt; &gt; --<br>
&gt; &gt; &gt; &gt; &gt; Rodrigo Sasaki<br>
&gt; &gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; --<br>
&gt; &gt; &gt; Rodrigo Sasaki<br>
&gt; &gt; &gt;<br>
&gt; &gt; _______________________________________________<br>
&gt; &gt; keycloak-user mailing list<br>
&gt; &gt; <a href="mailto:keycloak-user@lists.jboss.org">keycloak-user@lists.jboss.org</a><br>
&gt; &gt; <a href="https://lists.jboss.org/mailman/listinfo/keycloak-user" target="_blank">https://lists.jboss.org/mailman/listinfo/keycloak-user</a><br>
&gt; &gt;<br>
&gt;<br>
</div></div></blockquote></div><br></div>