简体   繁体   English

子域上的已登录会话

[英]logged-in session on subdomain

I'm currently facing a following problem: 我目前面临以下问题:

A main domain is running a particular PHP framework with framework specific sessions; 一个主域正在运行具有框架特定会话的特定PHP框架。 now there is a new subdomain, which runs a different PHP framework, and I need to share the login session information from the main domain with the subdomain. 现在有一个新的子域,它运行一个不同的PHP框架,我需要与该子域共享来自主域的登录会话信息。 Ie users only register on the main domain, but once logged in, they will also be logged into their account on the subdomain. 即,用户仅在主域上注册,但是一旦登录,他们也将登录到其在子域上的帐户。 And it should also be noted that the subdomain cannot have access to the main domain db. 还应注意,子域不能访问主域db。

With these restrictions, I came up with the following solution: first I set the domain cookie to .mydomain.com , so I can access the session cookie on the subdomain. 有了这些限制,我想出了以下解决方案:首先,我将域cookie设置为.mydomain.com ,以便可以访问子域上的会话cookie。 Next I implement a simple API call on the main domain, which returns loggedin status as well as other session information. 接下来,我在主域上实现一个简单的API调用,该调用返回登录状态以及其他会话信息。 The API url will have IP whitelist limited to the subdomain server, and once loggedin user comes from the main domain to the subdomain, the API url is requested with the users cookie serverside (cURL presumably). API URL将具有仅限于子域服务器的IP白名单,并且一旦登录用户从主域进入子域,便会向用户cookie服务器端(大概是cURL)请求API URL。 Once and if the user is authenticated this way on the subdomain, he is assigned a token for the particular session, and from there on I can manage that as a regular and separate session on the subdomain. 一旦用户在子域上通过这种方式进行身份验证,就会为他分配特定会话的令牌,然后从那里我可以将其作为子域上的常规会话进行管理。

Now my question is whether you can see any flaw security-wise in this setup? 现在我的问题是,在此设置中您是否可以看到任何安全漏洞? Or suggest any improvements or a more preferable way to do this... 或提出任何改进或更可取的方式来做到这一点...

Thanks 谢谢

For me, i think i will use single sign-on concept. 对我来说,我认为我将使用单点登录概念。 Once user logs-in through any of domain or sub-domain, generate access-Token for that user, sign-in. 用户通过任何域或子域登录后,请为该用户生成访问令牌,然后登录。 After that use that same access Token to check and authenticate user for different domain names, instead using separate sessions. 之后,使用相同的访问令牌来检查和验证用户的不同域名,而不是使用单独的会话。 This might lead to session hijacking and difficult to manage multiple sessions. 这可能导致会话劫持,并且难以管理多个会话。 Once session is created, allocate access-token, with access rules. 创建会话后,请分配访问令牌以及访问规则。 This will make seamless process for sign-in and easy to manage as well. 这将使登录过程变得无缝,并且也易于管理。

For more information look to search Single Sign on or OAuth 2.0 protocol. 有关更多信息,请搜索“单一登录”或OAuth 2.0协议。

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

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