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-2435] Add Organizations support to Management API Client #483

Merged
merged 39 commits into from
Apr 1, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
03c49a6
feat: Support passing `organization_id` configuration parameter
evansims Mar 16, 2021
0029569
feat: Pass `organization` parameter to /authorize endpoint
evansims Mar 16, 2021
daea5a9
feat: Add new API request helpers for normalizing additional query pa…
evansims Mar 16, 2021
2f3d57d
feat: Validate ID Token `org_id` claim when an organization is config…
evansims Mar 16, 2021
9a854cc
feat: Support querying /users/:user_id/organizations endpoint for lis…
evansims Mar 16, 2021
47587bb
feat: Add Organizations endpoint support for Management API
evansims Mar 16, 2021
bc79a0b
fix: Specify required parameters
evansims Mar 16, 2021
f1903dd
feat: Prep for basic branding customizations validation
evansims Mar 16, 2021
879f7a3
feat: Throw unique error if org_id claim is expected but not present.
evansims Mar 16, 2021
b2e22be
fix: Expose $organization params, rather than $organizationId
evansims Mar 16, 2021
946bc05
feat: Add helpers functions for parsing invitation query parameters f…
evansims Mar 16, 2021
26c24f8
docs: Update README with orgs examples
evansims Mar 16, 2021
84f6f13
docs: Update README
evansims Mar 16, 2021
5855e56
docs: Update README
evansims Mar 16, 2021
8539157
docs: Update README
evansims Mar 16, 2021
94d4b0f
feat: Allow instantiating singleton of Organizations class from Manag…
evansims Mar 16, 2021
db1c4d8
Merge remote-tracking branch 'origin/master' into feat-sdk-2374-manag…
evansims Mar 29, 2021
ecdcad2
chore: Update phpunit.xml.dist to newer configuration format
evansims Mar 30, 2021
c1342c9
chore: Coding standards
evansims Mar 30, 2021
cc3f081
feat: Continue implimenting Organizations to Management API
evansims Mar 30, 2021
878d845
tests: Add integration tests for Organizations on Management API
evansims Mar 30, 2021
5bc8231
feat: Add additional endpoints
evansims Mar 31, 2021
81ba103
tests: Improvements to integration tests
evansims Mar 31, 2021
e33f406
chores: Coding standards pass
evansims Mar 31, 2021
2454368
docs: Remove API documentation links until they’re available
evansims Mar 31, 2021
b8fb6fe
fix: Use new normalizeRequest() on Users::getOrganizations
evansims Mar 31, 2021
4c4d6c0
tests: Add Users::getOrganizations method to mocked unit tests
evansims Mar 31, 2021
3879e24
feat: Add validation helper checkEmptyOrInvalidArray()
evansims Mar 31, 2021
dfc02d5
feat: Add required parameter validators
evansims Mar 31, 2021
f95859a
tests: Mark as integration test group
evansims Mar 31, 2021
7c34f5d
tests: Add Organizations unit tests
evansims Mar 31, 2021
0475880
feat: Remove alias functions
evansims Mar 31, 2021
0962a64
tests: Tweaks to integration test
evansims Mar 31, 2021
f841bbc
fix: Remove leftover debug code
evansims Mar 31, 2021
eeea449
feat: Support passing organization_id to email verification and chang…
evansims Mar 31, 2021
9369fad
docs: Specify the inviter.name and invtee.email requirements on Organ…
evansims Mar 31, 2021
ec00082
tests: Add integration tests for invitations endpoints.
evansims Mar 31, 2021
002d926
fix: Typo in test name
evansims Mar 31, 2021
0a172a3
docs: Fix docblock parameters on getEnabledConnection
evansims Apr 1, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 7 additions & 10 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
<phpunit
colors="true"
verbose="true"
bootstrap="./tests/bootstrap.php">
<?xml version="1.0"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" colors="true" verbose="true" bootstrap="./tests/bootstrap.php" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
<coverage>
<include>
<directory suffix=".php">./src/</directory>
</include>
</coverage>
<testsuites>
<testsuite name="unit">
<directory>./tests/unit</directory>
Expand All @@ -10,10 +13,4 @@
<directory>./tests/integration</directory>
</testsuite>
</testsuites>

