<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"><!-- P {margin-top:0;margin-bottom:0;} --></style>
</head>
<body dir="ltr">
<div id="divtagdefaultwrapper" style="font-size:12pt;color:#000000;font-family:Calibri,Arial,Helvetica,sans-serif;">
<p></p>
<div>Thanks Sebastien!</div>
<div><br>
</div>
<div>You was right! I had a conflict with angular initialization.</div>
<div>Putting the script block in head of my &quot;index.html&quot; with a correct &quot;angular.bootstrap&quot; call and removing &quot;ng-app&quot; from my body tag all is working correctly!!&nbsp;</div>
<div><br>
</div>
<div>Kind regards,</div>
<div>Maurício.</div>
<p></p>
<br>
<div style="color: rgb(0, 0, 0);">
<hr tabindex="-1" style="display:inline-block; width:98%">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" color="#000000" style="font-size:11pt"><b>De:</b> Sebastien Blanc &lt;sblanc@redhat.com&gt;<br>
<b>Enviado:</b> segunda-feira, 26 de setembro de 2016 15:28<br>
<b>Para:</b> Maurício Giacomini Penteado<br>
<b>Cc:</b> keycloak-dev@lists.jboss.org<br>
<b>Assunto:</b> Re: [keycloak-dev] Infinite loop problem with authenticated users browsing out of root context</font>
<div>&nbsp;</div>
</div>
<div>
<div dir="ltr">
<div>
<div>I'm&nbsp; 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/" id="LPlnk150170" previewremoved="true">
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" id="LPlnk430147" previewremoved="true">
https://github.com/jamesfalkner/coolstore-microservice/blob/master/coolstore-ui/app/app.js#L30-L47</a>
<div id="LPBorder_GT_14749138286530.7565042461769149" style="margin-bottom: 20px; overflow: auto; width: 100%; text-indent: 0px;">
<table id="LPContainer_14749138286490.9947010037013388" cellspacing="0" style="width: 90%; background-color: rgb(255, 255, 255); position: relative; overflow: auto; padding-top: 20px; padding-bottom: 20px; margin-top: 20px; border-top: 1px dotted rgb(200, 200, 200); border-bottom: 1px dotted rgb(200, 200, 200);">
<tbody>
<tr valign="top" style="border-spacing: 0px;">
<td id="TextCell_14749138286520.06233184204844444" colspan="2" style="vertical-align: top; position: relative; padding: 0px; display: table-cell;">
<div id="LPRemovePreviewContainer_14749138286520.5164214657566786"></div>
<div id="LPTitle_14749138286520.144837417088286" style="top: 0px; color: rgb(0, 120, 215); font-weight: normal; font-size: 21px; font-family: wf_segoe-ui_light, &quot;Segoe UI Light&quot;, &quot;Segoe WP Light&quot;, &quot;Segoe UI&quot;, &quot;Segoe WP&quot;, Tahoma, Arial, sans-serif; line-height: 21px;">
<a id="LPUrlAnchor_14749138286520.7370784464621725" href="https://github.com/jamesfalkner/coolstore-microservice/" target="_blank" style="text-decoration: none;">jamesfalkner/coolstore-microservice</a></div>
<div id="LPMetadata_14749138286530.9255158073453211" style="margin: 10px 0px 16px; color: rgb(102, 102, 102); font-weight: normal; font-family: wf_segoe-ui_normal, &quot;Segoe UI&quot;, &quot;Segoe WP&quot;, Tahoma, Arial, sans-serif; font-size: 14px; line-height: 14px;">
github.com</div>
<div id="LPDescription_14749138286530.8672258430351816" style="display: block; color: rgb(102, 102, 102); font-weight: normal; font-family: wf_segoe-ui_normal, &quot;Segoe UI&quot;, &quot;Segoe WP&quot;, Tahoma, Arial, sans-serif; font-size: 14px; line-height: 20px; max-height: 100px; overflow: hidden;">
coolstore-microservice - This is an example demo showing a retail store consisting of a trio of microservices based on JBoss EAP 7 and Node.js, deployed to OpenShift and protected with Red Hat SSO.</div>
</td>
</tr>
</tbody>
</table>
</div>
<br>
<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: 'check-sso' 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: 'check-sso',</div>
<div><span style="white-space:pre-wrap"></span>responseMode: 'query',</div>
<div><span style="white-space:pre-wrap"></span>flow: 'standard'</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('Init Success (' &#43; (authenticated ? 'Authenticated' : 'Not Authenticated') &#43; ')');</div>
<div><span style="white-space:pre-wrap"></span>}).error(function () {</div>
<div><span style="white-space:pre-wrap"></span>output('Init Error');</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>&nbsp; &nbsp;&nbsp;</div>
<div><span style="white-space:pre-wrap"></span>var app = angular.module('myApp', [])</div>
<div><span style="white-space:pre-wrap"></span>.provider('keycloak', 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('MainCtrl', ['$scope, ''keycloak', function ($scope, keycloak) {<span style="white-space:pre-wrap">
</span></div>
<div><span style="white-space:pre-wrap"></span>$scope.login = function () {</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; keycloak.login();</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; };</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; $scope.logout = function () {</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; keycloak.logout();</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; };</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.&nbsp;</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 color="#000000" face="Calibri, sans-serif" style="font-size:11pt"><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>&nbsp;</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&nbsp;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&nbsp;:<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> &nbsp;- &gt; Works perfectly with authenticated users or unauthenticated users.&nbsp;</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>&nbsp; - &gt; Just works with unauthenticated users. With authenticated users starts
 a infinite loop.&nbsp;</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>
</div>
</div>
</div>
</body>
</html>