class token_storage implements TokenStorageInterface

OAuth storage wrapper for phpBB's cache

Properties

protected driver_interface $db
protected user $user
protected string $oauth_token_table
protected string $oauth_state_table
protected TokenInterface $cachedToken
protected string $cachedState

Methods

__construct(driver_interface $db, user $user, string $oauth_token_table, string $oauth_state_table)

Constructor.

retrieveAccessToken($service)

{@inheritdoc}

storeAccessToken($service, TokenInterface $token)

{@inheritdoc}

hasAccessToken($service)

{@inheritdoc}

clearToken($service)

{@inheritdoc}

clearAllTokens()

{@inheritdoc}

storeAuthorizationState($service, $state)

{@inheritdoc}

hasAuthorizationState($service)

{@inheritdoc}

retrieveAuthorizationState($service)

{@inheritdoc}

clearAuthorizationState($service)

{@inheritdoc}

clearAllAuthorizationStates()

{@inheritdoc}

void
set_user_id(int $user_id)

Updates the user_id field in the database associated with the token.

bool
has_access_token_by_session(string $service)

Checks to see if an access token exists solely by the session_id of the user.

bool
has_state_by_session(string $service)

Checks to see if a state exists solely by the session_id of the user.

bool
has_access_token(array $data)

A helper function that performs the query for has access token functions.

TokenInterface
retrieve_access_token_by_session(string $service)

A helper function that performs the query for retrieving access token functions by session.

string
retrieve_state_by_session(string $service)

A helper function that performs the query for retrieving state functions by session.

TokenInterface
_retrieve_access_token(array $data)

A helper function that performs the query for retrieve access token functions.

string
_retrieve_state(array $data)

A helper function that performs the query for retrieve state functions.

array|false
get_access_token_row(array $data)

A helper function that performs the query for retrieving an access token.

array|false
get_state_row(array $data)

A helper function that performs the query for retrieving a state.

string
json_encode_token(TokenInterface $token)

A helper function that JSON encodes a TokenInterface's data.

TokenInterface
json_decode_token(string $json)

A helper function that JSON decodes a data string and creates a TokenInterface.

string
get_service_name_for_db(string $provider)

Returns the service name as it must be stored in the database.

Details

at line 53
__construct(driver_interface $db, user $user, string $oauth_token_table, string $oauth_state_table)

Constructor.

Parameters

driver_interface $db

Database object

user $user

User object

string $oauth_token_table

OAuth table: token storage

string $oauth_state_table

OAuth table: state

at line 65
retrieveAccessToken($service)

{@inheritdoc}

Parameters

$service

at line 90
storeAccessToken($service, TokenInterface $token)

{@inheritdoc}

Parameters

$service
TokenInterface $token

at line 132
hasAccessToken($service)

{@inheritdoc}

Parameters

$service

at line 157
clearToken($service)

{@inheritdoc}

Parameters

$service

at line 180
clearAllTokens()

{@inheritdoc}

at line 200
storeAuthorizationState($service, $state)

{@inheritdoc}

Parameters

$service
$state

at line 222
hasAuthorizationState($service)

{@inheritdoc}

Parameters

$service

at line 247
retrieveAuthorizationState($service)

{@inheritdoc}

Parameters

$service

at line 272
clearAuthorizationState($service)

{@inheritdoc}

Parameters

$service

at line 295
clearAllAuthorizationStates()

{@inheritdoc}

at line 318
void set_user_id(int $user_id)

Updates the user_id field in the database associated with the token.

Parameters

int $user_id

The user identifier

Return Value

void

at line 343
bool has_access_token_by_session(string $service)

Checks to see if an access token exists solely by the session_id of the user.

Parameters

string $service

The OAuth service name

Return Value

bool

true if the user's access token exists, false if the user's access token does not exist

at line 367
bool has_state_by_session(string $service)

Checks to see if a state exists solely by the session_id of the user.

Parameters

string $service

The OAuth service name

Return Value

bool

true if the user's state exists, false if the user's state does not exist

at line 391
protected bool has_access_token(array $data)

A helper function that performs the query for has access token functions.

Parameters

array $data

The SQL WHERE data

Return Value

bool

true if the user's access token exists, false if the user's access token does not exist

at line 404
TokenInterface retrieve_access_token_by_session(string $service)

A helper function that performs the query for retrieving access token functions by session.

Also checks if the token is a valid token.

Parameters

string $service

The OAuth service provider name

Return Value

TokenInterface

Exceptions

TokenNotFoundException

at line 428
string retrieve_state_by_session(string $service)

A helper function that performs the query for retrieving state functions by session.

Parameters

string $service

The OAuth service provider name

Return Value

string

The OAuth state

Exceptions

AuthorizationStateNotFoundException

at line 453
protected TokenInterface _retrieve_access_token(array $data)

A helper function that performs the query for retrieve access token functions.

Also checks if the token is a valid token.

Parameters

array $data

The SQL WHERE data

Return Value

TokenInterface

Exceptions

TokenNotFoundException

at line 484
protected string _retrieve_state(array $data)

A helper function that performs the query for retrieve state functions.

Parameters

array $data

The SQL WHERE data

Return Value

string

The OAuth state

Exceptions

AuthorizationStateNotFoundException

at line 505
protected array|false get_access_token_row(array $data)

A helper function that performs the query for retrieving an access token.

Parameters

array $data

The SQL WHERE data

Return Value

array|false

array with the OAuth token row, false if the token does not exist

at line 524
protected array|false get_state_row(array $data)

A helper function that performs the query for retrieving a state.

Parameters

array $data

The SQL WHERE data

Return Value

array|false

array with the OAuth state row, false if the state does not exist

at line 542
string json_encode_token(TokenInterface $token)

A helper function that JSON encodes a TokenInterface's data.

Parameters

TokenInterface $token

Return Value

string

The json encoded TokenInterface's data

at line 571
TokenInterface json_decode_token(string $json)

A helper function that JSON decodes a data string and creates a TokenInterface.

Parameters

string $json

The json encoded TokenInterface's data

Return Value

TokenInterface

Exceptions

TokenNotFoundException

at line 610
protected string get_service_name_for_db(string $provider)

Returns the service name as it must be stored in the database.

Parameters

string $provider

The OAuth provider name

Return Value

string

The OAuth service name