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

[SDK-4393] feat(auth): Support Organization Name with Authorization API #719

Merged
merged 11 commits into from
Jul 19, 2023

Conversation

evansims
Copy link
Member

@evansims evansims commented Jul 18, 2023

Changes

Note
Your Auth0 tenant must have this feature enabled to use this.

This PR adds support for authorizing using an organization name. This enhances the existing support for authorizing using an organization ID. Example usage follows:

✨ (New) Authorization using an organization name:

new Auth0(
  new SdkConfiguration(
    organization: ['example-org-name'],
  )
);

(Existing) support for authorization using an organization ID:

new Auth0(
  new SdkConfiguration(
    organization: ['org_123456'],
  )
);

(Updated) The SDK treats the organization parameter as an allowlist for applications that need to work with multiple organizations. It now accepts organization names, as well as existing support for IDs.

$sdk = new Auth0(
  new SdkConfiguration(
    organization: ['org_123456', 'example-org-name', 'another-org-name'],
  )
);

(Existing) When redirecting for authorization, the organization allowlist's first value is used by default. This behavior can be overridden using method parameters:

// Redirects to /authorize?organization=org_123456&...
header('Location: ' . $sdk->login());
// Redirects to /authorize?organization=org_000000&...
header('Location: ' . $sdk->login(params: ['organization': 'org_000000'));
// Redirects to /authorize?organization=example-org-name&...
header('Location: ' . $sdk->login(params: ['organization': 'example-org-name'));
// Redirects to /authorize?...
header('Location: ' . $sdk->login(params: ['organization': null));

References

Please review the internal Jira ticket SDK-4393 for further information.

Testing

  • Tests have been updated to support the new functionality and maintain 100% coverage.
  • Run composer test from a clone of the branch to test locally.
  • Review the CI test results on the PR otherwise.

Contributor Checklist

@evansims evansims added Scope: Improvement Code changes including new features or enhancements to the library. Roadmap: Next Minor Targets the next minor release of the library. labels Jul 18, 2023
@evansims evansims added this to the Next Release milestone Jul 18, 2023
@codecov-commenter
Copy link

codecov-commenter commented Jul 18, 2023

Codecov Report

Patch coverage: 100.00% and no project coverage change.

Comparison is base (efa11eb) 100.00% compared to head (1d9240b) 100.00%.

Additional details and impacted files
@@             Coverage Diff             @@
##                main      #719   +/-   ##
===========================================
  Coverage     100.00%   100.00%           
- Complexity      1311      1327   +16     
===========================================
  Files             62        62           
  Lines           4587      4613   +26     
===========================================
+ Hits            4587      4613   +26     
Flag Coverage Δ
unittests 100.00% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
src/Configuration/SdkConfiguration.php 100.00% <ø> (ø)
src/Token.php 100.00% <100.00%> (ø)
src/Token/Validator.php 100.00% <100.00%> (ø)

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@evansims evansims marked this pull request as ready for review July 18, 2023 04:13
@evansims evansims requested a review from a team as a code owner July 18, 2023 04:13
src/Token/Validator.php Outdated Show resolved Hide resolved
@evansims
Copy link
Member Author

Thanks @stevehobbsdev, updated with changes to reflect that conversation.

@evansims evansims added this pull request to the merge queue Jul 19, 2023
Merged via the queue into main with commit 958e06a Jul 19, 2023
9 checks passed
@evansims evansims deleted the feat/org-name-support branch July 19, 2023 13:51
@evansims evansims mentioned this pull request Jul 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Roadmap: Next Minor Targets the next minor release of the library. Scope: Improvement Code changes including new features or enhancements to the library.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants