<div dir="ltr">Hi Stian and Bill,<div><br></div><div>thanks for your replies! I&#39;ll check out the blog post and try the approach with a web.xml and a keycloak.json in the backend for now. I&#39;ll keep you posted on what I end up with on the client side.</div>
<div><br></div><div>Cheers,</div><div>Nils</div><div><br></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, Mar 27, 2014 at 5:18 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">Personally, I think that in most cases for a client-side web app the best approach is to let the client-side do the oauth flow (the approach we&#39;re currently taking in keycloak.js). It does depend on your application though, and if you&#39;re application has a strict one html5 app calls one REST service then http-only cookies are an option. I don&#39;t see any real benefits of it though, and I believe it significantly complicates things.<br>

<br>
Have a look at <a href="http://blog.auth0.com/2014/01/07/angularjs-authentication-with-cookies-vs-token/" target="_blank">http://blog.auth0.com/2014/01/07/angularjs-authentication-with-cookies-vs-token/</a>, I think it provides a good summary of the pros of the token approach.<br>

<div class="HOEnZb"><div class="h5"><br>
----- Original Message -----<br>
&gt; From: &quot;Bill Burke&quot; &lt;<a href="mailto:bburke@redhat.com">bburke@redhat.com</a>&gt;<br>
&gt; To: <a href="mailto:keycloak-user@lists.jboss.org">keycloak-user@lists.jboss.org</a><br>
&gt; Sent: Thursday, 27 March, 2014 3:39:07 PM<br>
&gt; Subject: Re: [keycloak-user] Keycloak and AngularJS<br>
&gt;<br>
&gt; What I like about the current admin console approach is that there is no<br>
&gt; book keeping required by the browser.  The Angular app has really no<br>
&gt; knowledge of how it is being secured as its all driven by the server.<br>
&gt; Also, you need to remember that the admin console was designed to be run<br>
&gt; in a non-Java EE, non-servlet environment.  While this is a requirement<br>
&gt; for Keycloak, it may not be for your application.  So, what I&#39;m saying<br>
&gt; is that for your angular application, you could rely on the servlet<br>
&gt; container and keycloak adapter to maintain a session cookie and identity.<br>
&gt;<br>
&gt; What I like about the keycloak.js approach is that there is no<br>
&gt; server-side adapter required for the UI.  The UI could be hosted off any<br>
&gt; number of static web sites and use CORS invocations to any number of<br>
&gt; Restful services.<br>
&gt;<br>
&gt; There&#39;s also the debate of public vs. confidential clients.  The<br>
&gt; keycloak.js approach requires a public client.  My understanding was<br>
&gt; that confidential clients exist so that only an authenticated client<br>
&gt; (client *NOT* user) is able to obtain an access token.  I&#39;m not exactly<br>
&gt; sure what additional security benefits are obtained here beyond this.<br>
&gt; I&#39;ve been trying to ask this very question on OAuth mail lists but have<br>
&gt; been unable to get a response so far.<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; On 3/27/2014 10:41 AM, Nils Preusker wrote:<br>
&gt; &gt; Hi Stian and Bill,<br>
&gt; &gt;<br>
&gt; &gt; I&#39;ve posted some questions regarding this topic before but I thought I&#39;d<br>
&gt; &gt; start a new thread to keep things focused:<br>
&gt; &gt;<br>
&gt; &gt; I&#39;m writing an AngularJS application with Java EE 6/7 REST (JAX-RS)<br>
&gt; &gt; backend modules. To add authentication and authorization to this<br>
&gt; &gt; application, I&#39;d like to use keycloak<br>
&gt; &gt;<br>
&gt; &gt; * as a user and role management front-end<br>
&gt; &gt; * to provide a customizable login page (works very well by the way ;)<br>
&gt; &gt; * as an OAuth 2.0 token provider<br>
&gt; &gt; * to add user and role information to the HTTPRequests in my REST/<br>
&gt; &gt; backend modules<br>
&gt; &gt;<br>
&gt; &gt; To do this, I&#39;m currently looking at keycloak.js and the customer-app-js<br>
&gt; &gt; example. However, I&#39;m wondering whether this is really the best way to<br>
&gt; &gt; go. In a reply to an earlier post of mine you mentioned that the<br>
&gt; &gt; keycloak admin console is written in AngularJS and that you are using<br>
&gt; &gt; HTTP-only cookies there.<br>
&gt; &gt;<br>
&gt; &gt; However, in keycloak.js and the customer-app-js example you are<br>
&gt; &gt; retrieving the token in the JS app and adding an authorization header<br>
&gt; &gt; with a bearer token to the HTTP requests.<br>
&gt; &gt;<br>
&gt; &gt; So here are my questions:<br>
&gt; &gt;<br>
&gt; &gt; * Is there a reason you are using two different approaches in the admin<br>
&gt; &gt; console and the official demo app?<br>
&gt; &gt; * which one of the two approaches (bearer tokens vs. HTTP-only cookie)<br>
&gt; &gt; will you support/ will be the officially recommended one for HTML5/<br>
&gt; &gt; client side JavaScript applications in keycloak?<br>
&gt; &gt; * am I right in assuming that you haven&#39;t quite decided yet which<br>
&gt; &gt; approach to use and that you are still discussing this in the keycloak<br>
&gt; &gt; team?<br>
&gt; &gt;<br>
&gt; &gt; Looking forwards to your reply!<br>
&gt; &gt; Cheers,<br>
&gt; &gt; Nils<br>
&gt; &gt;<br>
&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>
&gt; --<br>
&gt; Bill Burke<br>
&gt; JBoss, a division of Red Hat<br>
&gt; <a href="http://bill.burkecentral.com" target="_blank">http://bill.burkecentral.com</a><br>
&gt; _______________________________________________<br>
&gt; keycloak-user mailing list<br>
&gt; <a href="mailto:keycloak-user@lists.jboss.org">keycloak-user@lists.jboss.org</a><br>
&gt; <a href="https://lists.jboss.org/mailman/listinfo/keycloak-user" target="_blank">https://lists.jboss.org/mailman/listinfo/keycloak-user</a><br>
&gt;<br>
_______________________________________________<br>
keycloak-user mailing list<br>
<a href="mailto:keycloak-user@lists.jboss.org">keycloak-user@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/keycloak-user" target="_blank">https://lists.jboss.org/mailman/listinfo/keycloak-user</a><br>
</div></div></blockquote></div><br></div>