class OAuthClient

Class OAuthClient

Constants

GENERAL_ADMIN_MODE

will be saved as user_id in oauth_access dbtable

Properties

protected string $clientId

The application's Client ID.

protected string $clientSecret

The application's Client Secret.

protected string $redirectUrl

The URL to which Auth will redirect the browser after authorization has been granted by the user.

protected string $authorizeUrl

The Authorization Endpoint performs Authentication of the End-User.

protected string $accessTokenUrl

To obtain an Access Token, an ID Token, and optionally a Refresh Token, the RP (Client) sends a Token Request to the Token Endpoint to obtain a Token Response

protected string $endSessionUrl

A URL where you can end a session by revoking an access_token.

protected string|null $jwksUrl
protected string|null $issuerUrl
protected string|null $userinfoEndpointUrl
protected string $scope

The scopes which you want to request authorization for.

protected string $state

An opaque value the application adds to the initial request that Auth includes when redirecting back to the application.

protected AccessToken $accessToken

Access token Object representing string like accessToken an authorization issued to the client refreshToken see refreshToken

protected string $refreshToken

Refresh tokens are issued to the client by the authorization server and are used to obtain a new access token when the current access token becomes invalid or expires

protected int $expires

The lifetime in seconds of the access token

protected string $code

The authorization code received from the authorization server

protected $resourceOwner
protected bool $isPersonal

false = Admin has created account

Methods

__construct(string $clientId = null, string $clientSecret = null, string $redirectUrl = null)

OAuthClient constructor.

addScope($scope)

Adds a new scope to the existing scopes.

disconnect(string $redirect_url)

Logout

fromArray(array $data)

No description

AccessToken
getAccessToken()

Function to test connection directly to an oauth server

string
getAccessTokenAsString()

No description

mixed
getAccessTokenUrl()

No description

string
getAuthorizationUrl()

Start Authorization Code Grant flow (redirect to authorizeUrl)

mixed
getAuthorizeUrl()

No description

string
getClientId()

Get application's Client ID.

string
getClientSecret()

Get application's Client Secret

string
getCode()

No description

string
getEndSessionUrl()

No description

int
getExpires()

No description

string|null
getIdToken()

Get potential ID Token (OIDC)

string|null
getIssuerUrl()

No description

string|null
getJwksUrl()

No description

string
getPostLogoutRedirectUrl(string $redirect_url)

No description

string
getRedirectUrl()

No description

string
getRefreshToken()

No description

string
getScope()

No description

array
getScopeArray()

Returns the scope as array.

string
getState()

No description

string|null
getUserinfoEndpointUrl()

No description

int
hasExpired()

No description

bool
isConnected()

Prove connection within xelos intranet to avoid to much request to an oauth server

bool
isPersonal()

No description

bool
isSendBasicAuthorization()

No description

bool
processAuthorizationCodeResponse(string $code)

Process Authorization Code Grant

processOpenIDConfiguration(OpenIDConfiguration $config)

Use an OpenID Configuration to setup this OAuth client

AccessToken|null
refreshAccessToken()

Returns the access token or null if there is no token yet.

setAccessToken(AccessToken $token = null)

No description

setAccessTokenUrl(mixed $accessTokenUrl)

No description

setAuthorizeUrl(mixed $authorizeUrl)

No description

setClientId(string $clientId)

Set application's Client ID.

setClientSecret(mixed $clientSecret)

Set application's Client Secret

$this
setEndSessionUrl($endSessionEndpoint)

No description

$this
setIssuerUrl(string|null $uri)

No description

$this
setJwksUrl(string|null $uri)

No description

setOptionalAuthParams(array $params)

No description

setPKCEParams(string $codeVerifier, string $codeChallengeMethod = 'S256')

Set Code Verifier and Code Challenge Method for RFC 7636: Proof Key for Code Exchange (PKCE) which is an alternative to client_secret or may be used in hybrid flows

setPersonal(bool $isPersonal = true)

Defines whether the client is for personal or global usage.

setRedirectUrl(string $redirectUrl)

No description

setRefreshToken(string $token)

No description

setResource(null $resource = null)

Set additional resource param when requesting access code

setScope(string $scope)

Set scopes which you want to request authorization for.

setSendBasicAuthorization(bool $sendBasicAuthorization = true)

Should client_id and client_secret be sent as Basic Auth Header during code exchange?

setState(string $state)

No description

$this
setUserinfoEndpointUrl(string|null $uri)

No description

void
startAuthorisationCodeFlow()

Start Authorization Code Grant flow (redirect to authorizeUrl)

array
toArray()

No description

Details

at line 170
__construct(string $clientId = null, string $clientSecret = null, string $redirectUrl = null)

OAuthClient constructor.

Parameters

string $clientId

The application's Client ID.

string $clientSecret

The application's Client Secret.

string $redirectUrl

The URL to which Auth will redirect the browser after authorization has been granted by the user. Will default to webservice OAuth Endpoint

at line 320
OAuthClient addScope($scope)

Adds a new scope to the existing scopes.

Parameters

$scope

Return Value

OAuthClient

at line 397
disconnect(string $redirect_url)

Logout

Parameters

string $redirect_url

Exceptions

Exception

at line 782
OAuthClient fromArray(array $data)

No description

Parameters

array $data

Return Value

OAuthClient

at line 535
protected AccessToken getAccessToken()

internal  
 

Function to test connection directly to an oauth server

Return Value

AccessToken

at line 547
string getAccessTokenAsString()

No description

Return Value

string

Exceptions

IdentityProviderException

