PHP 클래스 OAuthComponent

상속: extends Component, implements IOAuth2Storage, implements IOAuth2RefreshTokens, implements IOAuth2GrantUser, implements IOAuth2GrantCode, implements IOAuth2GrantClient
파일 보기 프로젝트 열기: thomseddon/cakephp-oauth-server 1 사용 예제들

공개 프로퍼티들

프로퍼티 타입 설명
$AccessToken object AccessToken object.
$AuthCode object AuthCode object.
$Client object Clients object.
$OAuth2 object OAuth2 Object
$RefreshToken object RefreshToken object.
$User object User object
$authenticate array Inherits theses defaults: $this->OAuth->authenticate = array( 'userModel' => 'User', 'fields' => array( 'username' => 'username', 'password' => 'password' ) ); Which can be overridden in your beforeFilter: $this->OAuth->authenticate = array( 'fields' => array( 'username' => 'email' ) ); $this->OAuth->authenticate
$grantTypes array By default = array('authorization_code', 'refresh_token', 'password'); Other grant mechanisms are not supported in the current release

보호된 프로퍼티들

프로퍼티 타입 설명
$_authDefaults array Defaults for $authenticate
$_user array Static storage for current user
$allowedActions array Array of allowed actions

공개 메소드들

메소드 설명
__call ( string $name, mixed $arguments ) : mixed Fakes the OAuth2.php vendor class extension for methods
__construct ( ComponentCollection $collection, $settings = [] ) Constructor - Adds class associations
__get ( string $name ) : mixed Fakes the OAuth2.php vendor class extension for variables
allow ( $action = null ) : void Takes a list of actions in the current controller for which authentication is not required, or no parameters to allow all actions.
checkClientCredentials ( string $client_id, string $client_secret = null ) : mixed Check client details are valid
checkRestrictedGrantType ( string $client_id, string $grant_type ) : boolean Partial implementation, just checks globally avaliable grant types
checkUserCredentials ( type $client_id, type $username, type $password ) Grant type: user_credentials
deny ( $action = null ) : void Removes items from the list of allowed/no authentication required actions.
getAccessToken ( string $oauth_token ) : mixed Retrieve access token
getAuthCode ( string $code ) : AuthCode Grant type: authorization_code
getClientDetails ( string $client_id ) : boolean Get client details
getRefreshToken ( string $refresh_token ) : mixed Grant type: refresh_token
hash ( string $password ) : string Convenience function for hashing client_secret (or whatever else)
initialize ( Controller $controller ) : void Initializes OAuthComponent for use in the controller
invalidateUserTokens ( integer $user_id, string $tokens = 'both' ) Convenience function to invalidate all a users tokens, for example when they change their password
isAuthorized ( ) : boolean Checks if user is valid using OAuth2-php library
setAccessToken ( string $oauth_token, string $client_id, integer $user_id, string $expires, string $scope = null ) : boolean Set access token
setAuthCode ( string $code, string $client_id, integer $user_id, string $redirect_uri, string $expires, string $scope = null ) : boolean Grant type: authorization_code
setRefreshToken ( string $refresh_token, integer $client_id, string $user_id, string $expires, string $scope = null ) : boolean Grant type: refresh_token
startup ( Controller $controller ) : boolean Main engine that checks valid access_token and stores the associated user for retrival
unsetRefreshToken ( string $refresh_token ) : boolean Grant type: refresh_token
user ( type $field = null, $token = null ) : mixed Gets the user associated to the current access token.

메소드 상세

__call() 공개 메소드

Fakes the OAuth2.php vendor class extension for methods
public __call ( string $name, mixed $arguments ) : mixed
$name string
$arguments mixed
리턴 mixed

__construct() 공개 메소드

Constructor - Adds class associations
public __construct ( ComponentCollection $collection, $settings = [] )
$collection ComponentCollection

__get() 공개 메소드

Fakes the OAuth2.php vendor class extension for variables
public __get ( string $name ) : mixed
$name string
리턴 mixed

allow() 공개 메소드

You can use allow with either an array, or var args. $this->OAuth->allow(array('edit', 'add')); or $this->OAuth->allow('edit', 'add'); or $this->OAuth->allow(); to allow all actions.
public allow ( $action = null ) : void
리턴 void

checkClientCredentials() 공개 메소드

Check client details are valid
public checkClientCredentials ( string $client_id, string $client_secret = null ) : mixed
$client_id string
$client_secret string
리턴 mixed array of client credentials if valid, false if not

checkRestrictedGrantType() 공개 메소드

Partial implementation, just checks globally avaliable grant types
또한 보기: IOAuth2Storage::checkRestrictedGrantType()
public checkRestrictedGrantType ( string $client_id, string $grant_type ) : boolean
$client_id string
$grant_type string
리턴 boolean If grant type is availiable to client

checkUserCredentials() 공개 메소드

Grant type: user_credentials
또한 보기: IOAuth2GrantUser::checkUserCredentials()
public checkUserCredentials ( type $client_id, type $username, type $password )
$client_id type
$username type
$password type

deny() 공개 메소드

You can use deny with either an array, or var args. $this->OAuth->deny(array('edit', 'add')); or $this->OAuth->deny('edit', 'add'); or $this->OAuth->deny(); to remove all items from the allowed list
또한 보기: OAuthComponent::allow()
public deny ( $action = null ) : void
리턴 void

