PHP 클래스 Gdn_OAuth2, vanilla

Base class to be extended by any plugin that wants to use Oauth2 protocol for SSO. WARNING This is a base class for the purposes of being extended by other plugins. It is not to be instantiated on its own. For most OAuth2 SSO needs the generic plugins/OAuth2/class.Oauth2.plugin.php should be adequate. If not, create a plugin that extends this class, Gdn_OAuth2, and overwrite any of its methods of constants.
상속: extends Gdn_Plugin
파일 보기 프로젝트 열기: vanilla/vanilla

보호된 프로퍼티들

프로퍼티 타입 설명
$accessToken token provider by authenticator
$authorizeUriParams optional additional get parameters to be passed in the authorize_uri
$defaultContentType content type for API calls
$profileRequestParams optional additional get params to be passed in the request for profile
$provider stored information to connect with provider (secret, etc.)
$providerKey key for GDN_UserAuthenticationProvider table
$requestAccessTokenParams optional additional post parameters to be passed in the accessToken request
$scope passing scope to authenticator
$settingsView

공개 메소드들

메소드 설명
__construct ( string $providerKey, boolean | string $accessToken = false ) Set up OAuth2 access properties.
accessToken ( boolean | string $newValue = false ) : boolean | string | null Renew or return access token.
assetModel_styleCss_handler ( $sender, $args ) Insert css file for generic styling of signin button/icon.
authorizeUri ( array $state = [] ) : string Create the URI that can return an authorization.
base_beforeSignInButton_handler ( $sender, $args ) Inject a sign-in icon into the ME menu.
base_connectData_handler ( $sender, $args ) Inject into the process of the base connection.
entryController_overrideSignIn_handler ( $sender, $args ) : mixed | boolean Redirect to provider's signin page if this is the default behaviour.
entryController_signIn_handler ( $sender, $args ) : mixed | boolean Inject sign-in button into the sign in page.
entryEndpoint ( $sender, $code, $state ) Create a controller to handle entry request.
gdn_pluginManager_afterStart_handler ( $sender ) Register a call back function so that multiple plugins can use it as an entry point on SSO.
getAccessTokenRequestOptions ( ) : array Allow child classes to pass different options to the Token request API call.
getProfile ( ) : array Get profile data from authentication provider through API.
getProfileRequestOptions ( ) : array Allow child classes to pass different options to the Profile request API call.
getProviderKey ( ) : string Get provider key.
isConfigured ( ) : boolean Check if there is enough data to connect to an authentication provider.
isConnected ( ) : boolean Check if an access token has been returned from the provider server.
isDefault ( ) : boolean Check authentication provider table to see if this is the default method for logging in.
log ( $message, $data )
provider ( ) : array Return all the information saved in provider table.
requestAccessToken ( string $code ) : mixed Request access token from provider.
requireVal ( string $key, array $arr, string $context = null ) : mixed Extract values from arrays.
setAccessToken ( string $accessToken ) Set access token received from provider.
setAuthorizeUriParams ( $params ) Set additional params to be added to the get string in the AuthorizeUri string.
setGetProfileParams ( $params ) Set additional params to be added to the get string in the getProfile request.
setProviderKey ( string $providerKey ) Set provider key used to access settings stored in GDN_UserAuthenticationProvider.
setRequestAccessTokenParams ( $params ) Set additional params to be added to the post array in the accessToken request.
setScope ( $scope ) Set scope to be passed to provider.
settingsEndpoint ( $sender, $args ) Create a controller to deal with plugin settings in dashboard.
setup ( ) Setup
signInButton ( string $type = 'button' ) : string Create signup button specific to this plugin.
structure ( ) Create the structure in the database.
translateProfileResults ( array $rawProfile = [] ) : array Allow the admin to input the keys that their service uses to send data.

보호된 메소드들

메소드 설명
api ( $uri, string $method = 'GET', array $params = [], array $options = [] ) : mixed | type. Generic API uses ProxyRequest class to fetch data from remote endpoints.
getSettingsFormFields ( ) : array Allow child class to over-ride or add form fields to settings.

메소드 상세

__construct() 공개 메소드

Set up OAuth2 access properties.
public __construct ( string $providerKey, boolean | string $accessToken = false )
$providerKey string Fixed key set in child class.
$accessToken boolean | string Provided by the authentication provider.

accessToken() 공개 메소드

Renew or return access token.
public accessToken ( boolean | string $newValue = false ) : boolean | string | null
$newValue boolean | string Pass existing token if it exists.
리턴 boolean | string | null String if there is an accessToken passed or found in session, false or null if not.

api() 보호된 메소드

Generic API uses ProxyRequest class to fetch data from remote endpoints.
protected api ( $uri, string $method = 'GET', array $params = [], array $options = [] ) : mixed | type.
$uri Endpoint on provider's server.
$method string HTTP method required by provider.
$params array Query string.
$options array Configuration options for the request (e.g. Content-Type).
리턴 mixed | type.

assetModel_styleCss_handler() 공개 메소드

Insert css file for generic styling of signin button/icon.
public assetModel_styleCss_handler ( $sender, $args )

authorizeUri() 공개 메소드

Create the URI that can return an authorization.
public authorizeUri ( array $state = [] ) : string
$state array Optionally provide an array of variables to be sent to the provider.
리턴 string Endpoint of the provider.

base_beforeSignInButton_handler() 공개 메소드

