Documentation

Database
in package

Provides functions to saves and retrieves data from a SQLite storage database for OP

Table of Contents

__construct()  : Database
creates a new Database instance
checkAccessToken()  : bool
check if the access_token exists
checkAuthorizationCode()  : bool
check if exists a request with the specified authorization code for that client_id and redirect_uri
checkIdToken()  : bool
check if the id_token exists
createAccessToken()  : string
create a new access token for the request identified by authorization code
createAuthorizationCode()  : string
update a request record generating the authcode for the request
createRequest()  : string
creates a record from an authentication request
deleteRequest()  : mixed
delete the request
dump()  : array<string|int, mixed>
executes a dump of a table
exec()  : array<string|int, mixed>
executes a SQL query to upsert values (INSERT, UPDATE)
getRequest()  : array<string|int, mixed>
retrieve a record of an authentication request
getRequestByClientID()  : array<string|int, mixed>
retrieve all records of authentication requests by client_id
getRequestByCode()  : array<string|int, mixed>
retrieve a record of an authentication request by authcode
getRequestByIdToken()  : array<string|int, mixed>
retrieve a record of an authentication request by id_token
getUserinfo()  : array<string|int, mixed>
get user info for the access_token
log()  : mixed
saves a record on the log table
query()  : array<string|int, mixed>
executes a SQL query to retrieve values (SELECT)
saveAccessToken()  : mixed
save the provided access_token for the request
saveIdToken()  : mixed
save id_token for the request
saveUserinfo()  : mixed
save user info for the request
updateRequest()  : string
updates a record of an authentication request

Methods

__construct()

creates a new Database instance

public __construct(string $db_file) : Database
Parameters
$db_file : string

path of sqlite file

Tags
throws
Exception
Return values
Database

checkAccessToken()

check if the access_token exists

public checkAccessToken(string $access_token) : bool
Parameters
$access_token : string

the access_token

Tags
throws
Exception
Return values
bool

true if the access_token exists

checkAuthorizationCode()

check if exists a request with the specified authorization code for that client_id and redirect_uri

public checkAuthorizationCode(string $client_id, string $redirect_uri, string $code) : bool
Parameters
$client_id : string

the client id

$redirect_uri : string

the redirect uri

$code : string

the authroization code

Tags
throws
Exception
Return values
bool

true if the auth code exists

checkIdToken()

check if the id_token exists

public checkIdToken(string $id_token) : bool
Parameters
$id_token : string

the id_token

Tags
throws
Exception
Return values
bool

true if the id_token exists

createAccessToken()

create a new access token for the request identified by authorization code

public createAccessToken(string $code) : string
Parameters
$code : string

the authcode

Tags
throws
Exception
Return values
string

the generated access_token

createAuthorizationCode()

update a request record generating the authcode for the request

public createAuthorizationCode(string $req_id) : string
Parameters
$req_id : string

the request id

Tags
throws
Exception
Return values
string

the generated authcode

createRequest()

creates a record from an authentication request

public createRequest(string $client_id, string $redirect_uri[, string $state = '' ][, string $nonce = '' ]) : string
Parameters
$client_id : string

id of the client

$redirect_uri : string

URL to which return after authentication

$state : string = ''

value of the state param sent with the request

$nonce : string = ''

value of the nonce param sent with the request

Tags
throws
Exception
Return values
string

the request id

deleteRequest()

delete the request

public deleteRequest(string $req_id) : mixed
Parameters
$req_id : string

the request id

Tags
throws
Exception
Return values
mixed

dump()

executes a dump of a table

public dump(string $table) : array<string|int, mixed>
Parameters
$table : string

the name of the table to dump

Tags
throws
Exception
Return values
array<string|int, mixed>

result of the dump

exec()

executes a SQL query to upsert values (INSERT, UPDATE)

public exec(string $sql[, array<string|int, string> $values = array() ]) : array<string|int, mixed>
Parameters
$sql : string

the SQL prepared query to execute

$values : array<string|int, string> = array()

values to bind on the query

Tags
throws
Exception
Return values
array<string|int, mixed>

result of the query

getRequest()

retrieve a record of an authentication request

public getRequest(string $req_id) : array<string|int, mixed>
Parameters
$req_id : string

id of the authentication request

Tags
throws
Exception
Return values
array<string|int, mixed>

the request

getRequestByClientID()

retrieve all records of authentication requests by client_id

public getRequestByClientID(string $client_id) : array<string|int, mixed>
Parameters
$client_id : string

the client_id

Tags
throws
Exception
Return values
array<string|int, mixed>

the requests

getRequestByCode()

retrieve a record of an authentication request by authcode

public getRequestByCode(string $code) : array<string|int, mixed>
Parameters
$code : string

the authcode of the authentication request

Tags
throws
Exception
Return values
array<string|int, mixed>

the request

getRequestByIdToken()

retrieve a record of an authentication request by id_token

public getRequestByIdToken(string $id_token) : array<string|int, mixed>
Parameters
$id_token : string

the id_token of the authentication request

Tags
throws
Exception
Return values
array<string|int, mixed>

the request

getUserinfo()

get user info for the access_token

public getUserinfo(string $access_token) : array<string|int, mixed>
Parameters
$access_token : string

the access_token

Tags
throws
Exception
Return values
array<string|int, mixed>

$userinfo the user info

log()

saves a record on the log table

public log(string $context, string $tag[, mixed $value = '' ][, string $severity = 'INFO' ]) : mixed
Parameters
$context : string

context for the log record

$tag : string

tag for the log record

$value : mixed = ''

value for the log record

$severity : string = 'INFO'

[DEBUG, INFO, NOTICE, WARNING, ERROR, CRITICAL]

Tags
throws
Exception
Return values
mixed

query()

executes a SQL query to retrieve values (SELECT)

public query(string $sql[, array<string|int, string> $values = array() ]) : array<string|int, mixed>
Parameters
$sql : string

the SQL prepared query to execute (es. SELECT * FROM request WHERE code_verifier = :code_verifier)

$values : array<string|int, string> = array()

values to bind on the query

Tags
throws
Exception
Return values
array<string|int, mixed>

result of the query

saveAccessToken()

save the provided access_token for the request

public saveAccessToken(string $req_id, string $access_token) : mixed
Parameters
$req_id : string

the request id

$access_token : string

the access_token

Tags
throws
Exception
Return values
mixed

saveIdToken()

save id_token for the request

public saveIdToken(string $req_id, string $id_token) : mixed
Parameters
$req_id : string

the request id

$id_token : string

the id_token to save

Tags
throws
Exception
Return values
mixed

saveUserinfo()

save user info for the request

public saveUserinfo(string $req_id, array<string|int, mixed> $userinfo) : mixed
Parameters
$req_id : string

the request id

$userinfo : array<string|int, mixed>

the user info

Tags
throws
Exception
Return values
mixed

updateRequest()

updates a record of an authentication request

public updateRequest(string $client_id, string $redirect_uri[, string $state = '' ][, string $nonce = '' ]) : string
Parameters
$client_id : string

id of the client

$redirect_uri : string

URL to which return after authentication

$state : string = ''

value of the state param sent with the request

$nonce : string = ''

value of the nonce param sent with the request

Tags
throws
Exception
Return values
string

the request id

Search results