未设置 httponly cookie
httponly cookies not set
具有此设置:
- auth 服务器(keycloak):
localhost:9990
,
- 后端:
localhost:8080
,
- 前端(SPA):
localhost:3000
用户可以通过将用户名+密码发送至:
来“登录”/获取 SPA 令牌
http://localhost:9990/auth/realms/w/protocol/openid-connect/token
然后我在 auth-server 上调用另一个 url 应该设置 keycloak 需要 SSO/remember-me 的 cookie(它应该设置一些 HttpOnly
cookie):
.then(t => keycloakInstance.init({
token: t.access_token,
refreshToken: t.refresh_token,
checkLoginIframe: false, // required to init with token
})
.then((authenticated) => {
console.log('auth', authenticated); // <-- it is true
if (authenticated) {
return fetch('http://localhost:9990/auth/realms/w/custom-sso-provider/sso', { headers: {
Authorization: `Bearer ${keycloakInstance.token}` } })
// else
请求本身似乎没问题,Set-Cookie
如我所料发生;这是回应 header:
我现在希望它们出现在 devtools > Application > cookies 中,但不幸的是没有 cookies 出现。为什么?我该怎么办?
我错过了 credentials: 'include'
的 fetch
电话:
return fetch('http://localhost:9990/auth/realms/w/custom-sso-provider/sso', { headers: { Authorization: `Bearer ${keycloakInstance.token}` }, credentials: 'include' })
具有此设置:
- auth 服务器(keycloak):
localhost:9990
, - 后端:
localhost:8080
, - 前端(SPA):
localhost:3000
用户可以通过将用户名+密码发送至:
来“登录”/获取 SPA 令牌http://localhost:9990/auth/realms/w/protocol/openid-connect/token
然后我在 auth-server 上调用另一个 url 应该设置 keycloak 需要 SSO/remember-me 的 cookie(它应该设置一些 HttpOnly
cookie):
.then(t => keycloakInstance.init({
token: t.access_token,
refreshToken: t.refresh_token,
checkLoginIframe: false, // required to init with token
})
.then((authenticated) => {
console.log('auth', authenticated); // <-- it is true
if (authenticated) {
return fetch('http://localhost:9990/auth/realms/w/custom-sso-provider/sso', { headers: {
Authorization: `Bearer ${keycloakInstance.token}` } })
// else
请求本身似乎没问题,Set-Cookie
如我所料发生;这是回应 header:
我现在希望它们出现在 devtools > Application > cookies 中,但不幸的是没有 cookies 出现。为什么?我该怎么办?
我错过了 credentials: 'include'
的 fetch
电话:
return fetch('http://localhost:9990/auth/realms/w/custom-sso-provider/sso', { headers: { Authorization: `Bearer ${keycloakInstance.token}` }, credentials: 'include' })