Inject a sign-in icon into the ME menu.
public base_beforeSignInButton_handler ( $sender, $args )

base_connectData_handler() 공개 메소드

Inject into the process of the base connection.
public base_connectData_handler ( $sender, $args )

entryController_overrideSignIn_handler() 공개 메소드

Redirect to provider's signin page if this is the default behaviour.
public entryController_overrideSignIn_handler ( $sender, $args ) : mixed | boolean
리턴 mixed | boolean Return null if not configured.

entryController_signIn_handler() 공개 메소드

Inject sign-in button into the sign in page.
public entryController_signIn_handler ( $sender, $args ) : mixed | boolean
리턴 mixed | boolean Return null if not configured

entryEndpoint() 공개 메소드

Create a controller to handle entry request.
public entryEndpoint ( $sender, $code, $state )
$code string Retrieved from the response of the authentication provider, used to fetch an authentication token.
$state string Values passed by us and returned in the response of the authentication provider.

gdn_pluginManager_afterStart_handler() 공개 메소드

This endpoint is executed on /entry/[provider] and is used as the redirect after making an initial request to log in to an authentication provider.
public gdn_pluginManager_afterStart_handler ( $sender )
$sender

getAccessTokenRequestOptions() 공개 메소드

Valid options are ConnectTimeout, Timeout, Content-Type and Authorization-Header-Message.

getProfile() 공개 메소드

Get profile data from authentication provider through API.
public getProfile ( ) : array
리턴 array User profile from provider.

getProfileRequestOptions() 공개 메소드

Valid options are ConnectTimeout, Timeout, Content-Type and Authorization-Header-Message.
public getProfileRequestOptions ( ) : array
리턴 array

getProviderKey() 공개 메소드

Get provider key.
public getProviderKey ( ) : string
리턴 string Provider key.

getSettingsFormFields() 보호된 메소드

Allow child class to over-ride or add form fields to settings.
protected getSettingsFormFields ( ) : array
리턴 array Form fields to appear in settings dashboard.

isConfigured() 공개 메소드

Check if there is enough data to connect to an authentication provider.
public isConfigured ( ) : boolean
리턴 boolean True if there is a secret and a client_id, false if not.

isConnected() 공개 메소드

Check if an access token has been returned from the provider server.
public isConnected ( ) : boolean
리턴 boolean True of there is an accessToken, fals if there is not.

isDefault() 공개 메소드

Check authentication provider table to see if this is the default method for logging in.
public isDefault ( ) : boolean
리턴 boolean Return the value of the IsDefault row of GDN_UserAuthenticationProvider .

log() 공개 메소드

public log ( $message, $data )

provider() 공개 메소드

Return all the information saved in provider table.
public provider ( ) : array
리턴 array Stored provider data (secret, client_id, etc.).

requestAccessToken() 공개 메소드

Request access token from provider.
public requestAccessToken ( string $code ) : mixed
$code string code returned from initial handshake with provider.
리턴 mixed Result of the API call to the provider, usually JSON.

requireVal() 공개 메소드

Extract values from arrays.
public requireVal ( string $key, array $arr, string $context = null ) : mixed
$key string Needle.
$arr array Haystack.
$context string Context to make error messages clearer.
리턴 mixed Extracted value from array.

setAccessToken() 공개 메소드

Set access token received from provider.
public setAccessToken ( string $accessToken )
$accessToken string Retrieved from provider to authenticate communication.

setAuthorizeUriParams() 공개 메소드

Set additional params to be added to the get string in the AuthorizeUri string.
public setAuthorizeUriParams ( $params )

setGetProfileParams() 공개 메소드

Set additional params to be added to the get string in the getProfile request.
public setGetProfileParams ( $params )

setProviderKey() 공개 메소드

Set provider key used to access settings stored in GDN_UserAuthenticationProvider.
public setProviderKey ( string $providerKey )
$providerKey string Key to retrieve provider data hardcoded into child class.

setRequestAccessTokenParams() 공개 메소드

Set additional params to be added to the post array in the accessToken request.
public setRequestAccessTokenParams ( $params )

setScope() 공개 메소드

Set scope to be passed to provider.
public setScope ( $scope )

settingsEndpoint() 공개 메소드

Create a controller to deal with plugin settings in dashboard.
public settingsEndpoint ( $sender, $args )

setup() 공개 메소드

Setup
public setup ( )

signInButton() 공개 메소드

Create signup button specific to this plugin.
public signInButton ( string $type = 'button' ) : string
$type string Either button or icon to be output.
리턴 string Resulting HTML element (button).

structure() 공개 메소드

Create the structure in the database.
public structure ( )

translateProfileResults() 공개 메소드

Allow the admin to input the keys that their service uses to send data.
public translateProfileResults ( array $rawProfile = [] ) : array
$rawProfile array profile as it is returned from the provider.
리턴 array Profile array transformed by child class or as is.

프로퍼티 상세

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

token provider by authenticator
protected $accessToken

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

optional additional get parameters to be passed in the authorize_uri
protected $authorizeUriParams

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

content type for API calls
protected $defaultContentType

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

optional additional get params to be passed in the request for profile
protected $profileRequestParams

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

stored information to connect with provider (secret, etc.)
protected $provider

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

key for GDN_UserAuthenticationProvider table
protected $providerKey

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

optional additional post parameters to be passed in the accessToken request
protected $requestAccessTokenParams

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

passing scope to authenticator
protected $scope

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

protected $settingsView