ํ์ฌ ๋ฐฑ์๋์์ set-cookie ํด์ฃผ๋ response๋ ์๋์ ๊ฐ๋ค
access-control-allow-credentials: true
allow: POST, OPTIONS
connection: close
content-length: 21
content-type: application/json
date: Wed, 22 Feb 2023 03:04:31 GMT
referrer-policy: same-origin
server: gunicorn
set-cookie: access_token=value; expires=1:00:00; HttpOnly; Path=/; SameSite=None
set-cookie: refresh_token=value; expires=14 days, 0:00:00; HttpOnly; Path=/; SameSite=None
Vary: Accept, Origin, Accept-Encoding
x-content-type-options: nosniff
x-frame-options: DENY
X-Powered-By: Express
ํฌ๋กฌ์์๋ ์ ๋๋ก ์ฟ ํค๊ฐ ์ค์ ๋์ง ์๊ณ ์๋ ๊ฒฝ๊ณ ๊ฐ ๋ฌ๋ค
Set-Cookie ํค๋์ SameSite=None ์์ฑ์ด Secrue ์์ฑ ์์ด ์ค์ ๋์ด ์๊ธฐ ๋๋ฌธ์ ์ฐจ๋จ๋์๋ค๊ณ ์ ํ์๋ค.
SameSite๋
์ฟ ํค๋ฅผ ๊ฐ์ ์ฌ์ดํธ๋ก ๊ณ ๋ คํด์ผํ๋์ง ๋๋ ๊ฐ์ ์ฌ์ดํธ์์๋ง ์ฌ์ฉํ ์ ์๋๋ก ์ ํํ ์ ์๋๋ก ์ค์ ํ ์ ์๋ ์์ฑ์ด๋ค.
Lax
๊ฐ์ ๋๋ฉ์ธ์ด ์๋๋๋ผ๋ ์ผ๋ถ ๊ฒฝ์ฐ(๋งํฌ ์ด๋) ํ์ฉ
Strict
ํ์ฌ ๋ธ๋ผ์ฐ์ ์ URL๊ณผ ์ฟ ํค์ ๋๋ฉ์ธ์ด ์ผ์นํ๋ ๊ฒฝ์ฐ์๋ง ์ฟ ํค ์ ์ก ๊ฐ๋ฅ
None
Set-Cookie: SameSite=None; Secure
- ๋ชจ๋ ๊ฒฝ์ฐ์ ์ ๊ทผ ๊ฐ๋ฅํ๋ค
- Secure ์์ฑ์ ์ฌ์ฉํด์ผํ๊ณ ์ฌ์ฉํ์ง ์์ ๊ฒฝ์ฐ ์ฟ ํค๊ฐ ์ฐจ๋จ๋๋ค.
- Secure์ HTTPS์ผ๋ก ์์ฒญํด์ผ๋ง ์๋ฒ๋ก ์ ์ก๋๋ค.
ํฌ๋กฌ์์ ์ฟ ํค ์ค์ ๋ฐฉ์
- 2020๋ 2์๋ถํฐ SameSite์ ๊ธฐ๋ณธ ๊ฐ์ด None์์ Lax๋ก ๋ณ๊ฒฝ๋์๋ค.
- SameSite=None์ผ๋ก ์ค์ ํ๋ ๊ฒฝ์ฐ์๋ HTTPS ์ฐ๊ฒฐ์ ํตํด์๋ง ์ค์ ํ ์ ์๋๋ก Secure ์์ฑ์ ์ฌ์ฉํด์ผํ๋ค
- http์ https๋ฅผ ์ฐ๊ฒฐ์ ํฌ๋ก์ค ์ฌ์ดํธ๋ก ๊ฐ์ฃผํ๊ธฐ ๋๋ฌธ์ ๊ฐ์ ํ๋กํ ์ฝ์ ์ฌ์ฉํด์ผํ๋ค.
๊ตฌํ ๋ธ๋ผ์ฐ์ ํธํ์ฑ
๊ตฌํ ๋ธ๋ผ์ฐ์ ๋ ์๋ก ๋ฐ๋ None ํน์ฑ๊ณผ ํธํ๋์ง ์๊ธฐ ๋๋ฌธ์ ์ฟ ํค๊ฐ ์ฐจ๋จ๋ ์ ์๋ค.
SameSite=None์ด ํธํ๋์ง ์๋ ๋ธ๋ผ์ฐ์ ๋ชฉ๋ก
1. SameStie=None; Secure ์ฟ ํค์ ์๋ ์ฟ ํค ๋ชจ๋ ์ค์ ํ๋ค
Set-cookie: 3pcookie=value; SameSite=None; Secure
Set-cookie: 3pcookie-legacy=value; Secure
์ ์ฟ ํค๋ฅผ ๋จผ์ ํ์ธํ๊ณ ์์ผ๋ฉด ๊ธฐ์กด ์ฟ ํค๋ก ๋์ฒดํ๋ค.
์ด ๊ฒฝ์ฐ, ์ค๋ณต ์ฟ ํค๋ฅผ ์ค์ ํด์ผํ๋ค๋ ๋จ์ ์ด ์๋ค.
2. Set-Cookie ํค๋๋ฅผ ๋ณด๋ด๋ ์์ ์ ๋ธ๋ผ์ฐ์ ๋ฅผ ๊ฐ์งํ๋ค
๋ธ๋ผ์ฐ์ ๋ฅผ ๊ฐ์งํ๋ ๋ผ์ด๋ธ๋ฌ๋ฆฌ (ex. Node.js์ ua-parser-js ๋ผ์ด๋ธ๋ฌ๋ฆฌ)๋ฅผ ์ฌ์ฉํด์ ์ง์ํ์ง ์๋ ๋ธ๋ผ์ฐ์ ์ธ ๊ฒฝ์ฐ์๋ ๋ ๊ฑฐ์ ๋ฐฉ๋ฒ์ผ๋ก, ์ง์ ๋ธ๋ผ์ฐ์ ๋ ์ ์ฟ ํค ๋ฐฉ์์ผ๋ก ์ค์ ํด์ค๋ค.
์ด ๊ฒฝ์ฐ, ๋ธ๋ผ์ฐ์ ๋ฅผ ๊ฐ์งํ๋ ๊ฒ์ ์ทจ์ฝํ๊ณ ๋ชจ๋ ๋ธ๋ผ์ฐ์ ๋ฅผ ๊ฐ์งํ ์ ์์ ์๋ ์๋ค๋ ๋จ์ ์ด ์๋ค.
์ฐธ๊ณ ๋ก ํ์ด์ดํญ์ค์์๋ ์ ๋๋ก ์ฟ ํค์ ์ค์ ์ด ๋๋ค
ํ์ด์ดํญ์ค๋ Firefox 69๋ถํฐ ํ ์คํธ ๋ฒ์ ์ ์ ๊ณตํ๊ณ ์๊ณ ๋์ค์ ํฌ๋กฌ๊ณผ ๊ฐ์ด ๊ธฐ๋ณธ ๋์์ผ๋ก ๋ง๋ค ์์ ์ด๋ผ๊ณ ํ๋ค.
https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie/SameSite
SameSite cookies - HTTP | MDN
The SameSite attribute of the Set-Cookie HTTP response header allows you to declare if your cookie should be restricted to a first-party or same-site context.
developer.mozilla.org
https://developers.google.com/search/blog/2020/01/get-ready-for-new-samesitenone-secure?hl=ko
์๋ก์ด SameSite=None; Secure ์ฟ ํค ์ค์ ์ ๋๋น | Google ๊ฒ์ ์ผํฐ ๋ธ๋ก๊ทธ | Google Developers
์๊ฒฌ ๋ณด๋ด๊ธฐ ์๋ก์ด SameSite=None; Secure ์ฟ ํค ์ค์ ์ ๋๋น ์ปฌ๋ ์ ์ ์ฌ์ฉํด ์ ๋ฆฌํ๊ธฐ ๋ด ํ๊ฒฝ์ค์ ์ ๊ธฐ์ค์ผ๋ก ์ฝํ ์ธ ๋ฅผ ์ ์ฅํ๊ณ ๋ถ๋ฅํ์ธ์. 2020๋ 1์ 16์ผ ๋ชฉ์์ผ ์ด ๊ฒ์๋ฌผ์ Chromium ๊ฐ๋ฐ์ ๋ธ๋ก
developers.google.com
https://web.dev/samesite-cookie-recipes/
SameSite ์ฟ ํค ๋ ์ํผ
์๋ก์ด SameSite=None ์์ฑ ๊ฐ์ ๋์ ์ผ๋ก ์ฌ์ดํธ๋ ์ด์ ์ฌ์ดํธ ๊ฐ ์ฌ์ฉ์ ์ํด ์ฟ ํค๋ฅผ ๋ช ์์ ์ผ๋ก ํ์ํฉ๋๋ค. ๋ธ๋ผ์ฐ์ ๋ ๋ค์์ผ๋ก ์ด๋ํฉ๋๋ค. SameSite ์์ฑ์ด ์๋ ์ฟ ํค๋ ๊ธฐ๋ณธ์ ์ผ๋ก ์์ฌ๋ก ์
web.dev