-
Notifications
You must be signed in to change notification settings - Fork 215
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding Support For Session And Refresh Tokens (#786)
### Changes Support Added for following endpoints: - [api/management/v2/users/get-refresh-tokens-for-user](https://auth0.com/docs/api/management/v2/users/get-refresh-tokens-for-user) - [api/management/v2/users/delete-refresh-tokens-for-user](https://auth0.com/docs/api/management/v2/users/delete-refresh-tokens-for-user) - [api/management/v2/users/get-sessions-for-user](https://auth0.com/docs/api/management/v2/users/get-sessions-for-user) - [api/management/v2/users/delete-sessions-for-user](https://auth0.com/docs/api/management/v2/users/delete-sessions-for-user) - [api/management/v2/refresh-tokens/get-refresh-token](https://auth0.com/docs/api/management/v2/refresh-tokens/get-refresh-token) - [api/management/v2/refresh-tokens/delete-refresh-token](https://auth0.com/docs/api/management/v2/refresh-tokens/delete-refresh-token) - [api/management/v2/sessions/get-session](https://auth0.com/docs/api/management/v2/sessions/get-session) - [api/management/v2/sessions/delete-session](https://auth0.com/docs/api/management/v2/sessions/delete-session) ### References - [api/management/v2/users/get-refresh-tokens-for-user](https://auth0.com/docs/api/management/v2/users/get-refresh-tokens-for-user) - [api/management/v2/users/delete-refresh-tokens-for-user](https://auth0.com/docs/api/management/v2/users/delete-refresh-tokens-for-user) - [api/management/v2/users/get-sessions-for-user](https://auth0.com/docs/api/management/v2/users/get-sessions-for-user) - [api/management/v2/users/delete-sessions-for-user](https://auth0.com/docs/api/management/v2/users/delete-sessions-for-user) - [api/management/v2/refresh-tokens/get-refresh-token](https://auth0.com/docs/api/management/v2/refresh-tokens/get-refresh-token) - [api/management/v2/refresh-tokens/delete-refresh-token](https://auth0.com/docs/api/management/v2/refresh-tokens/delete-refresh-token) - [api/management/v2/sessions/get-session](https://auth0.com/docs/api/management/v2/sessions/get-session) - [api/management/v2/sessions/delete-session](https://auth0.com/docs/api/management/v2/sessions/delete-session) ### Testing - [x] This change adds test coverage - [x] This change has been tested on the latest version of the platform/language or why not ### Contributor Checklist - [x] I agree to adhere to the [Auth0 General Contribution Guidelines](https://github.com/auth0/open-source-template/blob/master/GENERAL-CONTRIBUTING.md). - [x] I agree to uphold the [Auth0 Code of Conduct](https://github.com/auth0/open-source-template/blob/master/CODE-OF-CONDUCT.md).
- Loading branch information
1 parent
3acf0f4
commit f54ca47
Showing
10 changed files
with
436 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Auth0\SDK\API\Management; | ||
|
||
use Auth0\SDK\Contract\API\Management\RefreshTokensInterface; | ||
use Auth0\SDK\Utility\Request\RequestOptions; | ||
use Auth0\SDK\Utility\Toolkit; | ||
use Psr\Http\Message\ResponseInterface; | ||
|
||
/** | ||
* Handles requests to the Refresh Tokens endpoint of the v2 Management API. | ||
* | ||
* @see https://auth0.com/docs/api/management/v2#!/Refresh_Tokens | ||
*/ | ||
final class RefreshTokens extends ManagementEndpoint implements RefreshTokensInterface | ||
{ | ||
public function delete( | ||
string $id, | ||
?RequestOptions $options = null, | ||
): ResponseInterface { | ||
[$id] = Toolkit::filter([$id])->string()->trim(); | ||
|
||
Toolkit::assert([ | ||
[$id, \Auth0\SDK\Exception\ArgumentException::missing('id')], | ||
])->isString(); | ||
|
||
return $this->getHttpClient() | ||
->method('delete')->addPath(['refresh-tokens', $id]) | ||
->withOptions($options) | ||
->call(); | ||
} | ||
|
||
public function get( | ||
string $id, | ||
?RequestOptions $options = null, | ||
): ResponseInterface { | ||
[$id] = Toolkit::filter([$id])->string()->trim(); | ||
|
||
Toolkit::assert([ | ||
[$id, \Auth0\SDK\Exception\ArgumentException::missing('id')], | ||
])->isString(); | ||
|
||
return $this->getHttpClient() | ||
->method('get')->addPath(['refresh-tokens', $id]) | ||
->withOptions($options) | ||
->call(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Auth0\SDK\API\Management; | ||
|
||
use Auth0\SDK\Contract\API\Management\SessionsInterface; | ||
use Auth0\SDK\Utility\Request\RequestOptions; | ||
use Auth0\SDK\Utility\Toolkit; | ||
use Psr\Http\Message\ResponseInterface; | ||
|
||
/** | ||
* Handles requests to the Sessions endpoint of the v2 Management API. | ||
* | ||
* @see https://auth0.com/docs/api/management/v2/Sessions | ||
*/ | ||
final class Sessions extends ManagementEndpoint implements SessionsInterface | ||
{ | ||
public function delete( | ||
string $id, | ||
?RequestOptions $options = null, | ||
): ResponseInterface { | ||
[$id] = Toolkit::filter([$id])->string()->trim(); | ||
|
||
Toolkit::assert([ | ||
[$id, \Auth0\SDK\Exception\ArgumentException::missing('id')], | ||
])->isString(); | ||
|
||
return $this->getHttpClient() | ||
->method('delete')->addPath(['sessions', $id]) | ||
->withOptions($options) | ||
->call(); | ||
} | ||
|
||
public function get( | ||
string $id, | ||
?RequestOptions $options = null, | ||
): ResponseInterface { | ||
[$id] = Toolkit::filter([$id])->string()->trim(); | ||
|
||
Toolkit::assert([ | ||
[$id, \Auth0\SDK\Exception\ArgumentException::missing('id')], | ||
])->isString(); | ||
|
||
return $this->getHttpClient() | ||
->method('get')->addPath(['sessions', $id]) | ||
->withOptions($options) | ||
->call(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Auth0\SDK\Contract\API\Management; | ||
|
||
use Auth0\SDK\Utility\Request\RequestOptions; | ||
use Psr\Http\Message\ResponseInterface; | ||
|
||
interface RefreshTokensInterface | ||
{ | ||
/** | ||
* Delete a Refresh Token by ID. | ||
* Required scope: `delete:refresh_tokens`. | ||
* | ||
* @param string $id ID of the refresh token to delete. | ||
* @param null|RequestOptions $options Optional. Additional request options to use, such as a field filtering or pagination. (Not all endpoints support these. See @see for supported options.) | ||
* | ||
* @throws \Auth0\SDK\Exception\ArgumentException when an invalid `id` is provided | ||
* @throws \Auth0\SDK\Exception\NetworkException when the API request fails due to a network error | ||
* | ||
* @see https://auth0.com/docs/api/management/v2#!/Refresh_Tokens/delete_refresh_token | ||
*/ | ||
public function delete( | ||
string $id, | ||
?RequestOptions $options = null, | ||
): ResponseInterface; | ||
|
||
/** | ||
* Retrieve Refresh Token information | ||
* Required scopes: | ||
* - `read:refresh_tokens` for any call to this endpoint. | ||
* | ||
* @param string $id ID of refresh token to retrieve | ||
* @param null|RequestOptions $options Optional. Additional request options to use, such as a field filtering or pagination. (Not all endpoints support these. See @see for supported options.) | ||
* | ||
* @throws \Auth0\SDK\Exception\ArgumentException when an invalid `id` is provided | ||
* @throws \Auth0\SDK\Exception\NetworkException when the API request fails due to a network error | ||
* | ||
* @see https://auth0.com/docs/api/management/v2#!/Refresh_Tokens/get_refresh_token | ||
*/ | ||
public function get( | ||
string $id, | ||
?RequestOptions $options = null, | ||
): ResponseInterface; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Auth0\SDK\Contract\API\Management; | ||
|
||
use Auth0\SDK\Utility\Request\RequestOptions; | ||
use Psr\Http\Message\ResponseInterface; | ||
|
||
interface SessionsInterface | ||
{ | ||
/** | ||
* Delete a Session by ID. | ||
* Required scope: `delete:sessions`. | ||
* | ||
* @param string $id ID of the session to delete. | ||
* @param null|RequestOptions $options Optional. Additional request options to use, such as a field filtering or pagination. (Not all endpoints support these. See @see for supported options.) | ||
* | ||
* @throws \Auth0\SDK\Exception\ArgumentException when an invalid `id` is provided | ||
* @throws \Auth0\SDK\Exception\NetworkException when the API request fails due to a network error | ||
* | ||
* @see https://auth0.com/docs/api/management/v2#!/Sessions/delete_session | ||
*/ | ||
public function delete( | ||
string $id, | ||
?RequestOptions $options = null, | ||
): ResponseInterface; | ||
|
||
/** | ||
* Retrieve Session information | ||
* Required scopes: | ||
* - `read:sessions` for any call to this endpoint. | ||
* | ||
* @param string $id ID of session to retrieve | ||
* @param null|RequestOptions $options Optional. Additional request options to use, such as a field filtering or pagination. (Not all endpoints support these. See @see for supported options.) | ||
* | ||
* @throws \Auth0\SDK\Exception\ArgumentException when an invalid `id` is provided | ||
* @throws \Auth0\SDK\Exception\NetworkException when the API request fails due to a network error | ||
* | ||
* @see https://auth0.com/docs/api/management/v2#!/Sessions/get_session | ||
*/ | ||
public function get( | ||
string $id, | ||
?RequestOptions $options = null, | ||
): ResponseInterface; | ||
} |
Oops, something went wrong.