Repository navigation
Add optional request authentication - #6
Merged
Merged
Conversation
Add SkirClient::withAuthenticator() and an auth block in the package config (header, bearer, basic) resolved with Saloon's built-in authenticators. Misconfigured auth fails when the client is resolved instead of sending unauthenticated requests. The config key can be changed with SkirClientServiceProvider::useConfig(). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Adds optional authentication to the SkirRPC transport, using Saloon's own authenticators.
SkirClient::withAuthenticator(Authenticator $authenticator)passes any Saloon authenticator to the connector, alongsidewithMockClient().authblock inconfig/skir-client.php, set from.env:SKIR_CLIENT_AUTH_TYPE=headerwithSKIR_CLIENT_AUTH_HEADERandSKIR_CLIENT_AUTH_TOKEN(usesHeaderAuthenticator)bearerwithSKIR_CLIENT_AUTH_TOKEN(usesTokenAuthenticator)basicwithSKIR_CLIENT_AUTH_USERNAMEandSKIR_CLIENT_AUTH_PASSWORD(usesBasicAuthenticator)SkirClientExceptionwhen the client is resolved. The client never falls back to sending unauthenticated requests.Saloon\Contracts\Authenticatorand attach it with$app->extend(SkirClient::class, ...).SkirClientServiceProvider::useConfig()lets an app read the client and generator settings from a renamed config file. It is not documented.Docs: the README quick start gains a custom-header example,
docs/configuration.mdgains an Authentication section, and the exception list and boost reference are updated.Auth is off unless
SKIR_CLIENT_AUTH_TYPEis set, so existing setups behave the same.