Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Moved authentication logic to individual handlers #283

Merged
merged 1 commit into from
Apr 16, 2021

Conversation

dragonmantank
Copy link
Contributor

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 for Vonage\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 individual APIResource objects. This PR moves auth to something that can be used anywhere, and preps APIResource for the future, specifically v3.

How Has This Been Tested?

Unit tests and against the code snippets locally.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@dragonmantank dragonmantank requested a review from GregHolmes April 8, 2021 04:02
Copy link
Contributor

@GregHolmes GregHolmes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this was raised in an example I had a while ago (having 2 objects due to the auth). Really looking forward to this.

@dragonmantank
Copy link
Contributor Author

Yeah, this is a move toward fixing that. We currently cannot properly handle both Signature and Token auth at the same time. I don't think I can properly unravel that until v3.0 because I'll have to make some breaking changes.

@dragonmantank dragonmantank merged commit 5360821 into 2.x Apr 16, 2021
@SecondeJK SecondeJK deleted the move-auth-to-handlers branch January 18, 2022 13:20
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.

2 participants