list-sessions レスポンスからセッショントークンを除外する - #278
Merged
Merged
Conversation
|
🚀 プレビュー環境がデプロイされました! URL: https://tascal-pr-278-197260822086.asia-northeast1.run.app |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
close #262
目的
Better Auth の
GET /api/auth/list-sessionsが返す各 session を非機密フィールドの allowlist に変換し、Bearer 認証へ再利用できる session token をブラウザ JavaScript から取得できないようにします。変更内容
apps/api/src/auth.ts/list-sessionsの成功レスポンスを allowlist 化id、userId、日時、IP address、user agent を維持し、tokenを除外Cache-Control: private, no-storeを設定apps/api/src/auth.test.ts制約
この対応は Better Auth 標準 endpoint の after hook で実行時レスポンス本文を変換します。そのため、Better Auth が生成する
listSessionsの推論型および OpenAPI 契約は標準仕様のままで、token必須として表現される実行時レスポンスとの不一致が残ります。issue の第一方針である plugin hook による標準 endpoint の allowlist 化に沿い、Web は現在この API を利用しておらず、受け入れ条件は実行時の認証情報除外を対象としているため、本 PR では型/OpenAPI 契約の追加変更を見送ります。将来 Web 等から型付きで利用する場合は、専用 endpoint または契約の明示的な上書きを検討する必要があります。
影響範囲
apps/apiローカル検証
pnpm --filter @tascal/api exec vitest run src/auth.test.tspnpm lintpnpm format:checkpnpm typecheckpnpm testすべて成功済みです。
レビュー
親セッションで cross-review 済みです(critical 0 / warning 1 / info 1)。warning は上記の型/OpenAPI 契約との不一致として制約に記載し、info の未認証 401 テストは追加 commit で対応しました。