saloonphp / saloon

🤠 Build beautiful API integrations and SDKs with Saloon
https://docs.saloon.dev
MIT License
2.09k stars 107 forks source link

Feature | V3 Support Multiple Authenticators #349

Closed Sammyjo20 closed 11 months ago

Sammyjo20 commented 11 months ago

With previous versions of Saloon, you could only have one authenticator per connector/request. This meant that if an API utilized multiple ways of authentication like a certificate and an Authorization header you would have to write it manually. You can now use the MultiAuthenticator to use multiple authenticators at once.

protected function defaultAuth(): Authenticator
{
    return new MultiAuthenticator(
         new TokenAuthenticator('example'),
         new HeaderAuthenticator('api-key', 'X-API-Key'),
    );
}

This is a backwards-compatible change and it's entirely opt-in.

Sammyjo20 commented 11 months ago

Update - some feedback is suggesting just introduce the new MultiAuthenticator authenticator which can be used when multiple authenticators want to be used at the same time.