PHP Класс Hybrid_Auth

Hybrid_Auth class provide a simple way to authenticate users via OpenID and OAuth. Generally, Hybrid_Auth is the only class you should instanciate and use throughout your application.
Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
$config array Configuration array
$error Hybrid_Error Error pool
$logger Hybrid_Logger Logger
$store Hybrid_Storage Auth cache
$version

Открытые методы

Метод Описание
__construct ( array $config ) Try to start a new session of none then initialize Hybrid_Auth
authenticate ( string $providerId, array $params = null ) Try to authenticate the user with a given provider.
getAdapter ( string $providerId = null ) : Hybrid_Provider_Adapter Return the adapter instance for an authenticated provider
getConnectedProviders ( ) : array Return array listing all authenticated providers
getCurrentUrl ( boolean $request_uri = true ) : string Utility function, return the current url
getProviders ( ) : array Return array listing all enabled providers as well as a flag if you are connected
getSessionData ( ) : string | null Get hybridauth session data
initialize ( array $config ) : void Try to initialize Hybrid_Auth with given $config hash or file
isConnectedWith ( string $providerId ) : boolean Check if the current user is connected to a given provider
logoutAllProviders ( ) : void A generic function to logout all connected provider at once
redirect ( string $url, string $mode = "PHP" ) Utility function, redirect to a given URL with php header or using javascript location.href
restoreSessionData ( string $sessiondata = null ) Restore hybridauth session data
setup ( string $providerId, array $params = null ) : Hybrid_Provider_Adapter Setup an adapter for a given provider
storage ( ) : Hybrid_Storage Hybrid storage system accessor

Описание методов

__construct() публичный Метод

Hybrid_Auth constructor will require either a valid config array or a path for a configuration file as parameter. To know more please refer to the Configuration section: http://hybridauth.sourceforge.net/userguide/Configuration.html
public __construct ( array $config )
$config array Configuration array or path to a configratuion file

authenticate() публичный статический Метод

If the user is already connected we just return and instance of provider adapter, ELSE, try to authenticate and authorize the user with the provider. $params is generally an array with required info in order for this provider and HybridAuth to work, like : hauth_return_to: URL to call back after authentication is done openid_identifier: The OpenID identity provider identifier google_service: can be "Users" for Google user accounts service or "Apps" for Google hosted Apps
public static authenticate ( string $providerId, array $params = null )
$providerId string ID of the provider
$params array Params

getAdapter() публичный статический Метод

Return the adapter instance for an authenticated provider
public static getAdapter ( string $providerId = null ) : Hybrid_Provider_Adapter
$providerId string ID of the provider
Результат Hybrid_Provider_Adapter

getConnectedProviders() публичный статический Метод

Return array listing all authenticated providers
public static getConnectedProviders ( ) : array
Результат array

getCurrentUrl() публичный статический Метод

Utility function, return the current url
public static getCurrentUrl ( boolean $request_uri = true ) : string
$request_uri boolean true to get $_SERVER['REQUEST_URI'], false for $_SERVER['PHP_SELF']
Результат string

getProviders() публичный статический Метод

array( 'Facebook' => array( 'connected' => true ) )
public static getProviders ( ) : array
Результат array

getSessionData() публичный Метод

Get hybridauth session data
public getSessionData ( ) : string | null
Результат string | null

initialize() публичный статический Метод

Try to initialize Hybrid_Auth with given $config hash or file
public static initialize ( array $config ) : void
$config array Configuration array or path to a configratuion file
Результат void

isConnectedWith() публичный статический Метод

Check if the current user is connected to a given provider
public static isConnectedWith ( string $providerId ) : boolean
$providerId string ID of the provider
Результат boolean

logoutAllProviders() публичный статический Метод

A generic function to logout all connected provider at once
public static logoutAllProviders ( ) : void
Результат void

redirect() публичный статический Метод

Utility function, redirect to a given URL with php header or using javascript location.href
public static redirect ( string $url, string $mode = "PHP" )
$url string URL to redirect to
$mode string PHP|JS

restoreSessionData() публичный Метод

Restore hybridauth session data
public restoreSessionData ( string $sessiondata = null )
$sessiondata string Serialized session data

setup() публичный статический Метод

Setup an adapter for a given provider
public static setup ( string $providerId, array $params = null ) : Hybrid_Provider_Adapter
$providerId string ID of the provider
$params array Adapter params
Результат Hybrid_Provider_Adapter

storage() публичный статический Метод

Users sessions are stored using HybridAuth storage system ( HybridAuth 2.0 handle PHP Session only) and can be accessed directly by Hybrid_Auth::storage()->get($key) to retrieves the data for the given key, or calling Hybrid_Auth::storage()->set($key, $value) to store the key => $value set.
public static storage ( ) : Hybrid_Storage
Результат Hybrid_Storage

Описание свойств

$config публичное статическое свойство

Configuration array
public static array $config
Результат array

$error публичное статическое свойство

Error pool
public static Hybrid_Error $error
Результат Hybrid_Error

$logger публичное статическое свойство

Logger
public static Hybrid_Logger $logger
Результат Hybrid_Logger

$store публичное статическое свойство

Auth cache
public static Hybrid_Storage $store
Результат Hybrid_Storage

$version публичное статическое свойство

public static $version