refactor(upload): pilot migration onto @reloop/auth/middleware (#49)#58
Merged
Conversation
First service adopts the shared auth plugin. Mount createAuthPlugin with injected baseUrl/redis/ttl (SESSION_CACHE_REDIS_PREFIX), delete bespoke cookie-auth / api-key-auth / macro middleware, and switch routes to canonical AuthContext via authNoOrg (uploads are user-scoped). Adds smoke tests for session cookie + API key + unauthenticated 401.
| createAuthPlugin({ | ||
| baseUrl: uploadConfig.BASE_URL, | ||
| redis: sessionRedis, | ||
| ttl: 5, |
There was a problem hiding this comment.
Revoked Sessions Can Stay Cached
When a session is revoked by any path that does not delete the shared session:token key, upload now accepts the old cookie until this cache entry expires. The old middleware called get-session on every request, so those revocations were observed immediately instead of allowing a short stale-auth window.
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.
Summary
Pilotots the shared auth plugin on the upload service (low-risk, 2 protected routes).
createAuthPlugin({ baseUrl, redis, ttl })withSESSION_CACHE_REDIS_PREFIXcookie-auth.ts,api-key-auth.ts, and the bespoke macro middlewareAuthContext(userId) withauthNoOrg(user-scoped, not org-scoped)This PR is the migration recipe for later services.
Stacked on #57 (#48). Closes #49.
Test plan
bun testinapps/backend/upload— 3 smoke passbun run check-typesfor be-uploadGreptile Summary
This PR moves upload auth onto the shared auth middleware. The main changes are:
createAuthPluginmounted for upload routes.authNoOrg.Confidence Score: 5/5
This looks safe to merge after checking the short stale-session behavior.
apps/backend/upload/src/middleware/auth.ts
Security Review
A short stale-session window can remain if any revocation path misses shared cache eviction.
Important Files Changed
authNoOrgand readsuserIdfrom the shared auth context.authNoOrg.@reloop/apikeydependency.Reviews (1): Last reviewed commit: "refactor(upload): pilot migration onto @..." | Re-trigger Greptile