Moved authentication logic to individual handlers #283
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.
Description
Currently all authentication logic is handled by
Vonage\Client
and spread out in various methods. This change moves each authentication type we support to a handler, and changes the Client to use these handlers. This also adds the abilities forVonage\Client\APIResource
to eventually handle it's own authentication, but this is not directly implemented (it would cause most of the auth types to apply twice).Motivation and Context
As #280 explains, we currently do not have the ability to support both basic authentication and signature authentication when a user wants to use two APIs and one only supports basic, but the other supports Signature (for example, Account and SMS). This is largely due to some bad assumptions when deciding which authentication to use. Ultimately
Vonage\Client
should not be making this determination and it should be left to the individualAPIResource
objects. This PR moves auth to something that can be used anywhere, and prepsAPIResource
for the future, specifically v3.How Has This Been Tested?
Unit tests and against the code snippets locally.
Types of changes
Checklist: