Skip to content

Replace shared admin cookie with DB sessions#27

Merged
OziinG merged 1 commit intomainfrom
fix/db-backed-admin-sessions
May 1, 2026
Merged

Replace shared admin cookie with DB sessions#27
OziinG merged 1 commit intomainfrom
fix/db-backed-admin-sessions

Conversation

@OziinG
Copy link
Copy Markdown
Contributor

@OziinG OziinG commented May 1, 2026

CLEVER PR review completion

  • target repo: EVNSolution/tomotono-route-console
  • target service: tomotono-route-console
  • target branch: main
  • source branch: fix/db-backed-admin-sessions
  • project-start issue: not-created
  • change-control issue: not-created
  • target repo issue: not-created

변경 내용

  • Fixed shared ADMIN_SESSION_TOKEN cookie auth를 제거하고 로그인마다 랜덤 세션 토큰을 발급하도록 변경
  • AdminSession, AdminLoginLog Prisma 모델 및 migration 추가
  • raw token은 cookie에만 쓰고 DB에는 SHA-256 tokenHash만 저장
  • login 실패/성공, logout, invalid/expired/revoked session audit log 기록
  • Edge middleware는 cookie presence만 확인하고, 실제 DB 검증은 Node.js route/page guard에서 수행
  • logout 시 현재 세션 revokedAt 저장 및 cookie clear
  • EC2 psql audit query / retention cleanup 문서 추가
  • deploy env에서 obsolete ADMIN_PASSWORD, ADMIN_SESSION_TOKEN 제거

PR Scope Grouping Gate

  • grouping decision: single-pr
  • same document/operating-rule cleanup: auth/session/audit/deploy env 문서 일괄 변경
  • same validation command: npx prisma validate && npx prisma generate && npm test && npm run lint && npm run build
  • different app/service/contract surface: 없음
  • merge order dependency: 없음
  • rollback unit: single auth/session migration + route guard 변경

검증

  • npx prisma validate 통과
  • npx prisma generate 통과
  • npm test 통과: 3 files / 18 tests
  • npm run lint 통과
  • npm run build 통과
  • npx prisma migrate status는 로컬 PostgreSQL 접근 거부로 미검증; EC2 deploy migration에서 확인 필요

Concurrent Work Gate

  • parallel work decision: done
  • target repo issue: not-created
  • clever-change-control issue: not-created
  • open PR checked: yes, none open before this PR
  • conflict candidates: none known
  • user-forced-proceed reason: n/a

PR 검토 에이전트 종료 조건

  • 검토 에이전트 작업은 wiki/service context 업데이트로 마친다.
  • PR 정보를 wiki에 올리지 않는다.
  • wiki에는 필요한 서비스 책임, public contract, deploy/runtime 기준, 운영 caveat, 빠른 탐색 요약만 반영한다.

Context/wiki completion

  • context docs checked:
    • docs/admin-auth-operations.md
    • docs/ec2-deployment.md
    • README.md
  • wiki/service context update result: not-needed
  • service doc update: repo-local admin auth/deploy docs updated
  • wiki update: not-needed
  • clever-context-monorepo update: not-needed
  • not-needed reason: change is localized to current MVP app repo and deploy/auth operations docs are included in the repo

Linked issue close evidence

  • linked issue close evidence: no linked issue for this task
  • 이슈 종료는 PR 검토 완료 결과를 근거로 처리한다.
  • 이슈 종료 코멘트에는 wiki/service context 반영 결과 또는 불필요 사유를 이 PR에서 복사해 남긴다.

PR 기준

  • dev PR과 main PR은 검토 에이전트 종료 조건을 채운다.
  • main PR은 deploy merge 단위로 보고 wiki/service context 업데이트 여부를 다시 확인한다.
  • dev PR은 integration merge 단위로 보고 issue close 전에 wiki/service context 업데이트 여부를 확인한다.

Replace the shared cookie secret with per-login session rows and audit trails so EC2 operators can inspect auth activity without exposing raw tokens.

Constraint: Next middleware remains Edge-safe, so it only checks cookie presence while Node.js pages and API routes verify sessions with Prisma.

Rejected: JWT or external auth provider | outside current MVP scope and not requested.

Confidence: high

Scope-risk: moderate

Directive: Do not reintroduce ADMIN_SESSION_TOKEN or env-password fallback; AdminUser.passwordHash remains the password authority.

Tested: npx prisma validate && npx prisma generate && npm test && npm run lint && npm run build

Not-tested: prisma migrate status against local PostgreSQL; local DB denied access and no shadow database URL is configured.

Co-authored-by: OmX <omx@oh-my-codex.dev>
@OziinG OziinG merged commit f125dd3 into main May 1, 2026
2 checks passed
@OziinG OziinG deleted the fix/db-backed-admin-sessions branch May 1, 2026 06:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant