PHP Class EAuthServiceBase

Inheritance: extends CComponent, implements IAuthService
Afficher le fichier Open project: nodge/yii-eauth Class Usage Examples

Protected Properties

Свойство Type Description
$attributes authorization attributes.
$authenticated whether user was successfuly authenticated.
$jsArguments arguments for the jQuery.eauth() javascript function.
$name the service name.
$title the service title to display in views.
$type the service type (e.g. OpenID, OAuth).

Méthodes publiques

Méthode Description
__get ( string $name ) : mixed PHP getter magic method.
__isset ( string $name ) : boolean Checks if a attribute value is null.
authenticate ( ) : boolean Authenticate the user.
cancel ( $url = null ) Redirect to the {@link cancelUrl} or simply close the popup window.
getAttribute ( string $key, mixed $default = null ) : mixed Returns the authorization attribute value.
getAttributes ( ) : array Returns the array that contains all available authorization attributes.
getCancelUrl ( ) : string Returns the redirect url after unsuccessful authorization (e.g. user canceled).
getComponent ( ) : EAuth Returns the {@link EAuth} application component.
getId ( ) : mixed Returns the user unique id.
getIsAuthenticated ( ) : boolean Whether user was successfuly authenticated.
getItem ( ) : stdClass Returns the object with a human-readable representation of the current authorization.
getItemAttributes ( ) : array Returns the array that contains all available authorization attributes.
getJsArguments ( ) : array Returns arguments for the jQuery.eauth() javascript function.
getRedirectUrl ( ) : string Returns the redirect url after successful authorization.
getServiceName ( ) : string Returns service name(id).
getServiceTitle ( ) : string Returns service title.
getServiceType ( ) : string Returns service type (e.g. OpenID, OAuth).
hasAttribute ( string $key ) : boolean Whether the authorization attribute exists.
init ( EAuth $component, array $options = [] ) Initialize the component.
redirect ( string $url = null, array $params = [] ) Redirect to the url. If url is null, {@link redirectUrl} will be used.
setCancelUrl ( $url ) Sets redirect url after unsuccessful authorization (e.g. user canceled).
setComponent ( EAuth $component ) Sets {@link EAuth} application component
setRedirectUrl ( $url ) Sets redirect url after successful authorization.

Méthodes protégées

Méthode Description
_fetchAttributes ( ) Fetch attributes array.
fetchAttributes ( ) : boolean Fetch attributes array.
fetchJsonError ( stdClass $json ) : array Returns the error info from json.
getState ( string $key, mixed $defaultValue = null ) : mixed Returns the value of a variable that is stored in eauth session.
getStateKeyPrefix ( ) : string
hasState ( string $key ) : boolean Returns a value indicating whether there is a state of the specified name.
initRequest ( string $url, array $options = [] ) : cURL Initializes a new session and return a cURL handle.
makeRequest ( string $url, array $options = [], boolean $parseJson = true ) : stdClass Makes the curl request to the url.
parseJson ( string $response ) : object Parse response from {@link makeRequest} in json format and check OAuth errors.
setState ( string $key, mixed $value, mixed $defaultValue = null ) Stores a variable in eauth session.

Method Details

__get() public méthode

This method is overridden so that service attributes can be accessed like properties.
See also: getAttribute
public __get ( string $name ) : mixed
$name string property name.
Résultat mixed property value.

__isset() public méthode

This method overrides the parent implementation by checking if the attribute is null or not.
public __isset ( string $name ) : boolean
$name string the attribute name.
Résultat boolean whether the attribute value is null.

_fetchAttributes() protected méthode

This function is internally used to handle fetched state.
protected _fetchAttributes ( )

authenticate() public méthode

Authenticate the user.
public authenticate ( ) : boolean
Résultat boolean whether user was successfuly authenticated.

cancel() public méthode

Redirect to the {@link cancelUrl} or simply close the popup window.
public cancel ( $url = null )

fetchAttributes() protected méthode

Fetch attributes array.
protected fetchAttributes ( ) : boolean
Résultat boolean whether the attributes was successfully fetched.

fetchJsonError() protected méthode

Returns the error info from json.
protected fetchJsonError ( stdClass $json ) : array
$json stdClass the json response.
Résultat array the error array with 2 keys: code and message. Should be null if no errors.

getAttribute() public méthode

Returns the authorization attribute value.
public getAttribute ( string $key, mixed $default = null ) : mixed
$key string the attribute name.
$default mixed the default value.
Résultat mixed the attribute value.

getAttributes() public méthode

Returns the array that contains all available authorization attributes.
public getAttributes ( ) : array
Résultat array the attributes.

getCancelUrl() public méthode

