Hey Bill, thanks for the clarification, I didn't realize that the cookie was Http-only, neat!

We are building a pure HTML5 client that is also hosted separately from the REST-backends. The thing is that we use a reverse proxy so for the browser it all looks like one app since everything comes from different paths in the same domain.

I'll try to clarify the last part of my last mail: We are currently using org.jboss.resteasy.skeleton.key.as7.OAuthAuthenticationServerValve (skeleton-key-as7) in our REST-backend modules. If I'm not mistaken, some parts of the code base and concepts are the same as in keycloak, right?

So far, in the AngularJS application we've been adding bearer tokens to the HTTP Authorization header. Since the backend uses JAX-RS/ RestEasy, the verification of the bearer tokens was done transparently by OAuthAuthenticationServerValve and RESTEasy automatically added the roles etc. to the HttpServletRequest. Now in the REST backend of the admin app in keycloak you're doing the same thing (validating the tokens and extracting the roles) manually with the AuthenticationManager (authenticateSaasIdentityCookie(...)). So I was just wondering whether you are planning to make that process more transparent in the future?

I think it would be nice to be able to write REST services with @RolesAllowed etc.

Does that make more sense?

Cheers!
Nils


On Thu, Jan 30, 2014 at 2:30 PM, Bill Burke <bburke@redhat.com> wrote:


On 1/30/2014 6:24 AM, Nils Preusker wrote:
> Hi,
>
> I looked at the admin console and examined the HTTP requests and
> redirects and, as far as I can see, you are using a cookie
> (KEYCLOAK_SAAS_COOKIE) to exchange the authentication information (OAuth
> token) between the JavaScript client app and the REST services.
>
> Is there a specific reason you chose to use a cookie instead of a bearer
> token in an authorization header?
>

The cookie, if you see, is Http-only.  So, the browser app has no access
to the token and can't be hit with Javascript attacks. This is all very
specific to the admin console which assumes that it is not running in a
servlet container and getting a HttpSession.

For servlet apps (and those with a http session), token can be stored in
the HTTP session and the browser app just makes rest invocations that
are validated against the http session.

This of course, doesn't quite work well if the browser needs to make
CORS requests.  So, there's also a REST invocation that you can turn on
in the adapter that allows the client to get the token.  Or, you can
just use the pure Javascript lib that Stian wrote for pure HTML5 clients.

> Also, are you planning to integrate the cookie mechanism as
> transparently as bearer tokens (transparently validating by configuring
> web.xml, adding user and roles to HttpServletRequest etc.)?
>

Not sure what you mean by that.

--
Bill Burke
JBoss, a division of Red Hat
http://bill.burkecentral.com
_______________________________________________
keycloak-user mailing list
keycloak-user@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/keycloak-user