Conversation
There was a problem hiding this comment.
Pull request overview
ログアウト機能を「UI(サイドバーのボタン追加)」と「バックエンド(Cookie削除時のSameSite属性を発行時と一致させる)」の両面から整備し、確実にログアウトできる状態にするPRです。
Changes:
- フロントエンドのサイドバーにログアウトボタンを追加し、API呼び出し後に
/loginへ遷移 - バックエンドで
oauth_state/access_tokenの削除CookieにSameSite=None(HTTPS時)を付与し、発行時と属性を一致
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| frontend/src/features/dashboard/components/AppSidebar.tsx | ログアウトボタンUIとローディング制御、ログアウト後の遷移を追加 |
| backend/app/api/endpoints/auth.py | Cookie削除時のSameSite属性をHTTPS環境ではnoneにし、発行時と揃える |
| <div className="mt-auto mb-4"> | ||
| <button | ||
| onClick={handleLogout} | ||
| disabled={isLoggingOut} | ||
| className={` |
There was a problem hiding this comment.
Logout Button のラッパーに mt-auto を付けたことで、下の System Info Box 側にも mt-auto が残っている場合、flexの自動マージンが分散して「ログアウトボタンがSYSTEM STATUSの直上に来ない/大きな余白が入る」レイアウト崩れが起きます。どちらか片方だけに mt-auto を付けるか、2つをまとめた下部コンテナ1つに mt-auto を付けてその中で縦並びにしてください。
| setIsLoggingOut(true); | ||
| try { | ||
| await logout(); | ||
| router.push("/login"); |
There was a problem hiding this comment.
ログアウト後の遷移が router.push("/login") だと履歴にダッシュボードが残るため、戻る操作で保護ページに戻れてしまいます(withAuth 側で弾かれるとしてもUXが悪化しやすいです)。同リポジトリ内の認証リダイレクトは router.replace("/login") を使っているので、ここも replace に揃えるのが安全です。
| router.push("/login"); | |
| router.replace("/login"); |
| is_https = urlparse(settings.FRONTEND_URL).scheme == "https" | ||
| redirect.delete_cookie( | ||
| key="oauth_state", | ||
| path="/", | ||
| httponly=True, | ||
| secure=is_https, | ||
| samesite="lax", | ||
| samesite="none" if is_https else "lax", | ||
| ) |
There was a problem hiding this comment.
oauth_state の削除Cookieに samesite を付け分ける分岐が追加されていますが、現状のテストでは SameSite=None / Secure のケース(FRONTEND_URLがhttpsのとき)を検証していません。settings.FRONTEND_URL を一時的に https に差し替えるテストを追加し、Set-Cookie に samesite=none と secure が含まれることを確認できるようにしてください。
| path="/", | ||
| httponly=True, | ||
| secure=is_https, | ||
| samesite="lax", | ||
| samesite="none" if is_https else "lax", | ||
| ) |
There was a problem hiding this comment.
ログアウトの delete_cookie で samesite="none" if is_https else "lax" に変更されていますが、既存テストはCookieが消えること(max-age=0等)しか見ておらず、今回の修正目的である「属性一致(SameSite/Secure)により本番で確実に削除できる」ことを担保できません。FRONTEND_URLをhttpsにした場合のSet-Cookieヘッダーに samesite=none と secure が出ることを追加でアサートしてください。
There was a problem hiding this comment.
@copilot open a new pull request to apply changes based on this feedback
|
@Inlet-back I've opened a new pull request, #124, to work on those changes. Once the pull request is ready, I'll request review from you. |
- FRONTEND_URLがHTTPSの場合、Set-Cookieヘッダーに samesite=none と secure が含まれることをテスト - Cookie削除時は設定時と同じ属性が必要(ブラウザ仕様) - 本番環境で確実にCookie削除されることを担保
作業状況メモ (2026-02-22)
完了したPR
PR #117: OAuth Cookie設定の修正
fix/oauth-cookie-samesiteSameSite=None; Secureに変更(HTTPS環境)PR #115: デプロイ設定
feature/deployment-config進行中のPR
PR #122: ログアウト機能の完全実装 (Issue #122)
feature/issue-122-logout-buttonAppSidebar.tsxにログアウトボタンを追加auth.py)コミット:
9218941- ログアウトボタンUI実装19c20c5- Cookie削除時のSameSite修正PRタイトル:
PR本文:
デプロイ状況
Render (バックエンド)
Vercel (フロントエンド)
環境変数設定
既知の問題
SameSite=NoneのためCSRF攻撃に脆弱次のアクション