Skip to content

feat(oidc): add refresh tokens for regular clients#170

Merged
rowan-stein merged 2 commits intomainfrom
noa/issue-169
Apr 12, 2026
Merged

feat(oidc): add refresh tokens for regular clients#170
rowan-stein merged 2 commits intomainfrom
noa/issue-169

Conversation

@casey-brooks
Copy link
Copy Markdown
Contributor

Summary

  • add refresh token model plus rotation/reuse detection for regular OIDC clients
  • support refresh_token grants in the token service/route and revoke refresh tokens on logout
  • update admin UI copy/seed data and add coverage across unit/integration/e2e

Testing

  • pnpm lint
  • pnpm typecheck
  • pnpm test
  • pnpm exec dotenv -e .env.development -o -- pnpm build
  • pnpm test:prepare
  • LD_LIBRARY_PATH=/root/.nix-profile/lib:/workspace/mockauth/.playwright-browsers/chromium_headless_shell-1208/chrome-headless-shell-linux64 PLAYWRIGHT_BROWSERS_PATH=/workspace/mockauth/.playwright-browsers pnpm exec dotenv -e .env.test -o -- playwright test --workers=1 --reporter=line

Issue

@casey-brooks casey-brooks requested a review from a team as a code owner April 12, 2026 14:58
@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 12, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
mockauth Ready Ready Preview, Comment Apr 12, 2026 3:15pm

Request Review

@casey-brooks
Copy link
Copy Markdown
Contributor Author

Summary

  • added refresh token persistence, rotation, and reuse detection for regular OIDC clients
  • wired refresh_token grants and logout revocation, plus updated admin/seed data
  • expanded unit/integration/e2e coverage for refresh token flows

Testing

  • pnpm lint
  • pnpm typecheck
  • pnpm test
  • pnpm exec dotenv -e .env.development -o -- pnpm build
  • pnpm test:prepare
  • LD_LIBRARY_PATH=/root/.nix-profile/lib:/workspace/mockauth/.playwright-browsers/chromium_headless_shell-1208/chrome-headless-shell-linux64 PLAYWRIGHT_BROWSERS_PATH=/workspace/mockauth/.playwright-browsers pnpm exec dotenv -e .env.test -o -- playwright test --workers=1 --reporter=line

Copy link
Copy Markdown

@noa-lucent noa-lucent left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good implementation overall — the refresh token model, rotation, reuse detection, and transaction-based concurrency guard are well designed. The scope narrowing with offline_access retention is a nice touch.

Two items require changes before merge:

  1. Duplicated scope validation logicresolveRefreshTokenScopes copies ~15 lines of validation from normalizeRequestedScopes. Extract a shared helper to avoid silent drift.

  2. Missing unit test coverage — The issue explicitly requires tests for scope widening rejection, expired tokens, and client mismatch. These are core security invariants of the refresh flow and need explicit coverage.

Minor items (non-blocking): Prisma client variable naming in refresh-token-service.ts, parseScopeList reuse opportunity, and a note about redundant DB lookups in the route layer.

Comment thread src/server/services/token-service.ts Outdated
Comment thread src/server/services/token-service.ts Outdated
Comment thread src/app/r/[apiResourceId]/oidc/token/route.ts
Comment thread src/server/services/__tests__/token-service.test.ts
Comment thread src/server/services/refresh-token-service.ts Outdated
@casey-brooks
Copy link
Copy Markdown
Contributor Author

Summary

  • extracted shared scope validation helper for refresh/password grants
  • renamed refresh-token service db handle for clarity
  • added refresh grant tests for scope widening, expiry, client mismatch, and revoked tokens

Testing

  • pnpm lint
  • pnpm typecheck
  • pnpm test
  • pnpm exec dotenv -e .env.development -o -- pnpm build
  • pnpm test:prepare
  • LD_LIBRARY_PATH=/root/.nix-profile/lib:/workspace/mockauth/.playwright-browsers/chromium_headless_shell-1208/chrome-headless-shell-linux64 PLAYWRIGHT_BROWSERS_PATH=/workspace/mockauth/.playwright-browsers pnpm exec dotenv -e .env.test -o -- playwright test --workers=1 --reporter=line

Copy link
Copy Markdown

@noa-lucent noa-lucent left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All feedback addressed cleanly:

  • Scope validation duplication → extracted validateRequestedScopes as shared helper, both normalizeRequestedScopes and resolveRefreshTokenScopes now compose on top of it. No more drift risk.
  • Missing tests → four new test cases added covering scope widening rejection, expired tokens, client mismatch, and revoked tokens. All assert the correct error messages matching the service's DomainError throws.
  • clientdb rename → done in both createRefreshToken and revokeRefreshTokenFamily.
  • parseScopeList reusenormalizeRequestedScopes is now a one-liner using parseScopeList.

LGTM — nice work.

@rowan-stein rowan-stein enabled auto-merge April 12, 2026 15:28
@rowan-stein rowan-stein added this pull request to the merge queue Apr 12, 2026
Merged via the queue into main with commit ee51788 Apr 12, 2026
4 checks passed
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.

4 participants