PHP Class OpenIDConnectClient

Mostra file Open project: jumbojett/openid-connect-php Class Usage Examples

Public Methods

Method Description
__construct ( $provider_url = null, $client_id = null, $client_secret = null )
addAuthParam ( $param )
addScope ( $scope )
authenticate ( ) : boolean
canVerifySignatures ( ) : boolean
getAccessToken ( ) : string
getAccessTokenHeader ( ) : array
getAccessTokenPayload ( ) : array
getClientID ( ) : string
getClientName ( ) : mixed
getClientSecret ( ) : string
getIdToken ( ) : string
getIdTokenHeader ( ) : array
getIdTokenPayload ( ) : array
getProviderURL ( ) : string
getRedirectURL ( ) : string Gets the URL of the current page we are on, encodes, and returns it
getRefreshToken ( ) : string
getTokenResponse ( ) : array
providerConfigParam ( $array ) Use this to alter a provider's endpoints and other attributes
redirect ( $url )
refreshToken ( $refresh_token ) : mixed Requests Access token with refresh token
register ( ) Dynamic registration
requestUserInfo ( $attribute = null ) : mixed
setCertPath ( $certPath )
setClientID ( $clientID )
setClientName ( $clientName )
setClientSecret ( $clientSecret )
setHttpProxy ( $httpProxy )
setProviderURL ( $provider_url )
setRedirectURL ( $url )
setResponseTypes ( $response_types )

Protected Methods

Method Description
fetchURL ( $url, null $post_body = null, array() $headers = [] ) : mixed
generateRandString ( ) : string Used for arbitrary value generation for nonces and state
getNonce ( ) : string Get stored nonce
getState ( ) : string Get stored state
setNonce ( string $nonce ) : string Stores nonce
setState ( string $state ) : string Stores $state
unsetNonce ( ) : void Cleanup nonce
unsetState ( ) : void Cleanup state
urlEncode ( string $str ) : string

Private Methods

Method Description
decodeJWT ( $jwt, integer $section ) : object
getProviderConfigValue ( $param, $default = null ) : string Get's anything that we need configuration wise including endpoints, and other values
get_key_for_header ( array $keys, array $header ) : object
requestAuthorization ( ) : void Start Here
requestTokens ( $code ) : mixed Requests ID and Access tokens
verifyJWTclaims ( object $claims, $accessToken = null ) : boolean
verifyJWTsignature ( $jwt ) : boolean
verifyRSAJWTsignature ( string $hashtype, object $key, $payload, $signature ) : boolean

Method Details

__construct() public method

public __construct ( $provider_url = null, $client_id = null, $client_secret = null )
$provider_url string optional
$client_id string optional
$client_secret string optional

addAuthParam() public method

public addAuthParam ( $param )
$param - example: prompt=login

addScope() public method

public addScope ( $scope )
$scope - example: openid, given_name, etc...

authenticate() public method

public authenticate ( ) : boolean
return boolean

canVerifySignatures() public method

public canVerifySignatures ( ) : boolean
return boolean

fetchURL() protected method

protected fetchURL ( $url, null $post_body = null, array() $headers = [] ) : mixed
$url
$post_body null string If this is set the post type will be POST
$headers array()
return mixed

generateRandString() protected method

Used for arbitrary value generation for nonces and state
protected generateRandString ( ) : string
return string

getAccessToken() public method

public getAccessToken ( ) : string
return string

getAccessTokenHeader() public method

public getAccessTokenHeader ( ) : array
return array

getAccessTokenPayload() public method

public getAccessTokenPayload ( ) : array
return array

getClientID() public method

public getClientID ( ) : string
return string

getClientName() public method

public getClientName ( ) : mixed
return mixed

getClientSecret() public method

public getClientSecret ( ) : string
return string

getIdToken() public method

public getIdToken ( ) : string
return string

getIdTokenHeader() public method

public getIdTokenHeader ( ) : array
return array

getIdTokenPayload() public method

public getIdTokenPayload ( ) : array
return array

getNonce() protected method

