Repository navigation
feat: fill the extensibility schema gaps found by the API and provider - #158
Merged
Merged
Conversation
Adds the audit event types the API writes, the permission and custom claims on OidcAccountClaimsSchema, a non-recursive custom claim value the OpenAPI generator can describe, the misconfigured callout failure, and the login hook refusal bodies.
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.
Collects what the Wave 4 consumer PRs had to work around locally. They build on fells-code/seamless-auth-api#580, #582, #583, #584 and #585 and fells-code/seamless-auth-oidc-provider#63, all open and unreleased.
Part of #148 (the two link event types only; the link and notice schemas there are still to do).
What it adds
AUTH_EVENT_TYPES:session_created(#580),custom_claims_omitted(#584), andadmin_oidc_application_link_added/admin_oidc_application_link_removed(already on APImain). Found by diffing the list againstsrc/schemas/authEvent.types.tsonfeat/oidc-provider-claimsandfeat/audit-sinks, and checking everytype: '...'the API writes on both branches. A new test keeps the list sorted and free of duplicates.OidcAccountClaimsSchema: optionalpermissions,permissions_omitted(trueonly),org_roles,org_permissions, andcustomClaims(custom claim values, defaulting to{}so an older API still parses). Matches what #585 returns fromGET /oidc/accounts/:idand what seamless-auth-oidc-provider#63 extends locally. Additive, soOIDC_EDGE_CONTRACT_VERSIONstays at 3.OidcSignRefusalCodeSchema:claims_mismatch, which #585 (590caa1) now answers from/oidc/signfor every account-claim mismatch, so the provider reads the account again and retries once.OIDC_EDGE_CONTRACT_VERSIONstays at 3. An older provider (main) parses refusals with the sharedOidcSignRefusalSchema; an unknown code fails that parse and becomesOidcApiError(403, '/oidc/sign'), which#signOrRefuserethrows. The sign failed the same way for thesubject_mismatchthe API sent before, since onlysession_revokedandunknown_keyget special handling. Bumping would stop every older provider from starting against the new API, which is worse than a less specific log line.CustomClaimValueSchema: no longerz.json(). It is spelled out as three nested levels of string, number, boolean, null, array and record, which accepts and refuses exactly whatz.json()plus the depth check did. Values nested too deep still get the messagemust not nest deeper than 3 levels.CustomClaimSourceSchema.claimsuses it too, so the source and list responses can be described without overflowing the generator.PreTokenHookResultSchemakeepsz.json(): the API checks hook claim depth itself, so it can audit the failure, and that schema never goes into the OpenAPI document.CalloutFailureSchema:misconfigured, for a destination whose own configuration cannot be used, such as an audit sink naming a_AUDIT_SINK_SECRETenv var that is not set. #582 reports that asrefusedtoday.LoginDeniedErrorSchema({ error: 'login_denied', message?: string }) andLoginHookUnavailableErrorSchema({ error: 'login_hook_unavailable' }), the 403 and 503 bodies from #583'sloginHookRefusal.@asteasolutions/zod-to-openapi(^9.1.0, the API's version) is now a dev dependency.src/schemas/customClaim/openapi.test.tsgenerates components for every schema that carries a claim value, the way the API does it, and also checks that a plainz.json()still overflows (so the test shows why the values are spelled out). Againstmain'scustomClaim/schema.tsthe generation test fails withRangeError: Maximum call stack size exceeded.Notes for consumers
CustomClaimValueis now a type nested three levels deep rather than zod'sJSONType. Nothing in the API or provider branches names the type, but code that assigns an arbitraryJSONTypeto it would need a parse.customClaimson account claims is held to the custom claim value rules, where the local extensions usedz.unknown(). The API already holds static and hook claims to the same depth limit, so a valid response is unchanged.FAILURE_TEXT: Record<CalloutFailure, string>(seamless-auth-admin-dashboard#343) needs amisconfiguredentry once it takes this release.Local workarounds to drop once published
feat/oidc-provider-claims(#585):OidcAccountClaimsResponseSchemaand theclaims_mismatchextension ofOidcSignRefusalSchemainsrc/schemas/oidcEdge.responses.ts, and theCLAIMS_MISMATCH/SignRefusalCodeunion insrc/services/oidcSigning.ts.feat/custom-claims(#584): the wrappers insrc/schemas/customClaim.schemas.ts.feat/audit-sinks(#582): report unusable sink settings asmisconfiguredinstead ofrefused(SinkRefusedinsrc/lib/auditSinkTransport.ts).feat/provider-token-claims(feat(oauth): return returnTo from the callback and restrict its scheme #63): the.extendinOidcProviderAccountSchema(src/accountClaims.ts), andSignRefusalSchemainsrc/apiClient.tsplus theCLAIMS_MISMATCH/SignRefusalCodeunion insrc/errors.ts.feat/webhooks-hooks-claims-sinks(#343) andmain:PENDING_EVENT_TYPESinsrc/lib/eventLabels.ts.Checks
npm test: 33 files, 708 tests passednpm run lint: cleannpm run typecheck: cleannpm run build: cleannpm run format:check: All matched files use Prettier code style!npm run test:zod-floor: zod 4.5.0 ok with bothbundlerandNodeNextresolutionNot run: building the API or provider against this package. Their local workarounds come out in follow-ups once this is published.