带有 SameSite=None 的 Cookie;并非在所有上下文中都发送 Secure=true。 Chrome 91
Cookies with SameSite=None; Secure=true are not sent in all contexts. Chrome 91
我有一个托管在 https:/parent.example1.com 的 Web 应用程序,它在 https:/child.[=47 上嵌入了一个跨域 iframe 运行 =].我控制这两个应用程序。
我需要使用 axios
执行从 parent 应用到 child 域的身份验证请求
const config = {
headers: {
Authorization: "Bearer XYZ",
Accept: "application/json",
},
withCredentials: true,
};
axios.get("https://child.example2.com/auth", config)
.then((response) => {
...
})
.catch((error) => {
console.error(error);
});
我没有 SameSite 也没有 Secure errors/warnings 这里是 Set-Cookie header 在响应中:
Set-Cookie : userId="Exaat3Na3NEAA3AYRmi6jeciH5dEafX"; Version=1; Max-Age=604800; Expires=Sat, 25-Jun-2021 13:51:54 GMT; Path=/; Secure; HttpOnly; SameSite=None
此 cookie 应该与域 child.example2.com 相关联,但是当我刷新 iframe 时,浏览器出于某种原因没有发送 cookie。
当我使用 --disable-web-security
禁用 chrome web-security 时,它工作得很好
我想知道我做错了什么?
来自服务器 https://child.example2.com 的响应应包括此 headers :
access-control-allow-credentials: true (this one was missing)
access-control-allow-origin: https:/parent.example1.com (and not * if the header above is set to true)
我有一个托管在 https:/parent.example1.com 的 Web 应用程序,它在 https:/child.[=47 上嵌入了一个跨域 iframe 运行 =].我控制这两个应用程序。
我需要使用 axios
执行从 parent 应用到 child 域的身份验证请求const config = {
headers: {
Authorization: "Bearer XYZ",
Accept: "application/json",
},
withCredentials: true,
};
axios.get("https://child.example2.com/auth", config)
.then((response) => {
...
})
.catch((error) => {
console.error(error);
});
我没有 SameSite 也没有 Secure errors/warnings 这里是 Set-Cookie header 在响应中:
Set-Cookie : userId="Exaat3Na3NEAA3AYRmi6jeciH5dEafX"; Version=1; Max-Age=604800; Expires=Sat, 25-Jun-2021 13:51:54 GMT; Path=/; Secure; HttpOnly; SameSite=None
此 cookie 应该与域 child.example2.com 相关联,但是当我刷新 iframe 时,浏览器出于某种原因没有发送 cookie。
当我使用 --disable-web-security
禁用 chrome web-security 时,它工作得很好我想知道我做错了什么?
来自服务器 https://child.example2.com 的响应应包括此 headers :
access-control-allow-credentials: true (this one was missing)
access-control-allow-origin: https:/parent.example1.com (and not * if the header above is set to true)