Get stored nonce
protected getNonce ( ) : string
return string

getProviderURL() public method

public getProviderURL ( ) : string
return string

getRedirectURL() public method

Gets the URL of the current page we are on, encodes, and returns it
public getRedirectURL ( ) : string
return string

getRefreshToken() public method

public getRefreshToken ( ) : string
return string

getState() protected method

Get stored state
protected getState ( ) : string
return string

getTokenResponse() public method

public getTokenResponse ( ) : array
return array

providerConfigParam() public method

Use this to alter a provider's endpoints and other attributes
public providerConfigParam ( $array )
$array simple key => value

redirect() public method

public redirect ( $url )
$url

refreshToken() public method

Requests Access token with refresh token
public refreshToken ( $refresh_token ) : mixed
return mixed

register() public method

Dynamic registration
public register ( )

requestUserInfo() public method

public requestUserInfo ( $attribute = null ) : mixed
$attribute string optional Attribute Type Description user_id string REQUIRED Identifier for the End-User at the Issuer. name string End-User's full name in displayable form including all name parts, ordered according to End-User's locale and preferences. given_name string Given name or first name of the End-User. family_name string Surname or last name of the End-User. middle_name string Middle name of the End-User. nickname string Casual name of the End-User that may or may not be the same as the given_name. For instance, a nickname value of Mike might be returned alongside a given_name value of Michael. profile string URL of End-User's profile page. picture string URL of the End-User's profile picture. website string URL of End-User's web page or blog. email string The End-User's preferred e-mail address. verified boolean True if the End-User's e-mail address has been verified; otherwise false. gender string The End-User's gender: Values defined by this specification are female and male. Other values MAY be used when neither of the defined values are applicable. birthday string The End-User's birthday, represented as a date string in MM/DD/YYYY format. The year MAY be 0000, indicating that it is omitted. zoneinfo string String from zoneinfo [zoneinfo] time zone database. For example, Europe/Paris or America/Los_Angeles. locale string The End-User's locale, represented as a BCP47 [RFC5646] language tag. This is typically an ISO 639-1 Alpha-2 [ISO639‑1] language code in lowercase and an ISO 3166-1 Alpha-2 [ISO3166‑1] country code in uppercase, separated by a dash. For example, en-US or fr-CA. As a compatibility note, some implementations have used an underscore as the separator rather than a dash, for example, en_US; Implementations MAY choose to accept this locale syntax as well. phone_number string The End-User's preferred telephone number. E.164 [E.164] is RECOMMENDED as the format of this Claim. For example, +1 (425) 555-1212 or +56 (2) 687 2400. address JSON object The End-User's preferred address. The value of the address member is a JSON [RFC4627] structure containing some or all of the members defined in Section 2.4.2.1. updated_time string Time the End-User's information was last updated, represented as a RFC 3339 [RFC3339] datetime. For example, 2011-01-03T23:58:42+0000.
return mixed

setCertPath() public method

public setCertPath ( $certPath )
$certPath

setClientID() public method

public setClientID ( $clientID )
$clientID

setClientName() public method

public setClientName ( $clientName )
$clientName

setClientSecret() public method

public setClientSecret ( $clientSecret )
$clientSecret

setHttpProxy() public method

public setHttpProxy ( $httpProxy )
$httpProxy

setNonce() protected method

Stores nonce
protected setNonce ( string $nonce ) : string
$nonce string
return string

setProviderURL() public method

public setProviderURL ( $provider_url )
$provider_url

setRedirectURL() public method

public setRedirectURL ( $url )
$url Sets redirect URL for auth flow

setResponseTypes() public method

public setResponseTypes ( $response_types )
$response_types

setState() protected method

Stores $state
protected setState ( string $state ) : string
$state string
return string

unsetNonce() protected method

Cleanup nonce
protected unsetNonce ( ) : void
return void

unsetState() protected method

Cleanup state
protected unsetState ( ) : void
return void

urlEncode() protected method

protected urlEncode ( string $str ) : string
$str string
return string