Skip to content

Add optional request authentication - #6

Merged
happyDemon merged 1 commit into
mainfrom
auth
Nov 11, 2026
Merged

happyDemon merged 1 commit into
mainfrom
auth

Conversation

@happyDemon

Copy link
Copy Markdown
Member

Adds optional authentication to the SkirRPC transport, using Saloon's own authenticators.

  • SkirClient::withAuthenticator(Authenticator $authenticator) passes any Saloon authenticator to the connector, alongside withMockClient().
  • New auth block in config/skir-client.php, set from .env:
    • SKIR_CLIENT_AUTH_TYPE=header with SKIR_CLIENT_AUTH_HEADER and SKIR_CLIENT_AUTH_TOKEN (uses HeaderAuthenticator)
    • bearer with SKIR_CLIENT_AUTH_TOKEN (uses TokenAuthenticator)
    • basic with SKIR_CLIENT_AUTH_USERNAME and SKIR_CLIENT_AUTH_PASSWORD (uses BasicAuthenticator)
  • An unknown auth type, or a selected type with an empty credential, throws SkirClientException when the client is resolved. The client never falls back to sending unauthenticated requests.
  • Custom schemes: implement Saloon\Contracts\Authenticator and 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.md gains an Authentication section, and the exception list and boost reference are updated.

Auth is off unless SKIR_CLIENT_AUTH_TYPE is set, so existing setups behave the same.

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>
@happyDemon
happyDemon merged commit 51726cd into main Nov 11, 2026
7 checks passed
@happyDemon
happyDemon deleted the auth branch November 11, 2026 14:24
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