TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Understanding OAuth2 and OpenID Connect

139 pointsby bswaminaover 4 years ago

13 comments

mooredsover 4 years 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.<p>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&#x27;d suggest using an OAuth server (disclosure, I work for FusionAuth, a free as in beer competitor to Keycloak, Gluu, etc).<p>Additional things that I wish had been in the article:<p>* Don&#x27;t use implicit flow, use the authorization code grant with PKCE.<p>* Don&#x27;t use resource owner password flow; it was designed to allow existing systems to bridge into OAuth and shouldn&#x27;t be used in new systems today.<p>Both the implicit flow and the resource owner password flow are not part of OAuth 2.1--here&#x27;s a post I wrote about it: <a href="https:&#x2F;&#x2F;fusionauth.io&#x2F;blog&#x2F;2020&#x2F;04&#x2F;15&#x2F;whats-new-in-oauth-2-1" rel="nofollow">https:&#x2F;&#x2F;fusionauth.io&#x2F;blog&#x2F;2020&#x2F;04&#x2F;15&#x2F;whats-new-in-oauth-2-1</a><p>* Also, storing access tokens should be done carefully in the browser (httponly, secure cookies is the best way). If you can&#x27;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.<p>* 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.
评论 #24396679 未加载
评论 #24395882 未加载
评论 #24396270 未加载
taosxover 4 years ago
I have wasted so much time on oAuth2 and OIDC the past month that I&#x27;m building a SaaS around it. (not wasted but took away time from the business)<p>I would have really liked to use auth0 or other authn services but not a fan of lock-in platforms, I want to export my db without enterprise plans.<p>The pricing model I&#x27;m thinking of is a pay per usage + a commission of the total usage per month.<p>Thank you @sjroot
评论 #24393430 未加载
评论 #24394313 未加载
评论 #24393597 未加载
评论 #24392628 未加载
hardwaresoftonover 4 years ago
For those who are looking for an alternative and are OK with <i>centralization</i> of Auth which is somewhat different from the goals of OAuth, check out the CAS standard -- it&#x27;s an alternative to SAML more so than OAuth.<p>It&#x27;s so simple I wrote (and abandoned) a golang library that implements v1[2]. I didn&#x27;t need the proxy abilities in v2 (and doubt most orgs actually do) and I use JSON in some places before it was in the standard but it was very easy to implement and thus I can say it&#x27;s easy to understand. I&#x27;ve meant to convert the project to Rust for a long time but at this point I&#x27;ll probably never get to it.<p>[0]: <a href="https:&#x2F;&#x2F;apereo.github.io&#x2F;cas&#x2F;4.2.x&#x2F;protocol&#x2F;CAS-Protocol-Specification.html" rel="nofollow">https:&#x2F;&#x2F;apereo.github.io&#x2F;cas&#x2F;4.2.x&#x2F;protocol&#x2F;CAS-Protocol-Spe...</a><p>[1]: <a href="https:&#x2F;&#x2F;apereo.github.io&#x2F;cas&#x2F;4.2.x&#x2F;protocol&#x2F;CAS-Protocol.html" rel="nofollow">https:&#x2F;&#x2F;apereo.github.io&#x2F;cas&#x2F;4.2.x&#x2F;protocol&#x2F;CAS-Protocol.htm...</a><p>[2]: <a href="https:&#x2F;&#x2F;github.com&#x2F;t3hmrman&#x2F;casgo" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;t3hmrman&#x2F;casgo</a>
评论 #24398234 未加载
sjrootover 4 years ago
Are you implementing OAuth 2 or interested in learning more? I would <i>highly</i> recommend combing through the OAuth 2.1 spec [1] as it incorporates the “best practices” that were added to 2.0 through additional RFCs.<p>[1] <a href="https:&#x2F;&#x2F;tools.ietf.org&#x2F;html&#x2F;draft-ietf-oauth-v2-1-00" rel="nofollow">https:&#x2F;&#x2F;tools.ietf.org&#x2F;html&#x2F;draft-ietf-oauth-v2-1-00</a>
评论 #24393517 未加载
评论 #24395897 未加载
candiddevmikeover 4 years ago
May be worth mentioning--JWTs are not part of the OAuth. They&#x27;re certainly used together quite a bit, but you can absolutely use regular session tokens too.<p>I say this as someone who thought JWT was a core part of OAuth and it only added to the perceived complexity of the implementation.
评论 #24393016 未加载
评论 #24392995 未加载
brujoandover 4 years ago
The one thing that really bugs me about the OAuth flow is what is described as step 3. When the application who wants to access data on your behalf is redirected to a login page where the user enters credentials and grants access.<p>In many apps, these login redirects happen inside the app window, hiding the url. And even if the URL isn’t hidden, there’s suddenly a browser window inside my app and many unconscious “security checks” fail to load.<p>I’d much rather have the OAuth provider send me an email or get a notification that can be actioned within the OAuth providers app so that I know I’m not giving my credentials to something that looks like the OAuth providers sign in page.
评论 #24401162 未加载
archsurfaceover 4 years ago
I look forward to reading this, because I&#x27;m currently unconvinced it is possible.
bogomipzover 4 years ago
This was a really well-written post. I really liked the learn by doing approach accompanied by flow diagrams. It&#x27;s easy to get lost in the weeks with OAAuth terminology and this really kept good focus. I also looked at some of the author&#x27;s other posts on things Protobufs and Tries and found them similarly enjoyable. I look forward to reading future posts and hope you post them here as well.
评论 #24398642 未加载
the_afover 4 years ago
The article briefly mentions that the Implicit Grant is a less secure and more simplified version of the Authorization Code grant, but then it doesn&#x27;t elaborate (or it&#x27;s possible I missed that bit). In an introductory article such as this, I think it&#x27;s important to explain <i>why</i> it&#x27;s less secure -- otherwise the Authorization Code grant seems like an unnecessary complication.
评论 #24392489 未加载
评论 #24401478 未加载
ablekhover 4 years ago
Would you think that, for an early-stage SaaS startup (enterprise B2B focus), the <i>optimal strategy</i> for implementing AuthN&#x2F;AuthZ would be to use a managed service (e.g., Auth0) for MVP development and after that (perhaps, during pilots phase) migrate to an open source solution (e.g., Keycloak)?
评论 #24400636 未加载
ratiolatover 4 years ago
The main confusion probably comes from the name Oauth, which seems to suggest that it is about Single Sign On&#x2F;authentication, while in reality it&#x27;s about granting site A access to your data at site B.
评论 #24392432 未加载
评论 #24393638 未加载
amingilaniover 4 years ago
I really wish banks would read this.
bitwarriorover 4 years ago
Can we update the link to point to the actual article?<p><a href="https:&#x2F;&#x2F;www.polarsparc.com&#x2F;xhtml&#x2F;OAuth2-OIDC.html" rel="nofollow">https:&#x2F;&#x2F;www.polarsparc.com&#x2F;xhtml&#x2F;OAuth2-OIDC.html</a>
评论 #24395546 未加载
评论 #24392620 未加载