3 ms·
This was a good article. The first section, explaining the reason why OAuth2 is a fit for certain data flow needs, was really strong. I liked the diagram of the
by mooreds 6y ago
This was a good article. The first section, explaining the reason why OAuth2 is a fit for certain data flow needs, was really strong. I liked the diagram of the flow as that made it clear what all the pieces were.
I think that if you need that separation between your resource servers and authorization server, the OAuth dance can be a bit complicated, you can just use a simple api key. But as soon as you start to allow outside access to your systems, I'd suggest using an OAuth server (disclosure, I work for FusionAuth, a free as in beer competitor to Keycloak, Gluu, etc).
Additional things that I wish had been in the article:
* Don't use implicit flow, use the authorization code grant with PKCE.
* Don't use resource owner password flow; it was designed to allow existing systems to bridge into OAuth and shouldn't be used in new systems today.
Both the implicit flow and the resource owner password flow are not part of OAuth 2.1--here's a post I wrote about it: https://fusionauth.io/blog/2020/04/15/whats-new-in-oauth-2-1 https://fusionauth.io/blog/2020/04/15/whats-new-in-oauth-2-1
* Also, storing access tokens should be done carefully in the browser (httponly, secure cookies is the best way). If you can't do that, then use a server side proxy to store the access tokens. Otherwise your access tokens might get stolen by code executing in the browser.
* OIDC is built on top of OAuth and has a standard set of claims. If you can get by on what OIDC defines, you can switch between identity provider implementations fairly easily.
- bswamina 6y agoThank you very much for the valuable feedback ... very much appreciate and pointers ... this why love to share so can get feedback and pointers for other information may have missed.
- mooreds 6y agoThanks for writing the post and helping people understand the standards better!
- mooreds 6y ago> I think that if you need that separation between your resource servers and authorization server, ... Ack, this should have been I think that if you do not need that separation between your resource servers and authorization server, ...
- different_sort 6y agoStoring tokens in cookies would be against the spec wouldn’t it? I’m not putting rfc6749 on some sort of pedestal, but it clearly states that the tokens are in the response body and not set in cookies. Do you have any examples of Authorization servers in the wild doing this or front end SDKs that work with that? I’m very curious, I’m doing an SPA security research project at work and I’m very interested in these stories and learning more. I’ve seen some folks do refresh in an httponly cookie, and Access in the js space. I’ve seen another example (auth0) put the refresh token in a web worker and access token accessible in js. And I’ve seen things like msal.js just say F it and make them all accessible to js.
- mooreds 6y agoHiya, Sorry, I was wrong. According to the spec you definitely have to send the access token back in the response body[0]. However, a client can store them as cookies (or, as you mention, other places, such as a service worker[1]). This is useful if the client is a single page application (SPA), which may need to present the access token to other resource servers. RFC 6750 has something to say about how to store the bearer token [2]: > Don't store bearer tokens in cookies: Implementations MUST NOT store bearer tokens within cookies that can be sent in the clear (which is the default transmission mode for cookies). Implementations that do store bearer tokens in cookies MUST take precautions against cross-site request forgery. So, I apologize. The authorization server wouldn't send the access token as a cookie. Instead, there'd be a server side proxy which would request the token and then send it down as a secure cookie. Again, best practice would be to keep the access token on the server side proxy and just send a session id down to the client, but that sometimes doesn't work. Here is a diagram illustrating that path (with the 'store' entity acting as the proxy mentioned above)[3]. 0: https://tools.ietf.org/html/rfc6749#section-5.1 https://tools.ietf.org/html/rfc6749#section-5.1 1: https://gitlab.com/jimdigriz/oauth2-worker https://gitlab.com/jimdigriz/oauth2-worker 2: https://tools.ietf.org/html/rfc6750#page-13 https://tools.ietf.org/html/rfc6750#page-13 3: https://fusionauth.io/learn/expert-advice/authentication/webapp/oauth-authorization-code-grant-jwts-refresh-tokens-cookies https://fusionauth.io/learn/expert-advice/authentication/web...
- 6y ago