【发布时间】:2019-12-30 12:42:45
【问题描述】:
我正在为多个产品开发集中管理模块。试图在多个产品中保持相同的会话。
对于 Product1:验证成功并在响应标头中发送令牌
请求网址:http://localhost:8080/admin-web/rest/authenticate/
请求标头
Accept:application/json, text/plain, */*
Accept-Encoding:gzip, deflate
Accept-Language:en-US,en;q=0.8
Cache-Control:no-cache
Connection:keep-alive
Host:localhost:8080
Origin:http://product1.com:9090
Pragma:no-cache
Referer:http://product1.com:9090/p1/
User-Agent:Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.109 Safari/537.36
响应标头
Set-Cookie:token=asdf123sfs1f23sfsf321sfsf21; Version=1; Comment=""; Domain=localhost; Path=/ <------------------------------------???
Access-Control-Allow-Credentials:true
Access-Control-Allow-Origin:http://product1.com:9090
Content-Encoding:gzip
Content-Type:application/json
Date:Mon, 13 Nov 2017 12:38:27 GMT
Server:Apache-Coyote/1.1
Transfer-Encoding:chunked
Vary:Origin
Vary:Accept-Encoding
对于产品 2:
请求网址:http://localhost:8080/admin-web/rest/authenticate/
请求标头
Accept:application/json, text/plain, */*
Accept-Encoding:gzip, deflate
Accept-Language:en-US,en;q=0.8
Cache-Control:no-cache
Connection:keep-alive
Content-Length:156
Content-Type:application/json;charset=UTF-8
Host:localhost:8080
Origin:http://product2.com:9090
Pragma:no-cache
Referer:http://product2.com:9090/p2/
token:null <------------------------------------???
User-Agent:Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.109 Safari/537.36
在product1 身份验证后进行product2 身份验证时,发现令牌null。如果我在同一个域上部署product1,它工作正常。
所以,我想在另一个产品请求中对相同的服务 url 使用令牌头。我该怎么做?请在下面找到我的CORS 配置:
<filter>
<filter-name>CORS</filter-name>
<filter-class>com.thetransactioncompany.cors.CORSFilter</filter-class>
<init-param>
<param-name>cors.allowOrigin</param-name>
<param-value>*</param-value>
</init-param>
<init-param>
<param-name>cors.supportedMethods</param-name>
<param-value>GET, HEAD, POST, OPTIONS, PUT, DELETE</param-value>
</init-param>
</filter>
【问题讨论】:
标签: java angularjs rest cookies cross-domain