Repository navigation
[Client] Add client credentials, private_key_jwt and cross-app access - #669
Draft
chr-hertel wants to merge 5 commits into
Draft
chr-hertel wants to merge 5 commits into
chr-hertel wants to merge 5 commits into
Conversation
The HTTP client gets decorated, so the transport keeps speaking plain PSR-18: AuthenticatingHttpClient authenticates every request and retries the ones the authenticator can act on. BearerToken sends a token you already have. A 401 or 403 now fails with an AuthorizationException that names the challenge, which connect() wraps in a ConnectionException without a retry.
Finds and validates the documents that say who guards an MCP server: protected resource metadata (RFC 9728) and authorization server metadata (RFC 8414 and OpenID Connect), plus the WWW-Authenticate challenge that points at them. All of it is @internal, since nothing uses it until the authenticator lands. Endpoints have to pass SecureUrl, and a document naming another issuer than it was fetched for is discarded.
Pass OAuth::forApplication('My App')->build() as `auth` and a client answers a
401 with discovery, client registration, the authorization code flow with PKCE
and a retry. It refreshes tokens, handles step-up challenges and refuses what a
hostile server could send.
Client id metadata documents, the console handler, client credentials,
private_key_jwt and cross-app access follow in their own changes, so their
conformance scenarios stay in the baselines.
… handler setClientMetadataUrl() uses a published document as the client id where the authorization server supports it, and otherwise registers as before. The URL has to be https with a path. ConsoleAuthorizationHandler prints the authorization URL and reads back the redirected URL, for a shell without a browser. It refuses a bare code, which would skip the state and iss checks.
forServiceAccount() runs without a user, setPrivateKeyJwt() replaces the shared secret with a signed assertion and setCrossAppAccess() exchanges an enterprise identity token for a grant.
This branch has not been deployed
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.
Closes #324 & #325 - last slice of the client authorization in chr-hertel#53. Builds on #668, so please only look at the last commit until that one is merged.
setPrivateKeyJwt()signs an assertion instead of sending a secret - withfirebase/php-jwtinstead of the built-in signer orlcobucci/jwtthat [Client] Implement client_credentials grant (client_secret_basic + private_key_jwt) #324 mentions, sinceJwtTokenValidatoralready uses it. It stays a suggestion.setCrossAppAccess()exchanges an enterprise identity token for a grantCompared to the prototype, a client with only a key no longer falls back to Basic with an empty secret, a service account needs a secret or a key, and the identity provider's token endpoint has to be https or loopback.
make conformance-*doesn't run these extension scenarios, so I ranauth/client-credentials-jwt,auth/client-credentials-basic&auth/enterprise-managed-authorizationby hand - all pass.