OAuth2 Password grant with node js

依然范特西╮ 提交于 2019-12-12 09:44:18

问题


I am designing a web application that is mainly divided into following two parts

  1. Web site (UI) : Node JS Express application will be hosted as www.mysite.com
  2. Rest API: Business logic(Atuhentiation, Authorization, business logic) and will be hosted as some different domain for example api.mysite.com

I want to implement the OAuth2 for this application. I read through OAuth2 and understood it's various flows and based on my understanding, I concluded that "Resource Owner Password Credentials" flow is a way to go as Client and Service both belongs to me and user will also directly register with my application and thus they will provide username and password.

I researched a lot around "Resource Owner Password Credentials" flow but this flow is very less talked and documented. I have very little idea close to ZERO that how I should implement this flow in my application. I am developing Website and Rest API in Node JS. Please guide me around how should I implement this ? Any demos, documentations will be helpful.

Thanks in advance !


回答1:


You are right. Its very little documented, plus it is often misleadingly explained wrong. Most explanations of that flow do not point out, that there are two different situations for that flow.

If you have a SPA or similar open apps, you do NOT want to have the client id nor the client secret with the ROPC flow. Because, everyone could read it. Also, it is not required in the RFC.

Your situation is about 2-legged oauth without delegation.

Here is a very good article about how to secure the ROPC flow: http://andyfiedler.com/2014/09/how-secure-is-the-oauth2-resource-owner-password-credential-flow-for-single-page-apps

Hope that helps, I currently struggle with the same issue.



来源:https://stackoverflow.com/questions/40758151/oauth2-password-grant-with-node-js

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!