【问题标题】:Play session cookie not sent by SafariSafari 未发送的播放会话 cookie
【发布时间】:2012-12-24 18:05:28
【问题描述】:

我在域 a.domain.com (http) 上有一个单页应用程序 (SPA),它连接到 Play 2 (scala) 中构建的 b.otherdomain.com (https) 上的 api。

加载 SPA 后,用户输入凭据,应用对 https://b.otherdomain.com.com/login 进行 ajax 调用。

/login 设置了 Play cookie,并且以下请求得到了很好的验证。 一切都适用于 Chrome 和 Firefox(不是 IE,因为 CORS 限制)。

它应该可以在 Safari 上运行,但是在 /login 调用之后,cookie 不会随以下请求一起发回,因此 play 返回“401 未授权”响应。

这是我服务器端的错误还是配置错误? 我是否必须更改 application.session.httpOnly 和 application.session.secure ?

这是我从 Safari 检查器看到的:

/login headers :

URL de la requête:https://b.otherdomain.com//login
Méthode de la requête:POST
Code d’état:200 OK
En-têtes de requêteafficher la source
Accept:application/json, text/plain, */*
Content-Type:application/x-www-form-urlencoded
Origin:http://a.domain.com.com
Referer:http://a.domain.com/
User-Agent:Mozilla/5.0 (Windows NT 6.1) AppleWebKit/534.57.2 (KHTML, like Gecko) Version/5.1.7 Safari/534.57.2
Données du formulaireafficher l’URL codée
email:foo@foo.com
password: foofoo
En-têtes de réponseafficher la source
Access-Control-Allow-Credentials:true
Access-Control-Allow-Origin:http://a.domain.com
Connection:keep-alive
Content-Length:31
Content-Type:text/plain; charset=utf-8
Set-Cookie:PLAY_SESSION=a71f93e3315fa9164dd7112841ccdb4a0f0c447b-     sessionId%3A6gtu7%21z.5i%218d%29v8yxy693n-s6zsuejpav_p67f9hb%7Ej%274h2de*jx3g35p%7Egzo0u;Path=/;HTTPOnly
Strict-Transport-Security:max-age=31536000

following request :

URL de la requête:https://b.otherdomain.com/users
Méthode de la requête:GET
Code d’état:401 Unauthorized
En-têtes de requêteafficher la source
Accept:application/json, text/plain, */* 
Origin:http://a.domain.com
Referer:http://a.domain.com/
User-Agent:Mozilla/5.0 (Windows NT 6.1) AppleWebKit/534.57.2 (KHTML, like Gecko) Version/5.1.7 Safari/534.57.2
En-têtes de réponseafficher la source
Access-Control-Allow-Credentials:true
Access-Control-Allow-Origin:http://a.domain.com
Connection:keep-alive
Content-Length:24
Content-Type:text/plain; charset=utf-8
Strict-Transport-Security:max-age=31536000

【问题讨论】:

标签: scala session safari playframework-2.0 cors


【解决方案1】:

我遇到了同样的问题。它在 Chrome 中运行良好,但在 Safari 中根本不行。我的理解是,这是与third party Cookies相关的Safari新限制。

似乎没有(好的)解决方法。

选项: - 使用代理:服务器 a 上的设置和端点调用 b 服务器端。 - 为 b 创建一个 c-Name DNS 条目以将其视为 a

您可能想尝试 PayPal 跨域套件:https://medium.com/@bluepnume/introducing-paypals-open-source-cross-domain-javascript-suite-95f991b2731d

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-11-13
    • 2015-10-26
    • 1970-01-01
    • 2015-04-30
    • 2018-08-20
    • 1970-01-01
    • 1970-01-01
    • 2015-07-13
    相关资源
    最近更新 更多