<div dir="ltr"><div><div>I&#39;m  almost sure it is looping because of the automatic boostrap, looks at this demo app that has pretty much the some flow as your app <a href="https://github.com/jamesfalkner/coolstore-microservice/">https://github.com/jamesfalkner/coolstore-microservice/</a> and particulary this section <a href="https://github.com/jamesfalkner/coolstore-microservice/blob/master/coolstore-ui/app/app.js#L30-L47">https://github.com/jamesfalkner/coolstore-microservice/blob/master/coolstore-ui/app/app.js#L30-L47</a> <br><br></div>That could give you some ideas.<br><br></div>Sebi<br><br></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Sep 26, 2016 at 8:13 AM, Maurício Giacomini Penteado <span dir="ltr">&lt;<a href="mailto:mauriciogiacomini@hotmail.com" target="_blank">mauriciogiacomini@hotmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">




<div dir="ltr">
<div style="font-size:12pt;color:#000000;font-family:Calibri,Arial,Helvetica,sans-serif">
<p></p>
<div>Hi Sebastian</div>
<div><br>
</div>
<div>I did a code very similar of photoz sample.</div>
<div>On my &quot;index.html&quot; has the same &lt;script&gt; block from photoz sample but with onLoad: &#39;check-sso&#39; on initOptions:</div>
<div><br>
</div>
<div><span style="white-space:pre-wrap"></span>&lt;script&gt;</div>
<div><span style="white-space:pre-wrap"></span>...<span style="white-space:pre-wrap">
</span></div>
<div><span style="white-space:pre-wrap"></span>var initOptions = {</div>
<div><span style="white-space:pre-wrap"></span>onLoad: &#39;check-sso&#39;,</div>
<div><span style="white-space:pre-wrap"></span>responseMode: &#39;query&#39;,</div>
<div><span style="white-space:pre-wrap"></span>flow: &#39;standard&#39;</div>
<div><span style="white-space:pre-wrap"></span>};</div>
<div><br>
</div>
<div><span style="white-space:pre-wrap"></span>keycloak.init(initOptions).<wbr>success(function (authenticated) {</div>
<div><span style="white-space:pre-wrap"></span>output(&#39;Init Success (&#39; + (authenticated ? &#39;Authenticated&#39; : &#39;Not Authenticated&#39;) + &#39;)&#39;);</div>
<div><span style="white-space:pre-wrap"></span>}).error(function () {</div>
<div><span style="white-space:pre-wrap"></span>output(&#39;Init Error&#39;);</div>
<div><span style="white-space:pre-wrap"></span>});</div>
<div><span style="white-space:pre-wrap"></span>&lt;/script&gt;</div>
<div><span style="white-space:pre-wrap"></span></div>
<div>To pass keycloak instance for angular code I put on my &quot;app.js&quot; a provider:</div>
<div>    </div>
<div><span style="white-space:pre-wrap"></span>var app = angular.module(&#39;myApp&#39;, [])</div>
<div><span style="white-space:pre-wrap"></span>.provider(&#39;keycloak&#39;, function () {</div>
<div><span style="white-space:pre-wrap"></span>return {</div>
<div><span style="white-space:pre-wrap"></span>setKeycloak: function (value) {</div>
<div><span style="white-space:pre-wrap"></span>keycloak = value;</div>
<div><span style="white-space:pre-wrap"></span>},</div>
<div><span style="white-space:pre-wrap"></span>$get: function () {</div>
<div><span style="white-space:pre-wrap"></span>return keycloak;</div>
<div><span style="white-space:pre-wrap"></span>}</div>
<div><span style="white-space:pre-wrap"></span>};</div>
<div><span style="white-space:pre-wrap"></span>});</div>
<div><span style="white-space:pre-wrap"></span></div>
<div>Injecting keycloak on my controller I have success accessing keycloak methods like login or logout:</div>
<div><br>
</div>
<div>app.controller(&#39;MainCtrl&#39;, [&#39;$scope, &#39;&#39;keycloak&#39;, function ($scope, keycloak) {<span style="white-space:pre-wrap">
</span></div>
<div><span style="white-space:pre-wrap"></span>$scope.login = function () {</div>
<div>            keycloak.login();</div>
<div>        };</div>
<div>        $scope.logout = function () {</div>
<div>            keycloak.logout();</div>
<div>        };</div>
<div><span style="white-space:pre-wrap"></span>}</div>
<div>]);</div>
<div><br>
</div>
<div>Doing this way, I can call angular login and logout from $scope in &quot;index.html&quot; that I have all keycloak event logs reported like photoz sample:</div>
<div><br>
</div>
<div>&lt;body ng-app=&quot;myApp&quot; ng-controller=&quot;MainCtrl&quot;&gt;</div>
<div><span style="white-space:pre-wrap"></span>&lt;div&gt;</div>
<div><span style="white-space:pre-wrap"></span>&lt;button id=&quot;btnLogin&quot; ng-click=&quot;login()&quot;&gt;Login&lt;/<wbr>button&gt;</div>
<div><span style="white-space:pre-wrap"></span>&lt;button id=&quot;btnLogout&quot; ng-click=&quot;logout()&quot;&gt;Logout&lt;/<wbr>button&gt;</div>
<div><span style="white-space:pre-wrap"></span>&lt;/div&gt;</div>
<div>...</div>
<div><br>
</div>
<div>
<div>The behavior of my app is that I described on last email with an infinite loop if an authenticated user browse to <a href="http://www.exampledomain.com/someAppPath" target="_blank">www.exampledomain.com/<wbr>someAppPath</a>.</div>
<div><br>
</div>
<div>I am not doing the bootstrap of angular, perhaps it can be my problem. I not know where is the best place to do it, I will try find. </div>
</div>
<div></div>
<br>
<p></p>
Regards,
<div>Maurício.<br>
<br>
<div style="color:rgb(0,0,0)">
<hr style="display:inline-block;width:98%">
<div dir="ltr"><font style="font-size:11pt" color="#000000" face="Calibri, sans-serif"><b>De:</b> Sebastien Blanc &lt;<a href="mailto:sblanc@redhat.com" target="_blank">sblanc@redhat.com</a>&gt;<br>
<b>Enviado:</b> segunda-feira, 26 de setembro de 2016 13:57<br>
<b>Para:</b> Maurício Giacomini Penteado<br>
<b>Cc:</b> <a href="mailto:keycloak-dev@lists.jboss.org" target="_blank">keycloak-dev@lists.jboss.org</a><br>
<b>Assunto:</b> Re: [keycloak-dev] Infinite loop problem with authenticated users browsing out of root context</font>
<div> </div>
</div><div><div class="h5">
<div>Could you share some code on how you initiate keycloak and bootstrap the angular app ?<span></span><br>
<br>
Le lundi 26 septembre 2016, Maurício Giacomini Penteado &lt;<a href="mailto:mauriciogiacomini@hotmail.com" target="_blank">mauriciogiacomini@hotmail.com</a><wbr>&gt; a écrit :<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr">
<div style="font-size:12pt;color:#000000;font-family:Calibri,Arial,Helvetica,sans-serif">
<p>Hello everybody</p>
<p><br>
</p>
<p></p>
<div>I have a strange error trying codify with keycloak 2.0.0, Angular 1.5.8 and Wildfly 10. I am programming an application that follows concepts of &quot;WYSIWYG&quot;.</div>
<div>In my application I have setted keycloak to work on model &quot;check-sso&quot;.</div>
<div>All work perfectly if browsing is done with unauthenticated users on any path from my application.</div>
<div>But strangely, authenticated users just can browse on root context from my application. If any aditional path is requested with an authenticated user the app starts a infinite loop.</div>
<div><br>
</div>
<div>Example (with app running on root context &quot;/&quot;):</div>
<div><br>
</div>
<div><a href="http://www.exampledomain.com/" target="_blank">www.exampledomain.com/</a>  - &gt; Works perfectly with authenticated users or unauthenticated users. </div>
<div><br>
</div>
<div><a href="http://www.exampledomain.com/someAppPath" target="_blank">www.exampledomain.com/someAppP<wbr>ath</a><a href="http://www.exampledomain.com/someAppPath" target="_blank"></a>  - &gt; Just works with unauthenticated users. With authenticated users starts
 a infinite loop. </div>
<div><br>
</div>
<div><br>
</div>
<div>If anybody has an idea to solve this problem please, let me know.</div>
<div><br>
</div>
<div>Regards,</div>
<div>Maurício.</div>
<div><br>
</div>
<br>
<p></p>
<p><br>
</p>
<p><br>
</p>
</div>
</div>
</blockquote>
</div>
</div></div></div>
</div>
</div>
</div>

</blockquote></div><br></div>