简体   繁体   English

在不同域之间共享数据

[英]share data between different domains

I have two different services running on two different machine and thus url for both services will be different. 我在两个不同的机器上运行两个不同的服务,因此两个服务的URL将不同。

first user will come to first service which is front end and when some button clicked on this service then user will be redirected to the other frontend services which running on different machine with some dynamic value. 第一个用户将进入前端的第一个服务,并且当在该服务上单击某个按钮时,该用户将被重定向到以不同的动态值运行在不同计算机上的其他前端服务。 My question is how we can share data between these two different domain services without sending data as query string. 我的问题是,我们如何在这两个不同的域服务之间共享数据而又不将数据作为查询字符串发送。

如果这两个服务共享相同的根域(例如a.mysite.com和b.mysite.com),则可以尝试将日期存储在cookie中,以使其成为mysite.com的路径。

The other commenters have provided examples of how you can store data on the client (localStorage and sessionStorage) and one way to send it along with a request to a server (cookies). 其他评论者提供了有关如何在客户端上存储数据的示例(localStorage和sessionStorage),以及将数据和请求一起发送到服务器的一种方法(cookie)。

However, you say that you're trying to share an RSA token which tells me you don't really understand how RSA is supposed to work. 但是,您说您正在尝试共享RSA令牌,这告诉我您并不真正了解RSA应该如何工作。 The short answer is, you don't share the RSA token at all. 简短的答案是,您根本不共享RSA令牌。 At least not the way you're thinking about it. 至少不是您考虑的方式。 Instead, you're authenticating against a server that knows how to handle the 2FA provided by the token and pin combination for a user, this is usually just a POST request sent to that server like any other login. 相反,您要通过知道如何处理用户的令牌和密码组合提供的2FA的服务器进行身份验证,这通常只是发送给该服务器的POST请求,就像其他登录一样。 That server will then respond with some kind of other ticket / token / session cookie / whatever that subsequent requests to other services in your infrastructure will include with them. 然后,该服务器将使用某种其他票证/令牌/会话cookie /进行响应,无论对基础结构中其他服务的后续请求将包含在其中。 Depending on what mechanism you want to use, the details of what that service does to validate the claim will change, but that's the general pattern. 根据您要使用的机制,该服务将执行哪些操作以验证声明的细节将发生变化,但这是一般模式。

I'd strongly recommend studying up on the technologies you're working with so that you don't accidentally compromise the security they offer. 我强烈建议您研究正在使用的技术,以免意外损害其提供的安全性。 Here's a starting point on RSA: https://community.rsa.com/videos/26526 这是RSA的起点: https : //community.rsa.com/videos/26526

You may use localStorage or sessionStorage to share data. 您可以使用localStoragesessionStorage共享数据。

eg 例如

//first service
sessionStorage.setItem('item-key',itemData);

//second service
var itemData = sessionStorage.getItem('item-key');

here item-key will be unique to indicate the share data 这里的item-key将是唯一的,以指示共享数据

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

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