Skip to content

app/: auth::Principal, the auth seam for the Laravel Rust port (sc-8900) - #51

Merged
ndbroadbent merged 1 commit into
mainfrom
laravel-auth
Dec 2, 2026
Merged

ndbroadbent merged 1 commit into
mainfrom
laravel-auth

Conversation

@ndbroadbent

Copy link
Copy Markdown
Member

The auth seam for the Laravel Rust port (sc-8900), on top of the app/ scaffold (#50). This is what visualci features builds the API and MCP against.

  • auth::Principal, an extractor any handler takes. It's a person or a project token. It's found from, in order:
    • the signed-in user: the session on web routes, or the OAuth token's user behind Authenticate::via::<OAuthTokens<…>>, whose Grant names the MCP client;
    • a personal token (vcu_…), which acts as its user;
    • a project token (vci_…), for its project.
      Nobody found: 401.
  • Checks:
    • role_in(&impl InProject) reads the organization's membership. A project token is a member of its own project only.
    • can(Role, &impl InProject).
    • project_ids_visible().
    • client() says what acted (web, mcp with its client ID, token or project_token with the token's name), for review and upload attribution.
  • InProject: the domain's Project model implements it (project ID and organization ID), so auth doesn't depend on those models. ProjectRef covers callers that only have the IDs. Principal is Authorizable, so policies can take it first.
  • Schema (the auth side's migrations): users gains pid, avatar_url, staff and signup_via (everyone signs in through a forge, so password stays empty), plus identities, user_tokens, project_tokens and waitlist. project_tokens.project_id gets its foreign key once the domain tables exist.
  • Models: User, UserToken and ProjectToken. Tokens are stored as SHA-256 hex, the same as today's server.
  • GET /api/v1/whoami: who the request acts for, and how.

Tests (app/tests/auth.rs):

  • a session user;
  • personal and project bearer tokens;
  • an unknown token, or no token, gets a 401;
  • roles from memberships (a stand-in memberships table until the domain migration lands), and a project token limited to its own project.

Clippy and fmt are clean.

@ndbroadbent
ndbroadbent deleted the branch laravel-app-scaffold December 2, 2026 12:42
@ndbroadbent ndbroadbent closed this Dec 2, 2026
@ndbroadbent ndbroadbent reopened this Dec 2, 2026
@ndbroadbent
ndbroadbent changed the base branch from laravel-app-scaffold to main December 2, 2026 12:42
…r, from the session or MCP OAuth token (with its client) or a personal (vcu_) or project (vci_) bearer token; Role, can(role, project), role_in, project_ids_visible, client() for attribution; InProject for the domain's models; users, identities, user_tokens, project_tokens and waitlist migrations; User and token models; GET /api/v1/whoami
@visualci-com

visualci-com Bot commented Dec 2, 2026

Copy link
Copy Markdown

VisualCI

docspring/visualci · build #193 · 331 unchanged · no changes

This PR vs base: nothing since #192, across 1 build

Updated as builds change. Agents can review with VisualCI's MCP tools.

@ndbroadbent
ndbroadbent merged commit c155fd0 into main Dec 2, 2026
11 checks passed
@ndbroadbent
ndbroadbent deleted the laravel-auth branch December 2, 2026 12:58
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