简体   繁体   English

设计OAuth2身份验证流程

[英]Designing the flow of OAuth2 authentication

I am trying to come up with a proper OAuth2 authentication flow for a parent/child relationship. 我正在尝试为父/子关系提出适当的OAuth2身份验证流程。
App-A and App-B are two independent applications. App-A和App-B是两个独立的应用程序。 App-A opens up App-B in an iframe when clicks on a link from App-A . App-A打开App-B的iframe中时从一个链接的点击App-A

I am responsible for maintaining App-B . 我负责维护App-B
How can I design the flow in a way so that App-B recognizes users coming from App-A and keep the same session across both the applications? 如何设计流程,以便App-B识别来自App-A用户并在两个应用程序之间保持相同的会话?

This is the flow I have come up with so far: 到目前为止,这是我想出的流程:

  1. App-A will provide a client-id and secret-key to App-B before the interaction. App-A将提供客户端ID和秘密密钥对App-B的相互作用之前。

  2. User makes a request to GET /person endpoint of App-B with a parentId . 用户使用parentIdApp-B GET /person端点发出请求。

  3. App-B will then sends a request to App-A server with client-id, secret-key and redirect-url set as GET /person . 然后, App-B会将请求发送给App-A服务器,该请求的客户端ID,私钥和redirect-url设置为GET /person

Now what App-A will send to App-B to pass the session info of authenticated user. 现在, App-A将发送给App-B以传递经过身份验证的用户的会话信息。

If the flow doesn't make sense, you can get rid of it 如果流程没有意义,您可以摆脱它

Your problem is similar to maintaining session in multiple apps. 您的问题类似于在多个应用程序中维护会话。

The problem with your approach is you need make that request from front end or some Way to AppA (which maintains current user session) which exposes client id/secret 您的方法的问题是您需要从前端或以某种方式向AppA(维护当前用户会话)发出该请求,以公开客户端ID /秘密

Here is some ideas you could achieve it, 这是您可以实现的一些想法,

Is both application is under same parent domain? 两个应用程序都在同一父域下吗? if so, 如果是这样的话,

Like appA.domain.com and appB.domain.com Then after successful authentication, you can set some session identifier cookie in parent domain *..domain.com Then from appB you can get the get the current user session from which you can get the accessToken too. 类似于appA.domain.comappB.domain.com然后,在成功通过身份验证之后,您可以在父域* .. domain.com中设置一些会话标识符cookie,然后从appB中获取获取当前用户会话,从中可以获取也是accessToken。

If both applications are in different domain , then 如果两个应用程序都在不同的域中 ,则

you need to have some common auth server which will maintain session commonly , so when appA loads and found no session available , then it can redirect to common auth server , which in turns check session ( if not let user login ) then send the data back to appA 您需要具有一些将共同维护会话的公共身份验证服务器,因此,当appA加载且没有可用会话时,它可以重定向到公共身份验证服务器,该服务器依次检查会话(如果不让用户登录),然后将数据发送回去到appA

The same flow goes for appB. appB的流程相同。

Also check this link http://merbist.com/2012/04/04/building-and-implementing-a-single-sign-on-solution/ 另请检查此链接http://merbist.com/2012/04/04/building-and-implementing-a-single-sign-on-solution/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM