Repository navigation
feat(openapi): describe principal providers' credentials truthfully (#1047) - #1054
Merged
Merged
Conversation
…1047) The OpenAPI export gave every providesPrincipal gate an apiKey cookie scheme named `session`, a credential no provider reads and a generated client would send. - A principal provider may declare `openapiSecurity`, a bounded, JSON-only OpenAPI Security Scheme Object (http, apiKey or mutualTLS) that names where a credential goes, never one. It lives on the defineExtension definition (written into urlcode.json and the release catalog, so the passive export reads it without running the extension) and on the registration host() returns; composeHost refuses a difference, and core refuses it on a non-provider or outside the contract. - A complete declaration becomes `urlcodePrincipal.<name>` in components.securitySchemes and the gated operations' security. - A cookie whose name the operator configures, and an undeclared transport, get no scheme and no requirement: the operation states them under x-urlcode.authentication (credential: cookie with cookieName: operator-defined, or credential: unknown). Nothing is invented. - The auth extension declares Better Auth's session cookie without a name, since the name is the operator's Better Auth configuration. - The optional field adds to the extension contract without breaking it, so extensionContract stays 2. Tests cover a provider-declared cookie name, bearer, unknown and mixed gates from descriptors (the export never imports the provider), host-file overrides and refusals, a hey-api client authenticating through the declared cookie, the auth package with an operator cookie prefix, and the Auth.js proof's unknown transport. Co-Authored-By: Claude Opus 5.5 <[email protected]>
jimhoyd
enabled auto-merge (squash)
September 30, 2026 14:46
Takes main's side for the host lease and multiprocess removal (#1050) and keeps the OpenAPI security scheme changes (#1047). Co-Authored-By: Claude Opus 5.5 <[email protected]>
This was referenced Sep 30, 2026
Closed
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.
Fixes #1047
What changed
packages/core/src/openapi.tsgave everyprovidesPrincipalgate{type: 'apiKey', in: 'cookie', name: 'session'}, a cookie no provider reads. A generated client would send it.openapiSecurity, an OpenAPI 3.1 Security Scheme Object limited tohttp(scheme,bearerFormat),apiKey(in,name) andmutualTLS, each with an optionaldescription. It is closed-key JSON with token-checked and length-bounded strings (extensionOpenApiSecurityLimits,openApiSecurityProblemin the newpackages/core/src/openapi-security.ts). It says where a credential goes and has no field that could hold a credential.oauth2andopenIdConnectare left out because their URLs are operator configuration.defineExtensiondefinition. The build writes it intourlcode.jsonand the release catalog, so the export reads it passively and never imports the provider.host()returns must carry the same value, whichcomposeHostchecks.defineExtension, activation and descriptor/catalog parsing refuse it on a non-provider or outside the contract. With--host-file, the registration's value is used and checked before use.components.securitySchemes["urlcodePrincipal.<name>"]and the gated operations'security.apiKey/cookiewith noname) gets no scheme and no requirement. The same goes for a provider that declares nothing. The operation states these underx-urlcode.authentication, as{extension, credential: "cookie", cookieName: "operator-defined"}or{extension, credential: "unknown"}.nameonapiKey, and every scheme type asserts a transport. Any scheme we emitted would be an invented credential that clients like hey-api then send (they readsecurityto addCookie/headers). Leaving outsecurityis valid 3.1. Clients generate normally, and a browser sends its own cookies. Thex-urlcodeextension carries the fact without affecting clients that ignore it.__Secure-prefix an https origin adds. It never appears in the export, which the test checks with an operatorcookiePrefix.Evidence
npm run verifyandnpm run test:packagepass locally (macOS).test/openapi.test.tscovers four cases, each document validated against the shipped official 3.1 schema:sessioncookie.authoption and 200 with it. The client put the token in the cookie the scheme names.packages/auth/test/auth.test.ts: the definition, registration andurlcode.jsondeclare the same scheme. With an operatorcookiePrefix, the export with and without a registration contains no prefix, nobetter-authand nosession_token, while the served sign-in sets the prefixed cookie.test/authjs-provider.integration.ts: the independent Auth.js provider (undeclared) exportscredential: unknownand no scheme.x-badgeheader).Limitations
apiKeywithout a name.🤖 Generated with Claude Code