PHP 클래스 yii\authclient\OpenId

Supports Yadis and HTML discovery. Usage: ~~~ use yii\authclient\OpenId; $client = new OpenId(); $client->authUrl = 'https://open.id.provider.url'; // Setup provider endpoint $url = $client->buildAuthUrl(); // Get authentication URL return Yii::$app->getResponse()->redirect($url); // Redirect to authentication URL After user returns at our site: if ($client->validate()) { // validate response $userAttributes = $client->getUserAttributes(); // get account info ... } ~~~ AX and SREG extensions are supported. To use them, specify [[requiredAttributes]] and/or [[optionalAttributes]].
또한 보기: http://openid.net/
부터: 2.0
저자: Paul Klimov ([email protected])
상속: extends BaseClient, implements yii\authclient\ClientInterface
파일 보기 프로젝트 열기: yiisoft/yii2-authclient 1 사용 예제들

공개 프로퍼티들

프로퍼티 타입 설명
$authUrl authentication base URL, which should be used to compose actual authentication URL by OpenId::buildAuthUrl method.
$axToSregMap map of matches between AX and SREG attribute names in format: axAttributeName => sregAttributeName
$cainfo the name of a file holding one or more certificates to verify the peer with. This value will take effect only if [[verifyPeer]] is set.
$capath directory that holds multiple CA certificates. This value will take effect only if [[verifyPeer]] is set.
$data data, which should be used to retrieve the OpenID response. If not set combination of GET and POST will be used.
$optionalAttributes list of attributes, which could be returned from server. Attribute names should be always specified in AX format. For example: php ['namePerson/first', 'namePerson/last']
$requiredAttributes list of attributes, which always should be returned from server. Attribute names should be always specified in AX format. For example: php ['namePerson/friendly', 'contact/email']
$verifyPeer whether to verify the peer's certificate.

공개 메소드들

메소드 설명
buildAuthUrl ( boolean $identifierSelect = null ) : string Returns authentication URL. Usually, you want to redirect your user to it.
discover ( string $url ) : array Performs Yadis and HTML discovery.
fetchAttributes ( ) : array Gets AX/SREG attributes provided by OP. Should be used only after successful validation.
getClaimedId ( ) : string
getReturnUrl ( ) : string
getTrustRoot ( ) : string
hostExists ( string $url ) : boolean Checks if the server specified in the url exists.
init ( )
setClaimedId ( string $claimedId )
setReturnUrl ( string $returnUrl )
setTrustRoot ( string $value )
validate ( boolean $validateRequiredAttributes = true ) : boolean Performs OpenID verification with the OP.

보호된 메소드들

메소드 설명
buildAuthUrlV1 ( array $serverInfo ) : string Builds authentication URL for the protocol version 1.
buildAuthUrlV2 ( array $serverInfo ) : string Builds authentication URL for the protocol version 2.
buildAxParams ( ) : array Composes AX request parameters.
buildSregParams ( ) : array Composes SREG request parameters.
buildUrl ( string $baseUrl, string | array $additionalUrl ) : string Combines given URLs into single one.
compareUrl ( string $expectedUrl, string $actualUrl ) : boolean Compares 2 URLs taking in account possible GET parameters order miss match and URL encoding inconsistencies.
defaultRequestOptions ( )
defaultReturnUrl ( ) : string Generates default [[returnUrl]] value.
extractHtmlTagValue ( string $content, string $tag, string $matchAttributeName, string $matchAttributeValue, string $valueAttributeName ) : string | boolean Scans content for / tags and extract information from them.
fetchAxAttributes ( ) : array Gets AX attributes provided by OP.
fetchSregAttributes ( ) : array Gets SREG attributes provided by OP. SREG names will be mapped to AX names.
initUserAttributes ( )
sendRequest ( string $url, string $method = 'GET', array $params = [] ) : array | string Sends request to the server
validateRequiredAttributes ( ) : boolean Checks if all required attributes are present in the server response.

메소드 상세

buildAuthUrl() 공개 메소드

Returns authentication URL. Usually, you want to redirect your user to it.
public buildAuthUrl ( boolean $identifierSelect = null ) : string
$identifierSelect boolean whether to request OP to select identity for an user in OpenID 2, does not affect OpenID 1.
리턴 string the authentication URL.

buildAuthUrlV1() 보호된 메소드

Builds authentication URL for the protocol version 1.
protected buildAuthUrlV1 ( array $serverInfo ) : string
$serverInfo array OpenID server info.
리턴 string authentication URL.

buildAuthUrlV2() 보호된 메소드

Builds authentication URL for the protocol version 2.
protected buildAuthUrlV2 ( array $serverInfo ) : string
$serverInfo array OpenID server info.
리턴 string authentication URL.

buildAxParams() 보호된 메소드

Composes AX request parameters.
protected buildAxParams ( ) : array
리턴 array AX parameters.

buildSregParams() 보호된 메소드

Composes SREG request parameters.
protected buildSregParams ( ) : array
리턴 array SREG parameters.

buildUrl() 보호된 메소드

Combines given URLs into single one.
protected buildUrl ( string $baseUrl, string | array $additionalUrl ) : string
$baseUrl string base URL.
$additionalUrl string | array additional URL string or information array.
리턴 string composed URL.

compareUrl() 보호된 메소드

