Skip to content

fix(auth): use token un= verbatim for workspace owner paths (@bvbrc/@patricbrc suffixes)#222

Merged
samseaver merged 1 commit into
ModelSEED:stagingfrom
VibhavSetlur:staging
Jun 17, 2026
Merged

fix(auth): use token un= verbatim for workspace owner paths (@bvbrc/@patricbrc suffixes)#222
samseaver merged 1 commit into
ModelSEED:stagingfrom
VibhavSetlur:staging

Conversation

@VibhavSetlur

Copy link
Copy Markdown
Collaborator

Problem

Reported by José: the frontend stripped/rewrote the workspace owner realm when building output paths. A user whose token un= is compchemist726@bvbrc owns /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-flight OUTPUT_PATH_NOT_OWNED (commit 71e124a).

Users with @bvbrc or @patricbrc.org suffixes in their token's un= 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 — store user_id = un= verbatim (drop the @patricbrc.org append).
  • getStoredAuthUsername — return un= verbatim (token-first); removes the catch-fallback that double-suffixed already-qualified owners.
  • lib/utils/workspacePaths.ts (new) — shared expandOwnerRef derives the realm from the logged-in owner's un= instead of hardcoding @patricbrc.org, so a bare ref expands to /<user>@bvbrc/... for BV-BRC users (and @patricbrc.org for PATRIC users, unchanged).
  • app/model/[...path] and app/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, and npm audit --omit=dev --audit-level=high all pass.

🤖 Generated with Claude Code

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>
@samseaver samseaver merged commit 11e17e9 into ModelSEED:staging Jun 17, 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.

2 participants