Pdo
Simple PDO storage for all storage types
NOTE: This class is meant to get users started quickly. If your application requires further customization, extend this class or create your own.
NOTE: Passwords are stored in plaintext, which is never a good idea. Be sure to override this for your application
- Full name:
\OAuth2\Storage\Pdo
- 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
Properties
db
config
Methods
__construct
Parameters:
Parameter | Type | Description |
---|---|---|
$connection |
mixed | |
$config |
array |
Throws:
checkClientCredentials
Make sure that the client credentials is valid.
Parameters:
Parameter | Type | Description |
---|---|---|
$client_id |
string | |
$client_secret |
null|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 |
string |
getClientDetails
Get client details corresponding client_id.
Parameters:
Parameter | Type | Description |
---|---|---|
$client_id |
string |
setClientDetails
public setClientDetails(string $client_id, null|string $client_secret = null, null|string $redirect_uri = null, null|array $grant_types = null, null|string $scope = null, null|string $user_id = null): bool
Parameters:
Parameter | Type | Description |
---|---|---|
$client_id |
string | |
$client_secret |
null|string | |
$redirect_uri |
null|string | |
$grant_types |
null|array | |
$scope |
null|string | |
$user_id |
null|string |
checkRestrictedGrantType
Check restricted grant types of corresponding client identifier.
Parameters:
Parameter | Type | Description |
---|---|---|
$client_id |
mixed | |
$grant_type |
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, string $scope = null): bool
Parameters:
Parameter | Type | Description |
---|---|---|
$access_token |
string | |
$client_id |
mixed | |
$user_id |
mixed | |
$expires |
int | |
$scope |
string |
unsetAccessToken
Parameters:
Parameter | Type | Description |
---|---|---|
$access_token |
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 $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|mixed
Parameters:
Parameter | Type | Description |
---|---|---|
$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 |
setAuthorizationCodeWithIdToken
private setAuthorizationCodeWithIdToken(string $code, mixed $client_id, mixed $user_id, string $redirect_uri, string $expires, string $scope = null, string $id_token = null, mixed $code_challenge = null, mixed $code_challenge_method = null): bool
Parameters:
Parameter | Type | Description |
---|---|---|
$code |
string | |
$client_id |
mixed | |
$user_id |
mixed | |
$redirect_uri |
string | |
$expires |
string | |
$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 |
getUserDetails
Parameters:
Parameter | Type | Description |
---|---|---|
$username |
string |
getUserClaims
Return claims about the provided user id.
Parameters:
Parameter | Type | Description |
---|---|---|
$user_id |
mixed | |
$claims |
string |
getUserClaim
Parameters:
Parameter | Type | Description |
---|---|---|
$claim |
string | |
$userDetails |
array |
getRefreshToken
Grant refresh access tokens.
Parameters:
Parameter | Type | Description |
---|---|---|
$refresh_token |
string |
setRefreshToken
Take the provided refresh token values and store them somewhere.
public setRefreshToken(string $refresh_token, mixed $client_id, mixed $user_id, string $expires, string $scope = null): bool
Parameters:
Parameter | Type | Description |
---|---|---|
$refresh_token |
string | |
$client_id |
mixed | |
$user_id |
mixed | |
$expires |
string | |
$scope |
string |
unsetRefreshToken
Expire a used refresh token.
Parameters:
Parameter | Type | Description |
---|---|---|
$refresh_token |
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 |
getUser
Parameters:
Parameter | Type | Description |
---|---|---|
$username |
string |
setUser
plaintext passwords are bad! Override this for your application
public setUser(string $username, string $password, string $firstName = null, string $lastName = null): bool
Parameters:
Parameter | Type | Description |
---|---|---|
$username |
string | |
$password |
string | |
$firstName |
string | |
$lastName |
string |
scopeExists
Check if the provided scope exists.
Parameters:
Parameter | Type | Description |
---|---|---|
$scope |
string |
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 |
mixed |
getClientKey
Get the public key associated with a client_id
Parameters:
Parameter | Type | Description |
---|---|---|
$client_id |
mixed | |
$subject |
mixed |
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 $expires, mixed $jti): array|null
Parameters:
Parameter | Type | Description |
---|---|---|
$client_id |
mixed | |
$subject |
mixed | |
$audience |
mixed | |
$expires |
mixed | |
$jti |
mixed |
setJti
Store a used jti so that we can check against it to prevent replay attacks.
Parameters:
Parameter | Type | Description |
---|---|---|
$client_id |
mixed | |
$subject |
mixed | |
$audience |
mixed | |
$expires |
mixed | |
$jti |
mixed |
getPublicKey
Parameters:
Parameter | Type | Description |
---|---|---|
$client_id |
mixed |
getPrivateKey
Parameters:
Parameter | Type | Description |
---|---|---|
$client_id |
mixed |
getEncryptionAlgorithm
Parameters:
Parameter | Type | Description |
---|---|---|
$client_id |
mixed |
getBuildSql
DDL to create OAuth2 database and tables for PDO storage
Parameters:
Parameter | Type | Description |
---|---|---|
$dbName |
string |
See Also:
- https://github.com/dsquier/oauth2-server-php-mysql -
Automatically generated on 2025-03-18