Compares 2 URLs taking in account possible GET parameters order miss match and URL encoding inconsistencies.
protected compareUrl ( string $expectedUrl, string $actualUrl ) : boolean
$expectedUrl string expected URL.
$actualUrl string actual URL.
리턴 boolean whether URLs are equal.

defaultRequestOptions() 보호된 메소드

protected defaultRequestOptions ( )

defaultReturnUrl() 보호된 메소드

Generates default [[returnUrl]] value.
protected defaultReturnUrl ( ) : string
리턴 string default authentication return URL.

discover() 공개 메소드

Performs Yadis and HTML discovery.
public discover ( string $url ) : array
$url string Identity URL.
리턴 array OpenID provider info, following keys will be available: - url: string, OP Endpoint (i.e. OpenID provider address). - version: int, OpenID protocol version used by provider. - identity: string, identity value. - identifier_select: bool, whether to request OP to select identity for an user in OpenID 2, does not affect OpenID 1. - ax: bool, whether AX attributes should be used. - sreg: bool, whether SREG attributes should be used.

extractHtmlTagValue() 보호된 메소드

Scans content for / tags and extract information from them.
protected extractHtmlTagValue ( string $content, string $tag, string $matchAttributeName, string $matchAttributeValue, string $valueAttributeName ) : string | boolean
$content string HTML content to be be parsed.
$tag string name of the source tag.
$matchAttributeName string name of the source tag attribute, which should contain $matchAttributeValue
$matchAttributeValue string required value of $matchAttributeName
$valueAttributeName string name of the source tag attribute, which should contain searched value.
리턴 string | boolean searched value, "false" on failure.

fetchAttributes() 공개 메소드

Note that it does not guarantee that any of the required/optional parameters will be present, or that there will be no other attributes besides those specified. In other words. OP may provide whatever information it wants to. SREG names will be mapped to AX names.
또한 보기: http://www.axschema.org/types/
public fetchAttributes ( ) : array
리턴 array array of attributes with keys being the AX schema names, e.g. 'contact/email'

fetchAxAttributes() 보호된 메소드

Gets AX attributes provided by OP.
protected fetchAxAttributes ( ) : array
리턴 array array of attributes.

fetchSregAttributes() 보호된 메소드

Gets SREG attributes provided by OP. SREG names will be mapped to AX names.
protected fetchSregAttributes ( ) : array
리턴 array array of attributes with keys being the AX schema names, e.g. 'contact/email'

getClaimedId() 공개 메소드

public getClaimedId ( ) : string
리턴 string claimed identifier (identity).

getReturnUrl() 공개 메소드

public getReturnUrl ( ) : string
리턴 string authentication return URL.

getTrustRoot() 공개 메소드

public getTrustRoot ( ) : string
리턴 string client trust root (realm).

hostExists() 공개 메소드

Checks if the server specified in the url exists.
public hostExists ( string $url ) : boolean
$url string URL to check
리턴 boolean true, if the server exists; false otherwise

init() 공개 메소드

public init ( )

initUserAttributes() 보호된 메소드

protected initUserAttributes ( )

sendRequest() 보호된 메소드

Sends request to the server
protected sendRequest ( string $url, string $method = 'GET', array $params = [] ) : array | string
$url string request URL.
$method string request method.
$params array request parameters.
리턴 array | string response.

setClaimedId() 공개 메소드

public setClaimedId ( string $claimedId )
$claimedId string claimed identifier (identity).

setReturnUrl() 공개 메소드

public setReturnUrl ( string $returnUrl )
$returnUrl string authentication return URL.

setTrustRoot() 공개 메소드

public setTrustRoot ( string $value )
$value string client trust root (realm).

validate() 공개 메소드

Performs OpenID verification with the OP.
public validate ( boolean $validateRequiredAttributes = true ) : boolean
$validateRequiredAttributes boolean whether to validate required attributes.
리턴 boolean whether the verification was successful.

validateRequiredAttributes() 보호된 메소드

Checks if all required attributes are present in the server response.
protected validateRequiredAttributes ( ) : boolean
리턴 boolean whether all required attributes are present.

프로퍼티 상세

$authUrl 공개적으로 프로퍼티

authentication base URL, which should be used to compose actual authentication URL by OpenId::buildAuthUrl method.
public $authUrl

$axToSregMap 공개적으로 프로퍼티

map of matches between AX and SREG attribute names in format: axAttributeName => sregAttributeName
public $axToSregMap

$cainfo 공개적으로 프로퍼티

the name of a file holding one or more certificates to verify the peer with. This value will take effect only if [[verifyPeer]] is set.
public $cainfo

$capath 공개적으로 프로퍼티

directory that holds multiple CA certificates. This value will take effect only if [[verifyPeer]] is set.
public $capath

$data 공개적으로 프로퍼티

data, which should be used to retrieve the OpenID response. If not set combination of GET and POST will be used.
public $data

$optionalAttributes 공개적으로 프로퍼티

list of attributes, which could be returned from server. Attribute names should be always specified in AX format. For example: php ['namePerson/first', 'namePerson/last']
public $optionalAttributes

$requiredAttributes 공개적으로 프로퍼티

list of attributes, which always should be returned from server. Attribute names should be always specified in AX format. For example: php ['namePerson/friendly', 'contact/email']
public $requiredAttributes

$verifyPeer 공개적으로 프로퍼티

whether to verify the peer's certificate.
public $verifyPeer