at line 270
mixed getAccessTokenUrl()

No description

Return Value

mixed

at line 605
string getAuthorizationUrl()

Start Authorization Code Grant flow (redirect to authorizeUrl)

Return Value

string

Exceptions

Exception

at line 253
mixed getAuthorizeUrl()

No description

Return Value

mixed

at line 196
string getClientId()

Get application's Client ID.

Return Value

string

at line 217
string getClientSecret()

Get application's Client Secret

Return Value

string

at line 386
string getCode()

No description

Return Value

string

at line 416
string getEndSessionUrl()

No description

Return Value

string

at line 372
int getExpires()

No description

Return Value

int

at line 559
string|null getIdToken()

Get potential ID Token (OIDC)

Return Value

string|null

at line 452
string|null getIssuerUrl()

No description

Return Value

string|null

at line 434
string|null getJwksUrl()

No description

Return Value

string|null

at line 408
string getPostLogoutRedirectUrl(string $redirect_url)

No description

Parameters

string $redirect_url

Return Value

string

at line 236
string getRedirectUrl()

No description

Return Value

string

at line 355
string getRefreshToken()

No description

Return Value

string

at line 287
string getScope()

No description

Return Value

string

at line 309
array getScopeArray()

Returns the scope as array.

Return Value

array

at line 338
string getState()

No description

Return Value

string

at line 469
string|null getUserinfoEndpointUrl()

No description

Return Value

string|null

at line 379
int hasExpired()

No description

Return Value

int

at line 490
bool isConnected()

Prove connection within xelos intranet to avoid to much request to an oauth server

Return Value

bool

Exceptions

IdentityProviderException

at line 585
bool isPersonal()

No description

Return Value

bool

at line 855
bool isSendBasicAuthorization()

No description

Return Value

bool

at line 644
bool processAuthorizationCodeResponse(string $code)

Process Authorization Code Grant

Parameters

string $code

Authorization Code

Return Value

bool

at line 182
processOpenIDConfiguration(OpenIDConfiguration $config)

Use an OpenID Configuration to setup this OAuth client

Parameters

OpenIDConfiguration $config

at line 505
AccessToken|null refreshAccessToken()

Returns the access token or null if there is no token yet.

If there is a token and the token is expired, it will automatically request a new access token by using the refresh token.

Return Value

AccessToken|null

Exceptions

IdentityProviderException

at line 572
OAuthClient setAccessToken(AccessToken $token = null)

No description

Parameters

AccessToken $token

Return Value

OAuthClient

at line 279
OAuthClient setAccessTokenUrl(mixed $accessTokenUrl)

No description

Parameters

mixed $accessTokenUrl

Return Value

OAuthClient

at line 262
OAuthClient setAuthorizeUrl(mixed $authorizeUrl)

No description

Parameters

mixed $authorizeUrl

Return Value

OAuthClient

at line 208
OAuthClient setClientId(string $clientId)

Set application's Client ID.

Find this value at your Application's Settings.

Parameters

string $clientId

Return Value

OAuthClient

at line 228
OAuthClient setClientSecret(mixed $clientSecret)

Set application's Client Secret

Parameters

mixed $clientSecret

Return Value

OAuthClient

at line 425
$this setEndSessionUrl($endSessionEndpoint)

No description

Parameters

$endSessionEndpoint

Return Value

$this

at line 461
$this setIssuerUrl(string|null $uri)

No description

Parameters

string|null $uri

Return Value

$this

at line 443
$this setJwksUrl(string|null $uri)

No description

Parameters

string|null $uri

Return Value

$this

at line 330
OAuthClient setOptionalAuthParams(array $params)

No description

Parameters

array $params

Return Value

OAuthClient

at line 879
OAuthClient setPKCEParams(string $codeVerifier, string $codeChallengeMethod = 'S256')

Set Code Verifier and Code Challenge Method for RFC 7636: Proof Key for Code Exchange (PKCE) which is an alternative to client_secret or may be used in hybrid flows

Parameters

string $codeVerifier

Empty will disable PKCE for the process/client

string $codeChallengeMethod

Return Value

OAuthClient

at line 596
OAuthClient setPersonal(bool $isPersonal = true)

Defines whether the client is for personal or global usage.

Parameters

bool $isPersonal

Return Value

OAuthClient

at line 245
OAuthClient setRedirectUrl(string $redirectUrl)

No description

Parameters

string $redirectUrl

Return Value

OAuthClient

at line 364
OAuthClient setRefreshToken(string $token)

No description

Parameters

string $token

Return Value

OAuthClient

at line 847
OAuthClient setResource(null $resource = null)

Set additional resource param when requesting access code

Parameters

null $resource

Return Value

OAuthClient

at line 299
OAuthClient setScope(string $scope)

Set scopes which you want to request authorization for.

These must be separated by a space.

Parameters

string $scope

Return Value

OAuthClient

at line 866
OAuthClient setSendBasicAuthorization(bool $sendBasicAuthorization = true)

Should client_id and client_secret be sent as Basic Auth Header during code exchange?

Parameters

bool $sendBasicAuthorization

Return Value

OAuthClient

at line 347
OAuthClient setState(string $state)

No description

Parameters

string $state

Return Value

OAuthClient

at line 478
$this setUserinfoEndpointUrl(string|null $uri)

No description

Parameters

string|null $uri

Return Value

$this

at line 626
void startAuthorisationCodeFlow()

Start Authorization Code Grant flow (redirect to authorizeUrl)

Return Value

void

Exceptions

Exception

at line 719
array toArray()

No description

Return Value

array