Returns the redirect url after unsuccessful authorization (e.g. user canceled).
public getCancelUrl ( ) : string
Résultat string the redirect url after unsuccessful authorization (e.g. user canceled).

getComponent() public méthode

Returns the {@link EAuth} application component.
public getComponent ( ) : EAuth
Résultat EAuth the {@link EAuth} application component.

getId() public méthode

Returns the user unique id.
public getId ( ) : mixed
Résultat mixed the user id.

getIsAuthenticated() public méthode

Whether user was successfuly authenticated.
public getIsAuthenticated ( ) : boolean
Résultat boolean whether user was successfuly authenticated.

getItem() public méthode

Returns the object with a human-readable representation of the current authorization.
public getItem ( ) : stdClass
Résultat stdClass the object.

getItemAttributes() public méthode

Returns the array that contains all available authorization attributes.
Deprecation: because getAttributes is more semantic.
public getItemAttributes ( ) : array
Résultat array the attributes.

getJsArguments() public méthode

Returns arguments for the jQuery.eauth() javascript function.
public getJsArguments ( ) : array
Résultat array the arguments for the jQuery.eauth() javascript function.

getRedirectUrl() public méthode

Returns the redirect url after successful authorization.
public getRedirectUrl ( ) : string
Résultat string the redirect url after successful authorization.

getServiceName() public méthode

Returns service name(id).
public getServiceName ( ) : string
Résultat string the service name(id).

getServiceTitle() public méthode

Returns service title.
public getServiceTitle ( ) : string
Résultat string the service title.

getServiceType() public méthode

Returns service type (e.g. OpenID, OAuth).
public getServiceType ( ) : string
Résultat string the service type (e.g. OpenID, OAuth).

getState() protected méthode

Returns the value of a variable that is stored in eauth session.
See also: setState
protected getState ( string $key, mixed $defaultValue = null ) : mixed
$key string variable name.
$defaultValue mixed default value.
Résultat mixed the value of the variable. If it doesn't exist in the session, the provided default value will be returned.

getStateKeyPrefix() protected méthode

protected getStateKeyPrefix ( ) : string
Résultat string a prefix for the name of the session variables storing eauth session data.

hasAttribute() public méthode

Whether the authorization attribute exists.
public hasAttribute ( string $key ) : boolean
$key string the attribute name.
Résultat boolean true if attribute exists, false otherwise.

hasState() protected méthode

Returns a value indicating whether there is a state of the specified name.
protected hasState ( string $key ) : boolean
$key string state name.
Résultat boolean whether there is a state of the specified name.

init() public méthode

Sets the default {@link redirectUrl} and {@link cancelUrl}.
public init ( EAuth $component, array $options = [] )
$component EAuth the component instance.
$options array properties initialization.

initRequest() protected méthode

Initializes a new session and return a cURL handle.
protected initRequest ( string $url, array $options = [] ) : cURL
$url string url to request.
$options array HTTP request options. Keys: query, data, referer.
Résultat cURL handle.

makeRequest() protected méthode

Makes the curl request to the url.
protected makeRequest ( string $url, array $options = [], boolean $parseJson = true ) : stdClass
$url string url to request.
$options array HTTP request options. Keys: query, data, referer.
$parseJson boolean Whether to parse response in json format.
Résultat stdClass the response.

parseJson() protected méthode

Parse response from {@link makeRequest} in json format and check OAuth errors.
protected parseJson ( string $response ) : object
$response string Json string.
Résultat object result.

redirect() public méthode

Redirect to the url. If url is null, {@link redirectUrl} will be used.
public redirect ( string $url = null, array $params = [] )
$url string url to redirect.
$params array

setCancelUrl() public méthode

Sets redirect url after unsuccessful authorization (e.g. user canceled).
public setCancelUrl ( $url )

setComponent() public méthode

Sets {@link EAuth} application component
public setComponent ( EAuth $component )
$component EAuth the application auth component.

setRedirectUrl() public méthode

Sets redirect url after successful authorization.
public setRedirectUrl ( $url )

setState() protected méthode

Stores a variable in eauth session.
See also: getState
protected setState ( string $key, mixed $value, mixed $defaultValue = null )
$key string variable name.
$value mixed variable value.
$defaultValue mixed default value. If $value===$defaultValue, the variable will be removed from the session.

Property Details

$attributes protected_oe property

authorization attributes.
See also: getAttribute
See also: getItem
protected $attributes

$authenticated protected_oe property

whether user was successfuly authenticated.
See also: getIsAuthenticated
protected $authenticated

$jsArguments protected_oe property

arguments for the jQuery.eauth() javascript function.
protected $jsArguments

$name protected_oe property

the service name.
protected $name

$title protected_oe property

the service title to display in views.
protected $title

$type protected_oe property

the service type (e.g. OpenID, OAuth).
protected $type