Skip to content

Option A — feat(auth): accept a custom OAuthTokenVerifier in oauth.verify - #2

Open
muralx wants to merge 2 commits into
mainfrom
feat/pluggable-token-verifier
Open

Option A — feat(auth): accept a custom OAuthTokenVerifier in oauth.verify#2
muralx wants to merge 2 commits into
mainfrom
feat/pluggable-token-verifier

Conversation

@muralx

@muralx muralx commented Aug 4, 2026

Copy link
Copy Markdown

One of two alternative shapes for the same capability: letting a provider package (or app) supply its own token verification through the oauth: config, while keeping everything the option wires up — well-known metadata routes, per-tool security schemes, and challenge handling. The companion PR shows the other shape; we intend to propose whichever reads better to the Skybridge maintainers upstream.

Shape

OAuthConfig.verify widens to JwksVerifyConfig | OAuthTokenVerifier. setupOAuth duck-types the union (isTokenVerifier) and only builds the internal JWKS verifier for the config shape.

  • Pro: the verifier is the same currency requireBearerAuth({ verifier }) already takes; exactly-one verification strategy is structurally guaranteed (cannot set both).
  • Con: needs the JwksOAuthConfig alias so provider results keep exposing verify.issuer to the type system; two shapes inhabit one field.

Changes

  • verify: JwksVerifyConfig | OAuthTokenVerifier with docs on the custom-verifier contract (resolve AuthInfo or throw the SDK error classes).
  • isTokenVerifier guard in verify.ts; config-shaped verify without issuer still throws at boot.
  • JwksOAuthConfig = OAuthConfig & { verify: JwksVerifyConfig }: bundled providers keep returning the narrow shape, so verify.issuer reads keep compiling.
  • Tests: guard unit tests + integration tests (custom verifier threads authInfo, 401 challenge with resource_metadata on rejection, metadata endpoints intact).
  • Docs: custom-provider.mdx.

All 403 core tests pass; tsc and biome ci clean.

muralx added 2 commits August 3, 2026 13:14
Widen OAuthConfig.verify to JwksVerifyConfig | OAuthTokenVerifier so a
provider package (or app) can supply its own verification — introspection
for opaque tokens, revocation checks, custom claim mapping, or an IdP's
SDK — while keeping everything the oauth option wires up: the well-known
metadata routes, per-tool security schemes, and challenge handling.

setupOAuth duck-types the union with isTokenVerifier and only builds the
internal JWKS verifier for the config shape; a config-shaped verify still
requires an issuer. The bundled providers keep returning the narrow shape
via the new JwksOAuthConfig alias, so reading verify.issuer off a preset
still typechecks.
@muralx

muralx commented Aug 4, 2026

Copy link
Copy Markdown
Author

Companion/alternative PR: #3 (Option B — createVerifier hook, verify untouched).

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