<filter>
<whitelist>
<directory suffix=".php">./src/</directory>
</whitelist>
</filter>
</phpunit>
22 changes: 22 additions & 0 deletions src/API/Management.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
use Auth0\SDK\API\Management\Logs;
use Auth0\SDK\API\Management\LogStreams;
use Auth0\SDK\API\Management\ResourceServers;
use Auth0\SDK\API\Management\Organizations;
use Auth0\SDK\API\Management\Roles;
use Auth0\SDK\API\Management\Rules;
use Auth0\SDK\API\Management\Stats;
Expand Down Expand Up @@ -126,6 +127,13 @@ class Management
*/
private $logStreams;

/**
* Instance of Auth0\SDK\API\Management\Organizations
*
* @var Organizations
*/
private $organizations;

/**
* Instance of Auth0\SDK\API\Management\Roles
*
Expand Down Expand Up @@ -381,6 +389,20 @@ public function logStreams() : LogStreams
return $this->logStreams;
}

/**
* Return an instance of the Organizations class.
*
* @return Organizations
*/
public function organizations() : Organizations
{
if (! $this->organizations instanceof Organizations) {
$this->organizations = new Organizations($this->apiClient);
}

return $this->organizations;
}

/**
* Return an instance of the Roles class.
*
Expand Down
17 changes: 17 additions & 0 deletions src/API/Management/GenericResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -183,4 +183,21 @@ protected function checkEmptyOrInvalidString($var, $var_name)
throw new EmptyOrInvalidParameterException($var_name);
}
}

/**
* Check that a variable is an array and is not empty.
*
* @param mixed $var The variable to check.
* @param string $var_name The variable name.
*
* @return void
*
* @throws EmptyOrInvalidParameterException If $var is empty or is not a string.
*/
protected function checkEmptyOrInvalidArray($var, $var_name)
{
if (! is_array($var) || ! count($var)) {
throw new EmptyOrInvalidParameterException($var_name);
}
}
}
13 changes: 9 additions & 4 deletions src/API/Management/Jobs.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,11 @@ public function exportUsers($params = [])
*
* @param string $user_id User ID of the user to send the verification email to.
* @param array $params Array of optional parameters to add.
* - client_id: Client ID of the requesting application. If not provided, the global Client ID will be used.
* - identity: The optional identity of the user, as an array. Required to verify primary identities when using social, enterprise, or passwordless connections. It is also required to verify secondary identities.
* - user_id: User ID of the identity to be verified. Must be a non-empty string.
* - provider: Identity provider name of the identity (e.g. google-oauth2). Must be a non-empty string.
* - client_id: Client ID of the requesting application. If not provided, the global Client ID will be used.
* - identity: The optional identity of the user, as an array. Required to verify primary identities when using social, enterprise, or passwordless connections. It is also required to verify secondary identities.
* - user_id: User ID of the identity to be verified. Must be a non-empty string.
* - provider: Identity provider name of the identity (e.g. google-oauth2). Must be a non-empty string.
* - organization_id: ID of the organization. If provided, the organization_id and organization_name will be included as query arguments in the link back to the application.
*
* @throws EmptyOrInvalidParameterException Thrown if any required parameters are empty or invalid.
* @throws \Exception Thrown by the HTTP client when there is a problem with the API call.
Expand All @@ -145,6 +146,10 @@ public function sendVerificationEmail($user_id, array $params = [])
$body['client_id'] = $params['client_id'];
}

if (! empty( $params['organization_id'] )) {
$body['organization_id'] = $params['organization_id'];
}

if (! empty( $params['identity'] )) {
if (empty( $params['identity']['user_id']) || ! is_string($params['identity']['user_id'])) {
throw new EmptyOrInvalidParameterException('Missing required "user_id" field of the "identity" object.');
Expand Down
Loading