getAccessToken() 공개 메소드

Retrieve access token
public getAccessToken ( string $oauth_token ) : mixed
$oauth_token string
리턴 mixed AccessToken array if valid, null if not

getAuthCode() 공개 메소드

Grant type: authorization_code
또한 보기: IOAuth2GrantCode::getAuthCode()
public getAuthCode ( string $code ) : AuthCode
$code string
리턴 AuthCode if valid, null of not

getClientDetails() 공개 메소드

Get client details
public getClientDetails ( string $client_id ) : boolean
$client_id string
리턴 boolean

getRefreshToken() 공개 메소드

Grant type: refresh_token
또한 보기: IOAuth2RefreshTokens::getRefreshToken()
public getRefreshToken ( string $refresh_token ) : mixed
$refresh_token string
리턴 mixed RefreshToken if valid, null if not

hash() 공개 정적인 메소드

Convenience function for hashing client_secret (or whatever else)
public static hash ( string $password ) : string
$password string
리턴 string Hashed password

initialize() 공개 메소드

Initializes OAuthComponent for use in the controller
public initialize ( Controller $controller ) : void
$controller Controller A reference to the instantiating controller object
리턴 void

invalidateUserTokens() 공개 메소드

Convenience function to invalidate all a users tokens, for example when they change their password
public invalidateUserTokens ( integer $user_id, string $tokens = 'both' )
$user_id integer
$tokens string 'both' (default) to remove both AccessTokens and RefreshTokens or remove just one type using 'access' or 'refresh'

isAuthorized() 공개 메소드

Checks if user is valid using OAuth2-php library
또한 보기: OAuth2::getBearerToken()
또한 보기: OAuth2::verifyAccessToken()
public isAuthorized ( ) : boolean
리턴 boolean true if carrying valid token, false if not

setAccessToken() 공개 메소드

Set access token
public setAccessToken ( string $oauth_token, string $client_id, integer $user_id, string $expires, string $scope = null ) : boolean
$oauth_token string
$client_id string
$user_id integer
$expires string
$scope string
리턴 boolean true if successfull, false if failed

setAuthCode() 공개 메소드

Grant type: authorization_code
public setAuthCode ( string $code, string $client_id, integer $user_id, string $redirect_uri, string $expires, string $scope = null ) : boolean
$code string
$client_id string
$user_id integer
$redirect_uri string
$expires string
$scope string
리턴 boolean true if successfull, otherwise false

setRefreshToken() 공개 메소드

Grant type: refresh_token
또한 보기: IOAuth2RefreshTokens::setRefreshToken()
public setRefreshToken ( string $refresh_token, integer $client_id, string $user_id, string $expires, string $scope = null ) : boolean
$refresh_token string
$client_id integer
$user_id string
$expires string
$scope string
리턴 boolean true if successfull, false if fail

startup() 공개 메소드

Main engine that checks valid access_token and stores the associated user for retrival
또한 보기: AuthComponent::startup()
public startup ( Controller $controller ) : boolean
$controller Controller
리턴 boolean

unsetRefreshToken() 공개 메소드

Grant type: refresh_token
또한 보기: IOAuth2RefreshTokens::unsetRefreshToken()
public unsetRefreshToken ( string $refresh_token ) : boolean
$refresh_token string
리턴 boolean true if successfull, false if not

user() 공개 메소드

Will return array of all user fields by default You can specify specific fields like so: $id = $this->OAuth->user('id');
public user ( type $field = null, $token = null ) : mixed
$field type
리턴 mixed array of user fields if $field is blank, string value if $field is set and $fields is avaliable, false on failure

프로퍼티 상세

$AccessToken 공개적으로 프로퍼티

AccessToken object.
public object $AccessToken
리턴 object

$AuthCode 공개적으로 프로퍼티

AuthCode object.
public object $AuthCode
리턴 object

$Client 공개적으로 프로퍼티

Clients object.
public object $Client
리턴 object

$OAuth2 공개적으로 프로퍼티

OAuth2 Object
public object $OAuth2
리턴 object

$RefreshToken 공개적으로 프로퍼티

RefreshToken object.
public object $RefreshToken
리턴 object

$User 공개적으로 프로퍼티

User object
public object $User
리턴 object

$_authDefaults 보호되어 있는 프로퍼티

Defaults for $authenticate
protected array $_authDefaults
리턴 array

$_user 보호되어 있는 프로퍼티

Static storage for current user
protected array $_user
리턴 array

$allowedActions 보호되어 있는 프로퍼티

Array of allowed actions
protected array $allowedActions
리턴 array

$authenticate 공개적으로 프로퍼티

Inherits theses defaults: $this->OAuth->authenticate = array( 'userModel' => 'User', 'fields' => array( 'username' => 'username', 'password' => 'password' ) ); Which can be overridden in your beforeFilter: $this->OAuth->authenticate = array( 'fields' => array( 'username' => 'email' ) ); $this->OAuth->authenticate
public array $authenticate
리턴 array

$grantTypes 공개적으로 프로퍼티

By default = array('authorization_code', 'refresh_token', 'password'); Other grant mechanisms are not supported in the current release
public array $grantTypes
리턴 array