fix(auth): use token un= verbatim for workspace owner paths (@bvbrc/@patricbrc suffixes)#222
Merged
Merged
Conversation
The frontend was re-suffixing / hardcoding the workspace owner realm, which broke users whose token un= carries a non-PATRIC suffix. A user 'compchemist726@bvbrc' owns /compchemist726@bvbrc/... but jobs were submitted to /compchemist726/modelseed (or /compchemist726@patricbrc.org/...), so the PATRIC workspace rejected them with 'Insufficient permissions'. Use the auth token's un= value as-is everywhere the owner segment is built; never strip, split on '@', or append a realm. - loginPatric: store user_id = un= verbatim (drop the @patricbrc.org append). - getStoredAuthUsername: return un= verbatim (token-first), no realm appending; fixes the catch-fallback that double-suffixed already-qualified owners. - lib/utils/workspacePaths.ts: new shared expandOwnerRef that derives the realm from the logged-in owner's un= instead of hardcoding @patricbrc.org. - model + fba pages: use the shared helper with the verbatim owner. - Tests for loginPatric, getStoredAuthUsername, and expandOwnerRef (+17). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
Problem
Reported by José: the frontend stripped/rewrote the workspace owner realm when building output paths. A user whose token
un=iscompchemist726@bvbrcowns/compchemist726@bvbrc/..., but jobs were submitted to/compchemist726/modelseed(suffix stripped), and elsewhere the realm was hardcoded to@patricbrc.org. The PATRIC/BV-BRC workspace then rejected them with "Insufficient permissions" — matching the new backend pre-flightOUTPUT_PATH_NOT_OWNED(commit71e124a).Users with
@bvbrcor@patricbrc.orgsuffixes in their token'sun=field need the full value used verbatim — don't strip, split, or re-suffix.Fix
Use the auth token's
un=value as-is everywhere the owner segment is built.loginPatric— storeuser_id=un=verbatim (drop the@patricbrc.orgappend).getStoredAuthUsername— returnun=verbatim (token-first); removes the catch-fallback that double-suffixed already-qualified owners.lib/utils/workspacePaths.ts(new) — sharedexpandOwnerRefderives the realm from the logged-in owner'sun=instead of hardcoding@patricbrc.org, so a bare ref expands to/<user>@bvbrc/...for BV-BRC users (and@patricbrc.orgfor PATRIC users, unchanged).app/model/[...path]andapp/fba/[...path]— use the shared helper with the verbatim owner instead of the auth method.Tests
+17 unit tests (
loginPatric,getStoredAuthUsername,expandOwnerRef) covering@bvbrc,@patricbrc.org, bare, and fallback cases — these would have caught the regression.Local verification (CI-equivalent):
lint,tsc --noEmit,vitest run(125 passed),next build, andnpm audit --omit=dev --audit-level=highall pass.🤖 Generated with Claude Code