简体   繁体   English

在不同域之间共享令牌

[英]Share token between different domains

I'm looking a way to securely share a token between one webapp with the front-end of a second webapp.我正在寻找一种在一个 webapp 与第二个 webapp 的前端之间安全地共享令牌的方法。

Environment details:环境细节:

  • webapp.local : A PHP webapp that stories some data that are restricted to specific users. webapp.local :一个 PHP webapp,它讲述了一些仅限特定用户使用的数据。 This webapp is accessible by VPN only.此 webapp 只能通过 VPN 访问。
  • otherwebapp.example : This is a Zendesk instance, it allows us to create a plugin (HTML + JavaScript) that is loaded on the client-side. otherwebapp.example :这是一个 Zendesk 实例,它允许我们创建一个加载在客户端的插件(HTML + JavaScript)。

Notes:笔记:

  • webapp.local and otherwebapp.example use different domains (they aren't sub-domain). webapp.localotherwebapp.example使用不同的域(它们不是子域)。
  • otherwebapp.example is not able to access the webapp.local . otherwebapp.example无法访问webapp.local But the front-end will be able (the user are connected to the VPN).但前端将能够(用户连接到VPN)。

I did some research, and found some options:我做了一些研究,并找到了一些选择:

  • HTTP Coockies : the "SameSite" need to be "None" ( reference ), is it a secure option? HTTP Coockies :“SameSite”需要为“None”(参考),这是一个安全的选项吗? I did some tests and seems that they need to be on the same sub-domain.我做了一些测试,似乎它们需要在同一个子域上。
  • JS postMessage : It will need to open a popup or a iframe, I did some tests but still trying to make it works. JS postMessage :它需要打开一个弹出窗口或一个 iframe,我做了一些测试,但仍然试图让它工作。

The question is: Is there a best practice or another way to share a sensitive data (token) between a webapp and a front-end located on other domain/app?问题是:是否有最佳实践或其他方式在 web 应用程序和位于其他域/应用程序上的前端之间共享敏感数据(令牌)?

I think there is not a fully secure way to do it because you want to handle the share on the client side and that will be always exposed, though you can take a different approach like share a request token via GET param to the second webapp and there call a validation API that validates the origin of the request (should be restricted to the second webapp domain) and also validate the passed token and then return the actual session token.我认为没有一种完全安全的方法可以做到这一点,因为您想在客户端处理共享并且始终会公开,尽管您可以采取不同的方法,例如通过 GET 参数将请求令牌共享到第二个 webapp 和调用一个验证 API 来验证请求的来源(应该限制在第二个 webapp 域),并验证传递的令牌,然后返回实际的 session 令牌。

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

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