<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On 28 April 2016 at 17:53, Aikeaguinea <span dir="ltr">&lt;<a href="mailto:aikeaguinea@xsmail.com" target="_blank">aikeaguinea@xsmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><u></u>




<div><div>We have something of a special case. We have privileged devices for which we will use service accounts and certificates/JWT based authentication.<br></div>
<div> </div>
<div>Then we will have a user (employee of ours) perform a second log in to the application running on the device. The particulars don&#39;t allow us to use a browser in this instance. (For one thing, the user&#39;s credentials are not a username/password -- I&#39;ve had to create a special authenticator for this purpose. But this isn&#39;t the only reason.) So, to Brian&#39;s question, we are not embedding these credentials in our code.<br></div></div></blockquote><div><br></div><div>That would normally be an argument for using a browser. Using an embedded browser allows you to enable different authentication modes in Keycloak without modifying your applications. Keycloak has built-in support for authentication Kerberos tickets for example, all without the applications knowledge. </div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div><div></div>
<div> </div>
<div>Since the device is trusted, we could use the password credentials grant. However, since this is a fairly high-security situation we&#39;d prefer not to be sending access tokens over the wire, particularly if we&#39;re only relying on TLS for encrypting the token.<br></div></div></blockquote><div><br></div><div>If you&#39;re not sending access tokens over the wire, what are you sending over the wire? That&#39;s how Keycloak works and an access token is always going to be sent over the wire. Doesn&#39;t matter what flow you use. You can choose exactly what goes into the token though.</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div><div></div>
<div> </div>
<div>We could, on the other hand, use the authorization code flow--I&#39;d just have to follow the redirects and dig the form action out of the form that&#39;s returned in the challenge page. I was just wondering if there was some way to access that URL other than by chomping on the HTML, e.g., by using a different &quot;Accept:&quot; header.<br></div></div></blockquote><div><br></div><div>The authorization code flows is by design a purely browser flow. Using this outside of the browser isn&#39;t the correct approach. The direct access grant (resource owner credentials) is the flow you want to use if you&#39;re not going to use a browser.</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div><div></div><div><div class="h5">
<div> </div>
<div> </div>
<div>On Thu, Apr 28, 2016, at 12:58 AM, Stian Thorgersen wrote:<br></div>
<blockquote type="cite"><div dir="ltr"><div>The answer depends on what your code is doing:<br></div>
<div> </div>
<div>a) Is it a server not invoking services on behalf of users, but rather on behalf of itself? Then use service accounts and you can also use public/private key based auth here (client credential flow from oauth2).<br></div>
<div>b) Is it a user logging in through a non-browser based application? Then the ideal option if possible is to embed a web browser and use the authorization code flow. The alternative is to use direct grant (resource owner credential grant flow from oauth2).<br></div>
<div>c) Is it a background process invoking a service on behalf of users when the users are not online? Then use offline tokens.<br></div>
</div>
<div><div> </div>
<div><div>On 27 April 2016 at 17:17, Aikeaguinea <span dir="ltr">&lt;<a href="mailto:aikeaguinea@xsmail.com" target="_blank">aikeaguinea@xsmail.com</a>&gt;</span> wrote:<br></div>
<blockquote style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div>As I understand it, using the authorization code flow rather than the<br></div>
<div> implicit flow is recommended where possible.<br></div>
<div> </div>
<div> We have a server-side client application, but the user agents making<br></div>
<div> requests are not browsers, but instead our own code.<br></div>
<div> </div>
<div> I&#39;m not entirely sure how to make the authorization code flow work<br></div>
<div> without a browser. For instance, if on the command line I request<br></div>
<div> </div>
<div> curl<br></div>
<div> &#39;http://host:port/auth/realms/foo/protocol/openid-connect/auth?response_type=code&amp;client_id=test-client&amp;state=state&amp;redirect_uri=<a href="http://www.example.com/hello-world" target="_blank">http://www.example.com/hello-world</a>&#39;<br></div>
<div> </div>
<div> Then (assuming the parameters are correct) I get back an HTML login page<br></div>
<div> with a form. In order to submit the credentials, I would need to dig the<br></div>
<div> URL out of the action of the form and then submit a request like<br></div>
<div> </div>
<div> curl -X POST -d &#39;username=test-user&#39; -d &#39;password=test1234&#39;<br></div>
<div> &#39;http://host:port/auth/realms/foo/login-actions/authenticate?code=Ctr79aRsbwPPkC4nEeT2vR9-TuC31uuXngQXoHQH6FE.ef26cfcd-a35b-4d1e-a4f7-49790f6e2f00&amp;execution=a86f56da-9900-4f1d-a461-f18617a2333b&#39;<br></div>
<div> </div>
<div> Three questions:<br></div>
<div> 1. Is there some reason I shouldn&#39;t be trying to implement the<br></div>
<div> authorization code flow like this?<br></div>
<div> </div>
<div> 2. Is there a way to get the proper login action back without having to<br></div>
<div> dig it out of an HTML form? I&#39;ve tried adding --header &quot;Accept:<br></div>
<div> application/json&quot; to the command but this has no effect.<br></div>
<div> </div>
<div> 3. Is there a way of submitting credentials other than by using form<br></div>
<div> parameters? I&#39;ve tried HTTP basic auth but it doesn&#39;t work for me.<br></div>
<div> <span><span style="color:rgb(136,136,136)"><br> --<br> Aikeaguinea<br> <a href="mailto:aikeaguinea@xsmail.com" target="_blank">aikeaguinea@xsmail.com</a><br> <br> --<br> <a href="http://www.fastmail.com" target="_blank">http://www.fastmail.com</a> - Same, same, but different...<br> <br> _______________________________________________<br> keycloak-user mailing list<br> <a href="mailto:keycloak-user@lists.jboss.org" target="_blank">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></span></span></div>
</blockquote></div>
</div>
</blockquote><div> </div>
<div><div>--<br></div>
<div>  Aikeaguinea<br></div>
<div>  <a href="mailto:aikeaguinea@xsmail.com" target="_blank">aikeaguinea@xsmail.com</a><br></div>
<div> </div>
</div>
<div> </div>
<pre>-- 
<a href="http://www.fastmail.com" target="_blank">http://www.fastmail.com</a> - Same, same, but different...
</pre>
</div></div></div>

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