Documentation

FileStorage extends OAuthStorageAbstract
in package

Implements a filesystem storage adapter.

Please note that the storage root directory needs permissions 0777 or is_writable() will fail. Subfolders created by this class will have permissions set to 0755.

Tags
see
is_writable()
see
OAuthOptions::$fileStoragePath

Table of Contents

Constants

ENCRYPT_FORMAT  = \chillerlan\Utilities\Crypto::ENCRYPT_FORMAT_BINARY
Output format for encrypted data
KEY_STATE  = 'STATE'
KEY_TOKEN  = 'TOKEN'
KEY_VERIFIER  = 'VERIFIER'

Properties

$logger  : LoggerInterface
A PSR-3 logger
$oauthUser  : string|int
A *unique* ID to identify the user within your application, e.g. database row id or UUID
$options  : OAuthOptions|SettingsContainerInterface
The options instance

Methods

__construct()  : mixed
OAuthStorageAbstract constructor.
clearAccessToken()  : static
Deletes the access token for a given $provider (and current user)
clearAllAccessTokens()  : static
Deletes all access tokens (for the current user)
clearAllCodeVerifiers()  : static
Deletes all PKCE verifiers for this user
clearAllCSRFStates()  : static
Deletes all stored CSRF states (for the current user)
clearCodeVerifier()  : static
Deletes a PKCE verifier
clearCSRFState()  : static
Deletes a CSRF state for the given $provider (and current user)
fromStorage()  : AccessToken
Retrieves token JOSN from the underlying storage engine and returns an AccessToken
getAccessToken()  : AccessToken
Retrieves an AccessToken for the given $provider
getCodeVerifier()  : string
Retrieves a PKCE verifier
getCSRFState()  : string
Retrieves a CSRF <state> value for the given $provider
hasAccessToken()  : bool
Checks if a token for $provider exists
hasCodeVerifier()  : bool
Checks whether a PKCE verifier exists
hasCSRFState()  : bool
Checks if a CSRF state for the given provider exists
setLogger()  : static
Sets a logger. (LoggerAwareInterface is stupid)
storeAccessToken()  : static
Stores an AccessToken for the given $provider
storeCodeVerifier()  : static
Stores a PKCE verifier
storeCSRFState()  : static
Stores a CSRF <state> value for the given $provider
toStorage()  : mixed
Prepares an AccessToken for storage (serialize, encrypt etc.) and returns a value that is suited for the underlying storage engine
decrypt()  : string
decrypts the given $encrypted data
deleteAll()  : void
deletes all matching files
deleteFile()  : void
deletes an existing file
encrypt()  : string
encrypts the given $data
getFilepath()  : string
gets the file path for $key (token/state), $provider and the given oauth user ID
getProviderName()  : string
Gets the current provider name
loadFile()  : string
fetched the content from a file
saveFile()  : void
saves the given data to a file

Constants

ENCRYPT_FORMAT

Output format for encrypted data

protected final int ENCRYPT_FORMAT = \chillerlan\Utilities\Crypto::ENCRYPT_FORMAT_BINARY

Properties

$oauthUser

A *unique* ID to identify the user within your application, e.g. database row id or UUID

protected string|int $oauthUser

Methods

__construct()

OAuthStorageAbstract constructor.

public __construct(string|int $oauthUser[, OAuthOptions|SettingsContainerInterface $options = new OAuthOptions() ][, LoggerInterface $logger = new NullLogger() ]) : mixed
Parameters
$oauthUser : string|int
$options : OAuthOptions|SettingsContainerInterface = new OAuthOptions()
$logger : LoggerInterface = new NullLogger()

clearAccessToken()

Deletes the access token for a given $provider (and current user)

public clearAccessToken(string $provider) : static
Parameters
$provider : string
Return values
static

clearAllAccessTokens()

Deletes all access tokens (for the current user)

public clearAllAccessTokens() : static
Return values
static

clearAllCodeVerifiers()

Deletes all PKCE verifiers for this user

public clearAllCodeVerifiers() : static
Return values
static

clearAllCSRFStates()

Deletes all stored CSRF states (for the current user)

public clearAllCSRFStates() : static
Return values
static

clearCodeVerifier()

Deletes a PKCE verifier

public clearCodeVerifier(string $provider) : static
Parameters
$provider : string
Return values
static

clearCSRFState()

Deletes a CSRF state for the given $provider (and current user)

public clearCSRFState(string $provider) : static
Parameters
$provider : string
Return values
static

getAccessToken()

Retrieves an AccessToken for the given $provider

public getAccessToken(string $provider) : AccessToken

This method must throw a ItemNotFoundException if a token is not found

Parameters
$provider : string
Return values
AccessToken

getCodeVerifier()

Retrieves a PKCE verifier

public getCodeVerifier(string $provider) : string

This method must throw a ItemNotFoundException if a verifier is not found

Parameters
$provider : string
Return values
string

getCSRFState()

Retrieves a CSRF <state> value for the given $provider

public getCSRFState(string $provider) : string

This method must throw a ItemNotFoundException if a state is not found

Parameters
$provider : string
Return values
string

hasAccessToken()

Checks if a token for $provider exists

public hasAccessToken(string $provider) : bool
Parameters
$provider : string
Return values
bool

hasCodeVerifier()

Checks whether a PKCE verifier exists

public hasCodeVerifier(string $provider) : bool
Parameters
$provider : string
Return values
bool

hasCSRFState()

Checks if a CSRF state for the given provider exists

public hasCSRFState(string $provider) : bool
Parameters
$provider : string
Return values
bool

setLogger()

Sets a logger. (LoggerAwareInterface is stupid)

public setLogger(LoggerInterface $logger) : static
Parameters
$logger : LoggerInterface
Tags
codeCoverageIgnore
Return values
static

storeAccessToken()

Stores an AccessToken for the given $provider

public storeAccessToken(AccessToken $token, string $provider) : static
Parameters
$token : AccessToken
$provider : string
Return values
static

storeCodeVerifier()

Stores a PKCE verifier

public storeCodeVerifier(string $verifier, string $provider) : static
Parameters
$verifier : string
$provider : string
Return values
static

storeCSRFState()

Stores a CSRF <state> value for the given $provider

public storeCSRFState(string $state, string $provider) : static
Parameters
$state : string
$provider : string
Return values
static

toStorage()

Prepares an AccessToken for storage (serialize, encrypt etc.) and returns a value that is suited for the underlying storage engine

public toStorage(AccessToken $token) : mixed
Parameters
$token : AccessToken

decrypt()

decrypts the given $encrypted data

protected decrypt(string $encrypted) : string
Parameters
$encrypted : string
Return values
string

deleteAll()

deletes all matching files

protected deleteAll(string $key) : void
Parameters
$key : string

deleteFile()

deletes an existing file

protected deleteFile(string $key, string $provider) : void
Parameters
$key : string
$provider : string

encrypt()

encrypts the given $data

protected encrypt(string $data) : string
Parameters
$data : string
Return values
string

getFilepath()

gets the file path for $key (token/state), $provider and the given oauth user ID

protected getFilepath(string $key, string $provider) : string
Parameters
$key : string
$provider : string
Return values
string

loadFile()

fetched the content from a file

protected loadFile(string $key, string $provider) : string
Parameters
$key : string
$provider : string
Return values
string

saveFile()

saves the given data to a file

protected saveFile(string $data, string $key, string $provider) : void
Parameters
$data : string
$key : string
$provider : string

        
On this page

Search results