PHP Class CakeDC\Users\Auth\SocialAuthenticate

Inheritance: extends Cake\Auth\BaseAuthenticate
Show file Open project: cakedc/users

Protected Properties

Property Type Description
$_provider League\OAuth2\Client\Provider\AbstractProvider Instance of OAuth2 provider.

Public Methods

Method Description
__construct ( Cake\Controller\ComponentRegistry $registry, array $config = [] ) Constructor
authenticate ( Cake\Network\Request $request, Response $response ) : boolean Get a user based on information in the request.
getUser ( Cake\Network\Request $request ) : mixed Get a user based on information in the request.
normalizeConfig ( array $config ) : array Normalizes providers' configuration.
provider ( Cake\Network\Request $request ) : League\Oauth2\Client\Provider\GenericProvider | false Returns the $request-ed provider.
unauthenticated ( Cake\Network\Request $request, Response $response ) : Response | null Handles unauthenticated access attempts. Will automatically forward to the requested provider's authorization URL to let the user grant access to the application.

Protected Methods

Method Description
_authenticate ( Cake\Network\Request $request ) : array | boolean Authenticates with OAuth2 provider by getting an access token and retrieving the authorized user's profile data.
_getController ( ) : Controller Get the controller associated with the collection.
_getProvider ( string $alias ) : League\Oauth2\Client\Provider\GenericProvider Instantiates provider object.
_getProviderName ( Cake\Network\Request $request = null ) : mixed Get the provider name based on the request or on the provider set.
_map ( array $data ) : array Maps raw provider's user profile data to local user's data schema.
_mapUser ( string $provider, array $data ) : mixed Get the provider name based on the request or on the provider set.
_normalizeConfig ( array &$config, string $alias, array $parent ) : void Callback to loop through config values.
_socialLogin ( mixed $data ) : mixed
_touch ( array $data ) : array | boolean | mixed Find or create local user
_validate ( Cake\Network\Request $request ) : boolean Validates OAuth2 request.
_validateConfig ( mixed &$value, string $key ) : void Validates the configuration.

Method Details

__construct() public method

Constructor
public __construct ( Cake\Controller\ComponentRegistry $registry, array $config = [] )
$registry Cake\Controller\ComponentRegistry The Component registry used on this request.
$config array Array of config to use.

_authenticate() protected method

Authenticates with OAuth2 provider by getting an access token and retrieving the authorized user's profile data.
protected _authenticate ( Cake\Network\Request $request ) : array | boolean
$request Cake\Network\Request Request object.
return array | boolean

_getController() protected method

Get the controller associated with the collection.
protected _getController ( ) : Controller
return Cake\Controller\Controller Controller instance

_getProvider() protected method

Instantiates provider object.
protected _getProvider ( string $alias ) : League\Oauth2\Client\Provider\GenericProvider
$alias string of the provider.
return League\Oauth2\Client\Provider\GenericProvider

_getProviderName() protected method

Get the provider name based on the request or on the provider set.
protected _getProviderName ( Cake\Network\Request $request = null ) : mixed
$request Cake\Network\Request Request object.
return mixed Either false or an array of user information

_map() protected method

Maps raw provider's user profile data to local user's data schema.
protected _map ( array $data ) : array
$data array Raw user data.
return array

_mapUser() protected method

Get the provider name based on the request or on the provider set.
protected _mapUser ( string $provider, array $data ) : mixed
$provider string Provider name.
$data array User data
return mixed Either false or an array of user information

_normalizeConfig() protected method

Callback to loop through config values.
protected _normalizeConfig ( array &$config, string $alias, array $parent ) : void
$config array Configuration.
$alias string Provider's alias (key) in configuration.
$parent array Parent configuration.
return void

_socialLogin() protected method

protected _socialLogin ( mixed $data ) : mixed
$data mixed data
return mixed

_touch() protected method

Find or create local user
protected _touch ( array $data ) : array | boolean | mixed
$data array data
return array | boolean | mixed

_validate() protected method

Validates OAuth2 request.
protected _validate ( Cake\Network\Request $request ) : boolean
$request Cake\Network\Request Request object.
return boolean

_validateConfig() protected method

Validates the configuration.
protected _validateConfig ( mixed &$value, string $key ) : void
$value mixed Value.
$key string Key.
return void

authenticate() public method

Get a user based on information in the request.
public authenticate ( Cake\Network\Request $request, Response $response ) : boolean
$request Cake\Network\Request Request object.
$response Cake\Network\Response Response object.
return boolean

getUser() public method

Get a user based on information in the request.
public getUser ( Cake\Network\Request $request ) : mixed
$request Cake\Network\Request Request object.
return mixed Either false or an array of user information

normalizeConfig() public method

Normalizes providers' configuration.
public normalizeConfig ( array $config ) : array
$config array Array of config to normalize.
return array

provider() public method

Returns the $request-ed provider.
public provider ( Cake\Network\Request $request ) : League\Oauth2\Client\Provider\GenericProvider | false
$request Cake\Network\Request Current HTTP request.
return League\Oauth2\Client\Provider\GenericProvider | false

unauthenticated() public method

Handles unauthenticated access attempts. Will automatically forward to the requested provider's authorization URL to let the user grant access to the application.
public unauthenticated ( Cake\Network\Request $request, Response $response ) : Response | null
$request Cake\Network\Request Request object.
$response Cake\Network\Response Response object.
return Cake\Network\Response | null

Property Details

$_provider protected property

Instance of OAuth2 provider.
protected AbstractProvider,League\OAuth2\Client\Provider $_provider
return League\OAuth2\Client\Provider\AbstractProvider