PHP 클래스 RESTfulAPI_TokenAuthenticator

저자: Thierry Francois @colymba [email protected]
상속: implements RESTfulAPI_Authenticator
파일 보기 프로젝트 열기: colymba/silverstripe-restfulapi

보호된 프로퍼티들

프로퍼티 타입 설명
$tokenConfig array ...

공개 메소드들

메소드 설명
__construct ( ) Instanciation + config aquisition
authenticate ( SS_HTTPRequest $request ) : true | RESTfulAPI_Error Checks if a request to the API is authenticated Gets API Token from HTTP Request and return Auth result
getOwner ( SS_HTTPRequest $request ) : null | DataObject Returns the DataObject related to the token that sent the authenticated request
getToken ( integer $id ) : string Return the stored API token for a specific owner
login ( SS_HTTPRequest $request ) : array Login a user into the Framework and generates API token Only works if the token owner is a Member
logout ( SS_HTTPRequest $request ) Logout a user from framework and update token with an expired one if token owner class is a Member
lostPassword ( SS_HTTPRequest $request ) : array Sends password recovery email
resetToken ( integer $id, boolean $expired = false ) Reset an owner's token if $expired is set to true the owner's will have a new invalidated/expired token

비공개 메소드들

메소드 설명
generateToken ( boolean $expired = false ) : array Generates an encrypted random token and an expiry date
validateAPIToken ( string $token ) : true | RESTfulAPI_Error Validate the API token

메소드 상세

__construct() 공개 메소드

Instanciation + config aquisition
public __construct ( )

authenticate() 공개 메소드

Checks if a request to the API is authenticated Gets API Token from HTTP Request and return Auth result
public authenticate ( SS_HTTPRequest $request ) : true | RESTfulAPI_Error
$request SS_HTTPRequest HTTP API request
리턴 true | RESTfulAPI_Error True if token is valid OR RESTfulAPI_Error with details

getOwner() 공개 메소드

Returns the DataObject related to the token that sent the authenticated request
public getOwner ( SS_HTTPRequest $request ) : null | DataObject
$request SS_HTTPRequest HTTP API request
리턴 null | DataObject null if failed or the DataObject token owner related to the request

getToken() 공개 메소드

Return the stored API token for a specific owner
public getToken ( integer $id ) : string
$id integer ID of the token owner
리턴 string API token for the owner

login() 공개 메소드

Login a user into the Framework and generates API token Only works if the token owner is a Member
public login ( SS_HTTPRequest $request ) : array
$request SS_HTTPRequest HTTP request containing 'email' & 'pwd' vars
리턴 array login result with token

logout() 공개 메소드

Logout a user from framework and update token with an expired one if token owner class is a Member
public logout ( SS_HTTPRequest $request )
$request SS_HTTPRequest HTTP request containing 'email' var

lostPassword() 공개 메소드

Sends password recovery email
public lostPassword ( SS_HTTPRequest $request ) : array
$request SS_HTTPRequest HTTP request containing 'email' vars
리턴 array 'email' => false if email fails (Member doesn't exist will not be reported)

resetToken() 공개 메소드

Reset an owner's token if $expired is set to true the owner's will have a new invalidated/expired token
public resetToken ( integer $id, boolean $expired = false )
$id integer ID of the token owner
$expired boolean if true the token will be invalidated

프로퍼티 상세

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

...
protected array $tokenConfig
리턴 array