Cassandra
Cassandra storage for all storage types
To use, install "thobbs/phpcassa" via composer:
composer require thobbs/phpcassa:dev-master
Once this is done, instantiate the connection:
$cassandra = new \phpcassa\Connection\ConnectionPool('oauth2_server', array('127.0.0.1:9160'));
Then, register the storage client:
$storage = new OAuth2\Storage\Cassandra($cassandra);
$storage->setClientDetails($client_id, $client_secret, $redirect_uri);
- Full name:
\OAuth2\Storage\Cassandra
- This class implements:
\OAuth2\Storage\AuthorizationCodeInterface
,\OAuth2\Storage\AccessTokenInterface
,\OAuth2\Storage\ClientCredentialsInterface
,\OAuth2\Storage\UserCredentialsInterface
,\OAuth2\Storage\RefreshTokenInterface
,\OAuth2\Storage\JwtBearerInterface
,\OAuth2\Storage\ScopeInterface
,\OAuth2\Storage\PublicKeyInterface
,\OAuth2\OpenID\Storage\UserClaimsInterface
,\OAuth2\OpenID\Storage\AuthorizationCodeInterface
See Also:
-
- test/lib/OAuth2/Storage/Bootstrap::getCassandraStorage
Properties
cache
cassandra
config
Methods
__construct
Cassandra Storage! uses phpCassa
public __construct(\phpcassa\Connection\ConnectionPool|array $connection = array(), array $config = array()): mixed
Parameters:
Parameter | Type | Description |
---|---|---|
$connection |
\phpcassa\Connection\ConnectionPool|array | |
$config |
array |
Throws:
getValue
Parameters:
Parameter | Type | Description |
---|---|---|
$key |
mixed |
setValue
Parameters:
Parameter | Type | Description |
---|---|---|
$key |
mixed | |
$value |
mixed | |
$expire |
int |
expireValue
Parameters:
Parameter | Type | Description |
---|---|---|
$key |
mixed |
getAuthorizationCode
Fetch authorization code data (probably the most common grant type).
Parameters:
Parameter | Type | Description |
---|---|---|
$code |
string |
setAuthorizationCode
Take the provided authorization code values and store them somewhere.
public setAuthorizationCode(string $authorization_code, mixed $client_id, mixed $user_id, string $redirect_uri, int $expires, string $scope = null, string $id_token = null, mixed $code_challenge = null, mixed $code_challenge_method = null): bool
Parameters:
Parameter | Type | Description |
---|---|---|
$authorization_code |
string | |
$client_id |
mixed | |
$user_id |
mixed | |
$redirect_uri |
string | |
$expires |
int | |
$scope |
string | |
$id_token |
string | |
$code_challenge |
mixed | |
$code_challenge_method |
mixed |
expireAuthorizationCode
once an Authorization Code is used, it must be expired
Parameters:
Parameter | Type | Description |
---|---|---|
$code |
string |
checkUserCredentials
Grant access tokens for basic user credentials.
Parameters:
Parameter | Type | Description |
---|---|---|
$username |
string | |
$password |
string |
checkPassword
plaintext passwords are bad! Override this for your application
Parameters:
Parameter | Type | Description |
---|---|---|
$user |
array | |
$password |
string |
hashPassword
Parameters:
Parameter | Type | Description |
---|---|---|
$password |
mixed |
getUserDetails
Parameters:
Parameter | Type | Description |
---|---|---|
$username |
string |
getUser
Parameters:
Parameter | Type | Description |
---|---|---|
$username |
string |
setUser
public setUser(string $username, string $password, string $first_name = null, string $last_name = null): bool
Parameters:
Parameter | Type | Description |
---|---|---|
$username |
string | |
$password |
string | |
$first_name |
string | |
$last_name |
string |
checkClientCredentials
Make sure that the client credentials is valid.
Parameters:
Parameter | Type | Description |
---|---|---|
$client_id |
mixed | |
$client_secret |
string |
isPublicClient
Determine if the client is a "public" client, and therefore does not require passing credentials for certain grant types
Parameters:
Parameter | Type | Description |
---|---|---|
$client_id |
mixed |
getClientDetails
Get client details corresponding client_id.
Parameters:
Parameter | Type | Description |
---|---|---|
$client_id |
mixed |
setClientDetails
public setClientDetails(mixed $client_id, null $client_secret = null, null $redirect_uri = null, null $grant_types = null, null $scope = null, null $user_id = null): bool
Parameters:
Parameter | Type | Description |
---|---|---|
$client_id |
mixed | |
$client_secret |
null | |
$redirect_uri |
null | |
$grant_types |
null | |
$scope |
null | |
$user_id |
null |
checkRestrictedGrantType
Check restricted grant types of corresponding client identifier.
Parameters:
Parameter | Type | Description |
---|---|---|
$client_id |
mixed | |
$grant_type |
mixed |
getRefreshToken
Grant refresh access tokens.
Parameters:
Parameter | Type | Description |
---|---|---|
$refresh_token |
mixed |
setRefreshToken
Take the provided refresh token values and store them somewhere.
public setRefreshToken(mixed $refresh_token, mixed $client_id, mixed $user_id, mixed $expires, null $scope = null): bool
Parameters:
Parameter | Type | Description |
---|---|---|
$refresh_token |
mixed | |
$client_id |
mixed | |
$user_id |
mixed | |
$expires |
mixed | |
$scope |
null |
unsetRefreshToken
Expire a used refresh token.
Parameters:
Parameter | Type | Description |
---|---|---|
$refresh_token |
mixed |
getAccessToken
Look up the supplied oauth_token from storage.
Parameters:
Parameter | Type | Description |
---|---|---|
$access_token |
string |
setAccessToken
Store the supplied access token values to storage.
public setAccessToken(string $access_token, mixed $client_id, mixed $user_id, int $expires, null $scope = null): bool
Parameters:
Parameter | Type | Description |
---|---|---|
$access_token |
string | |
$client_id |
mixed | |
$user_id |
mixed | |
$expires |
int | |
$scope |
null |
unsetAccessToken
Parameters:
Parameter | Type | Description |
---|---|---|
$access_token |
mixed |
scopeExists
Check if the provided scope exists.
Parameters:
Parameter | Type | Description |
---|---|---|
$scope |
mixed |
getDefaultScope
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
Parameters:
Parameter | Type | Description |
---|---|---|
$client_id |
null |
setScope
Parameters:
Parameter | Type | Description |
---|---|---|
$scope |
mixed | |
$client_id |
null | |
$type |
string |
Throws:
getClientKey
Get the public key associated with a client_id
Parameters:
Parameter | Type | Description |
---|---|---|
$client_id |
mixed | |
$subject |
mixed |
setClientKey
Parameters:
Parameter | Type | Description |
---|---|---|
$client_id |
mixed | |
$key |
mixed | |
$subject |
null |
getClientScope
Get the scope associated with this client
Parameters:
Parameter | Type | Description |
---|---|---|
$client_id |
mixed |
getJti
Get a jti (JSON token identifier) by matching against the client_id, subject, audience and expiration.
public getJti(mixed $client_id, mixed $subject, mixed $audience, mixed $expiration, mixed $jti): \OAuth2\Storage\An
Parameters:
Parameter | Type | Description |
---|---|---|
$client_id |
mixed | |
$subject |
mixed | |
$audience |
mixed | |
$expiration |
mixed | |
$jti |
mixed |
Return Value:
associative array as below, and return NULL if the jti does not exist. - issuer: Stored client identifier. - subject: Stored subject. - audience: Stored audience. - expires: Stored expiration in unix timestamp. - jti: The stored jti.
Throws:
setJti
Store a used jti so that we can check against it to prevent replay attacks.
public setJti(mixed $client_id, mixed $subject, mixed $audience, mixed $expiration, mixed $jti): mixed
Parameters:
Parameter | Type | Description |
---|---|---|
$client_id |
mixed | |
$subject |
mixed | |
$audience |
mixed | |
$expiration |
mixed | |
$jti |
mixed |
Throws:
getPublicKey
Parameters:
Parameter | Type | Description |
---|---|---|
$client_id |
string |
getPrivateKey
Parameters:
Parameter | Type | Description |
---|---|---|
$client_id |
string |
getEncryptionAlgorithm
Parameters:
Parameter | Type | Description |
---|---|---|
$client_id |
null |
getUserClaims
Return claims about the provided user id.
Parameters:
Parameter | Type | Description |
---|---|---|
$user_id |
mixed | |
$claims |
string |
getUserClaim
Parameters:
Parameter | Type | Description |
---|---|---|
$claim |
mixed | |
$userDetails |
mixed |
Automatically generated on 2025-03-18