$redis
$redis :
redis storage for all storage types
To use, install "predis/predis" via composer
Register client:
$storage = new OAuth2\Storage\Redis($redis);
$storage->setClientDetails($client_id, $client_secret, $redirect_uri);
getAuthorizationCode( $code) : \OAuth2\Storage\An
Fetch authorization code data (probably the most common grant type).
Retrieve the stored data for the given authorization code.
Required for OAuth2::GRANT_TYPE_AUTH_CODE.
| $code | Authorization code to be check with. |
associative array as below, and NULL if the code is invalid
setAuthorizationCode( $authorization_code, mixed $client_id, mixed $user_id, string $redirect_uri, integer $expires, string $scope = null, $id_token = null)
Take the provided authorization code values and store them somewhere.
This function should be the storage counterpart to getAuthCode().
If storage fails for some reason, we're not currently checking for any sort of success/failure, so you should bail out of the script and provide a descriptive fail message.
Required for OAuth2::GRANT_TYPE_AUTH_CODE.
| $authorization_code | ||
| mixed | $client_id |
|
| mixed | $user_id |
|
| string | $redirect_uri |
|
| integer | $expires |
|
| string | $scope |
|
| $id_token |
checkUserCredentials( $username, $password) : TRUE
Grant access tokens for basic user credentials.
Check the supplied username and password for validity.
You can also use the $client_id param to do any checks required based on a client, if you need that.
Required for OAuth2::GRANT_TYPE_USER_CREDENTIALS.
| $username | Username to be check with. |
|
| $password | Password to be check with. |
if the username and password are valid, and FALSE if it isn't. Moreover, if the username and password are valid, and you want to
getUserDetails(string $username) : array|false
| string | $username |
|
checkClientCredentials( $client_id, $client_secret = null) : TRUE
Make sure that the client credentials is valid.
| $client_id | Client identifier to be check with. |
|
| $client_secret | (optional) If a secret is required, check that they've given the right one. |
if the client credentials are valid, and MUST return FALSE if it isn't.
getRefreshToken( $refresh_token) : \OAuth2\Storage\An
Grant refresh access tokens.
Retrieve the stored data for the given refresh token.
Required for OAuth2::GRANT_TYPE_REFRESH_TOKEN.
| $refresh_token | Refresh token to be check with. |
associative array as below, and NULL if the refresh_token is invalid:
setRefreshToken( $refresh_token, $client_id, $user_id, $expires, $scope = null)
Take the provided refresh token values and store them somewhere.
This function should be the storage counterpart to getRefreshToken().
If storage fails for some reason, we're not currently checking for any sort of success/failure, so you should bail out of the script and provide a descriptive fail message.
Required for OAuth2::GRANT_TYPE_REFRESH_TOKEN.
| $refresh_token | Refresh token to be stored. |
|
| $client_id | Client identifier to be stored. |
|
| $user_id | User identifier to be stored. |
|
| $expires | Expiration timestamp to be stored. 0 if the token doesn't expire. |
|
| $scope | (optional) Scopes to be stored in space-separated string. |
unsetRefreshToken( $refresh_token)
Expire a used refresh token.
This is not explicitly required in the spec, but is almost implied. After granting a new refresh token, the old one is no longer useful and so should be forcibly expired in the data store so it can't be used again.
If storage fails for some reason, we're not currently checking for any sort of success/failure, so you should bail out of the script and provide a descriptive fail message.
| $refresh_token | Refresh token to be expired. |
getAccessToken( $access_token) : array|null
Look up the supplied oauth_token from storage.
We need to retrieve access token data as we create and verify tokens.
| $access_token |
setAccessToken( $access_token, mixed $client_id, mixed $user_id, integer $expires, string $scope = null)
Store the supplied access token values to storage.
We need to store access token data as we create and verify tokens.
| $access_token | ||
| mixed | $client_id |
|
| mixed | $user_id |
|
| integer | $expires |
|
| string | $scope |
|
getDefaultScope( $client_id = null) : string
The default scope to use in the event the client does not request one. By returning "false", a request_error is returned by the server to force a scope request by the client. By returning "null", opt out of requiring scopes
| $client_id | An optional client id that can be used to return customized default scopes. |
representation of default scope, null if scopes are not defined, or false to force scope request by the client
ex: 'default' ex: null
getJti( $client_id, $subject, $audience, $expiration, $jti) : \OAuth2\Storage\An
Get a jti (JSON token identifier) by matching against the client_id, subject, audience and expiration.
| $client_id | Client identifier to match. |
|
| $subject | The subject to match. |
|
| $audience | The audience to match. |
|
| $expiration | The expiration of the jti. |
|
| $jti | The jti to match. |
associative array as below, and return NULL if the jti does not exist.
setJti( $client_id, $subject, $audience, $expiration, $jti)
Store a used jti so that we can check against it to prevent replay attacks.
| $client_id | Client identifier to insert. |
|
| $subject | The subject to insert. |
|
| $audience | The audience to insert. |
|
| $expiration | The expiration of the jti. |
|
| $jti | The jti to insert. |