Skip to content

[Request]: Prove an embedded upstream auth provider in one local URLCode application #843

Closed

Description

@jimhoyd

Problem or use case

First implementation gate for #841. #837 proved a generic request-bound handoff but its remaining plan expands our own service implementations. Before doing that, prove a real upstream implementation reduces URLCode ownership while retaining declarative authoring and understandable review.

Maintainer decisions: no backward compatibility, old-format migration or API shims; keep the default one locally runnable app; evaluate embedded authentication first. This is a bounded proof, not approval to recreate every current auth/admin feature.

Proposed behavior and alternatives

Use Better Auth as the first embedded candidate, SQLite for persistence, and ordinary static/frontend tooling. Better Auth documents native Request/Response integration and both built-in Node SQLite and better-sqlite3. Select an exact published version and a driver supported by the project's Node matrix during implementation; use node:sqlite first if it passes, rather than adding a native addon unnecessarily.

Build a synthetic private-requests application:

  • Two ordinary users and one reviewer; bootstrap test accounts with the upstream API/tooling.
  • Sign-in, sign-out, verified current identity and session invalidation using upstream behavior.
  • Owners create/list/read their own requests; one reviewer may approve a pending request. Another owner cannot read or alter it. A normal user cannot approve.
  • A minimal frontend uses the upstream client API and standard assets; no custom credential/session code and no new URLCode template language.
  • Explicit URLCode application routes and an explicitly owned upstream auth mount. Review shows the auth provider's subroutes when verified metadata is available; unknown exposure is marked honestly and cannot be described as fully inspected.
  • The app's one custom business transition remains focused application code. Temporary direct parameterized SQL is acceptable for the proof; it must not grow a second CRUD/persistence framework and is replaced/aligned by [Request]: Evaluate conditional state transitions and result-aware idempotency beyond store CRUD #835 before the final release.

Integrate through an operator-installed adapter and #840's handoff where sufficient. Provider authentication reads credentials inside the trusted host; ordinary application handlers receive verified identity/selected services, not forwarded cookies or Authorization. Provider-specific operations may stay namespaced. Do not design a universal authentication interface or expose a raw registry/database merely to demonstrate genericity.

Acceptance evidence:

  1. Start the packed-consumer sample with a documented local command and no mandatory network service; npm installation/build may use the network. Auth and app data initialize in synthetic local SQLite databases. Auth owns its schema; application code does not write its tables.
  2. Exercise the browser/HTTP flow, foreign-owner denial, reviewer denial, malformed input, revoked session, provider initialization failure, and cancellation boundaries. Review must distinguish identity from application permissions.
  3. Native sign-in must work before credential stripping for guest code; it must not bypass origin/CSRF/cookie controls or broadly forward guest credentials. Unsupported target/sandbox combinations refuse before serving.
  4. Run through both CLI-only and connected local authoring-MCP workflows, using [Request]: Make installed authoring validation context executable and discoverable #834 for executable validation context. Human revision approval is supplied explicitly by the evaluator and is not automated by the agent.
  5. Commit a deletion manifest in the PR description: old subsystems that become unnecessary, new adapter/application code, upstream dependencies and exact enabled endpoint/plugin inventory. Report physical source lines and runtime dependencies separately. No migration or compatibility code is counted as required.
  6. Exercise one change to the app without rebuilding account/session internals. Report actual agent repairs and review facts; one successful run is not a productivity benchmark claim.

Decision: adopt the candidate, narrow requirements, or reject it with concrete blocker evidence. Do not extend the proof into weeks of bespoke auth emulation. Only if embedded integration fails a required property should a second candidate be evaluated; Keycloak is not the default/fallback deployment without revisiting the one-app decision.

Non-goals: full historical auth/admin parity, support impersonation/two-person workflows unless independently required for the new product, automatic external package publishing, distributed storage, billing, an identity server, remote MCP authentication, or a frontend framework inside core. Existing sandbox isolation remains unchanged.

Sources: https://better-auth.com/docs/installation ; https://better-auth.com/docs/adapters/sqlite ; https://better-auth.com/docs/plugins/open-api . The OpenAPI plugin is documented as early-stage; endpoint completeness must be verified against the pinned instance, not assumed.

Code areas: packages/core/src/extensions.ts, host.ts, trusted-functions.ts; a small provider adapter and isolated sample. Do not expand packages/auth merely to preserve its public API. Follow repository branch/PR, semantic-card/docs/fixture, verify and package-check requirements. No provider integration was deployed by the preceding audit.

Activity

  1. jimhoyd commented on Sep 28, 2026

    @jimhoyd
    CollaboratorAuthor

    Proof implemented in #848 (unmerged; the decision is yours).

  2. jimhoyd commented on Sep 28, 2026

    @jimhoyd
    CollaboratorAuthor

    Maintainer clarification for #841/#843: Express and Fastify were examples, not the compatibility boundary or a framework shortlist. The direction is interoperability with established JavaScript/TypeScript frameworks and the broader npm ecosystem.

    Keep package identities, discovery, artifacts and core integration contracts independent of framework brands. Prefer established interfaces/formats and upstream APIs; use focused host adapters when lifecycle or request-context semantics differ. Be explicit whether an integration embeds URLCode, mounts a provider, consumes a library, or exchanges artifacts. Generic does not mean claiming every framework's plugins are interchangeable.

    The initial embedded-auth proof remains the first deliverable. Before settling its reusable contract, check for accidental coupling against a second materially different established framework/library integration and record concrete fit/gaps, using a bounded fixture where practical. Do not make implementing all frameworks a prerequisite, or grow a universal middleware layer speculatively.

    #837 remains on hold; this broadens the ecosystem objective rather than restarting its old stages. The authoritative scope in #841 now records this clarification.

  3. jimhoyd commented on Sep 28, 2026

    @jimhoyd
    CollaboratorAuthor

    The bounded proof is now the basis of the supported extension (#854): proofs/private-requests uses @jimhoyd/urlcode-auth directly and its adapter package is deleted; npm run test:proof 12/12 locally.

  4. jimhoyd commented on Sep 29, 2026

    @jimhoyd
    CollaboratorAuthor

    The proof passed and was adopted:

    npm run test:proof runs in CI (verify:workspaces). It covers owner privacy, the reviewer approval race (exactly one wins), non-reviewer 403, cross-origin refusal, revoked-session replay, throttling, sandbox refusal, audit readiness and the MCP runners.

    Remaining #841 acceptance items (a second independent provider, a second framework integration) are tracked on #841.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions