Skip to content

Key principal-provider behavior on providesPrincipal, not the name 'auth' (#888) - #893

Merged
jimhoyd merged 6 commits into
mainfrom
claude/principal-provider-not-name
Sep 29, 2026
Merged

jimhoyd merged 6 commits into
mainfrom
claude/principal-provider-not-name

Conversation

@jimhoyd

@jimhoyd jimhoyd commented Sep 29, 2026

Copy link
Copy Markdown
Collaborator

Fixes #888. The auth: short form, OpenAPI's 401/403 answers and security scheme, and review's session hint now follow the extension contract (providesPrincipal: true), not the extension name auth.

Design

  • Declaring it: providesPrincipal is declared on ExtensionDefinition and checked by defineExtension. composeHost refuses a registration that disagrees with its definition. It is written into urlcode.json by build:addons and carried into the release catalog. packages/auth declares it.
  • Short form: auth: true expands to policies.extensions.<P>, where P is the one declared extension whose descriptor declares providesPrincipal. It looks in the site's packages first, then the first-party install location, then the release catalog.
    • With no provider, it refuses.
    • With more than one, it refuses; name the provider with policies.extensions.<name>.
    • An independent provider such as authjs now works with auth: true. First-party names stay reserved.
  • Determinism: the expansion is written into the normalized routes, which feed the project version and projectSha256.
    • explain, the manifest and routes show the concrete extension.
    • A short-form project has the same revision as its hand-written long form (tested).
    • A package change that moves the target changes the revision (tested), so pinned registrations refuse until re-reviewed.
    • With a host file, prepareExtensions also refuses unless the registered principal provider is the expansion target.
  • OpenAPI: any principal-provider gate gets 401/403 and a per-provider scheme urlcodeSession.<name>. Breaking: it was urlcodeSession, and there is no alias.
  • Review: the session hint names the declared provider, and only if it runs on the requested target (merged with Store operator gaps: reassign audit events, operator attribution, CLI event delivery, targets in explain/review, range filters #875's refusedOn).
  • Breaking: any registration used with auth: must declare providesPrincipal: true.
  • Limits:
    • Text-mode tools resolve against the release catalog only.
    • A host-file-only registration with no installed package can't use the short form unless its name is in the catalog.

Auth.js proof converted

  • proofs/private-requests-authjs now uses auth: true. Its protected routes must match the Better Auth proof's exactly (tested).
  • explain shows extensions.authjs.
  • A new OpenAPI subtest checks security urlcodeSession.authjs and 200/401/403.
  • The "core coupling" gap text is replaced in the proof README and docs/EXTENSIONS.md.

Evidence (macOS, Node 26)

  • npm test: 1158/1158. test:proof:authjs: 13/13. npm run verify and npm run test:package pass.
  • New tests:
    • an independent authjs provider with the short form: it validates statically, has the same revision as the long form, and returns 401/200;
    • zero and two providers are refused;
    • a moved target changes the revision;
    • the OpenAPI and review provider tests;
    • the catalog round trip and the host mismatch refusal.
  • Core budget raised to 909/3598 KiB (measured 927,468 / 3,681,030 bytes).

🤖 Generated with Claude Code

jimhoyd and others added 2 commits September 28, 2026 21:39
…t the name auth (#888)

The route auth: short form, the OpenAPI security scheme and review's session
hint now follow the extension contract instead of the extension name `auth`.

- ExtensionDefinition gains providesPrincipal; composeHost refuses a host()
  registration that disagrees with its definition, and build:addons writes it
  into urlcode.json and the release catalog (packages/auth declares it).
- auth: expands to policies.extensions.<P>, where P is the one declared
  extension whose static descriptor declares providesPrincipal (site
  dependency, else first-party install location, else release catalog). Zero
  or several providers refuse the short form; the explicit form still works.
  Text-mode tools resolve against the release catalog only.
- Determinism: the expansion lands in the normalized routes, so it is part of
  `version` and the pinned projectSha256. A package change that moves the
  target changes the revision, and pinned registrations and grants refuse it.
  prepareExtensions also refuses unless the one declared registration that
  provides a principal is the expansion target.
- OpenAPI emits 401/403 and a per-provider urlcodeSession.<name> scheme for
  any principal-providing gate (registration when loaded, else descriptor).
- review names the declared principal provider in the session hint.
- installedProviders/readInstalledDescriptor move to addon-manifest.ts so the
  config worker can read descriptors without importing addon-install.ts.
- The @example/urlcode-authjs proof declares providesPrincipal and its routes use auth: true; its README, the
  integration test (explain, OpenAPI urlcodeSession.authjs) and EXTENSIONS.md drop the coupling gap.
- Package budget raised (909 KiB packed, 3598 KiB unpacked), measured against current main.

BREAKING CHANGE: a host registration used with auth: must declare
providesPrincipal: true; the OpenAPI scheme is now urlcodeSession.<provider>.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@jimhoyd
jimhoyd merged commit 7c24bbc into main Sep 29, 2026
25 checks passed
@jimhoyd
jimhoyd deleted the claude/principal-provider-not-name branch September 29, 2026 03:19
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.

Key principal-provider behavior on providesPrincipal, not the extension name 'auth'

1 participant