Skip to content

Refactor auth phased - #1

Merged
shurco merged 5 commits into
mainfrom
refactor-auth-phased
Aug 18, 2026
Merged

Refactor auth phased#1
shurco merged 5 commits into
mainfrom
refactor-auth-phased

Conversation

@shurco

@shurco shurco commented Aug 18, 2026

Copy link
Copy Markdown
Member

No description provided.

shurco added 5 commits August 18, 2026 17:22
Changes made in this commit:
- Added: docs/plans/auth-refactor.md

Key changes:
- Define target session model with opaque refresh and DB sessions
- Document API contract, role matrix, and two-cookie policy
- List phased migration steps with file lists and acceptance criteria
Changes made in this commit:
- Modified: cmd/piplos/main.go, internal/config/config.go, internal/handlers/auth.go, internal/handlers/users.go, internal/middleware/middleware.go, internal/models/models.go, internal/server/routes.go, internal/server/routes_auth_test.go, internal/services/auth/auth.go
- Added: internal/auth/permissions.go, internal/handlers/auth_test.go, internal/middleware/middleware_test.go, internal/middleware/session_checker.go, internal/repository/sessions.go, internal/services/auth/auth_test.go, migrations/012_refresh_sessions.sql
- Deleted: internal/middleware/user_lookup.go

Key changes:
- Store opaque refresh tokens in refresh_sessions with rotation
- Link access JWT claims to session sid for revocation checks
- Add POST /auth/logout and shared permissions matrix
- Validate sessions in middleware without per-request user lookups
Changes made in this commit:
- Modified: web/admin/src/app.d.ts, web/admin/src/hooks.server.ts, web/admin/src/lib/api.server.ts, web/admin/src/lib/auth.server.ts, web/admin/src/routes/(auth)/+layout.server.ts, web/admin/src/routes/(auth)/+layout.svelte, web/admin/src/routes/login/+page.server.ts, web/admin/src/routes/logout/+page.server.ts
- Added: web/admin/src/lib/permissions.ts

Key changes:
- Remove admin_user cookie and load profile via /v1/auth/me
- Centralize token refresh in ensureValidSession
- Align route guards with backend permissions matrix
Changes made in this commit:
- Modified: internal/handlers/auth_test.go, internal/server/routes_auth_test.go, internal/services/auth/auth_test.go, web/admin/package.json
- Added: internal/auth/permissions_test.go, web/admin/package-lock.json, web/admin/src/lib/api.server.test.ts, web/admin/src/lib/auth.server.test.ts, web/admin/src/lib/permissions.test.ts, web/admin/vitest.config.ts

Key changes:
- Cover login, refresh, inactive user, and full auth flow in route tests
- Add permissions matrix drift tests on backend
- Add vitest suite for ensureValidSession, token expiry, and UI guards
Changes made in this commit:
- Modified: web/admin/package.json, web/admin/bun.lock

Key changes:
- Add @internationalized/date required by bits-ui at dev server startup
@shurco
shurco merged commit 87e00b9 into main Aug 18, 2026
2 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.

1 participant