Class LightOpenID
This class provides a simple interface for OpenID (1.1 and 2.0) authentication. Supports Yadis discovery. The authentication process is stateless/dumb.
Usage: Sign-on with OpenID is a two step process: Step one is authentication with the provider:
$openid = new LightOpenID('my-host.example.org'); $openid->identity = 'ID supplied by user'; header('Location: ' . $openid->authUrl());
The provider then sends various parameters via GET, one of them is openid_mode. Step two is verification:
$openid = new LightOpenID('my-host.example.org'); if ($openid->mode) { echo $openid->validate() ? 'Logged in.' : 'Failed'; }
Change the 'my-host.example.org' to your domain name. Do NOT use $_SERVER['HTTP_HOST'] for that, unless you know what you are doing.
Optionally, you can set $returnUrl and $realm (or $trustRoot, which is an alias). The default values for those are: $openid->realm = (!empty($_SERVER['HTTPS']) ? 'https' : 'http') . '://' . $_SERVER['HTTP_HOST']; $openid->returnUrl = $openid->realm . $_SERVER['REQUEST_URI']; If you don't know their meaning, refer to any openid tutorial, or specification. Or just guess.
AX and SREG extensions are supported. To use them, specify $openid->required and/or $openid->optional before calling $openid->authUrl(). These are arrays, with values being AX schema paths (the 'path' part of the URL). For example: $openid->required = array('namePerson/friendly', 'contact/email'); $openid->optional = array('namePerson/first'); If the server supports only SREG or OpenID 1.1, these are automaticaly mapped to SREG names, so that user doesn't have to know anything about the server.
To get the values, use $openid->getAttributes().
The library requires PHP >= 5.1.2 with curl or http/https stream wrappers enabled.
License: MIT
Author: Mewp
Located at src/web/includes/lightopenid/openid.php
public
|
|
public
|
|
public
|
|
public
true,
|
|
protected
|
#
request_curl( mixed $url, mixed $method = 'GET', mixed $params = array(), mixed $update_claimed_id )
|
protected
|
|
protected
|
#
request_streams( mixed $url, mixed $method = 'GET', mixed $params = array(), mixed $update_claimed_id )
|
protected
|
|
protected
|
|
protected
|
|
public
String
|
|
protected
|
|
protected
|
|
protected
|
|
protected
|
|
public
String
|
|
public
Bool
|
|
protected
|
|
protected
|
|
public
|
#
getAttributes( )
Gets AX/SREG attributes provided by OP. should be used only after successful
validaton. 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. |
public
mixed
|
$returnUrl |
|
|
public
array
|
$required | array()
|
|
public
array
|
$optional | array()
|
|
public
mixed
|
$verify_peer | null
|
|
public
mixed
|
$capath | null
|
|
public
mixed
|
$cainfo | null
|
|
public
mixed
|
$data |
|
|
protected
mixed
|
$server |
|
|
protected
mixed
|
$version |
|
|
protected
mixed
|
$trustRoot |
|
|
protected
mixed
|
$aliases |
|
|
protected
boolean
|
$identifier_select | false
|
|
protected
boolean
|
$ax | false |
|
protected
boolean
|
$sreg | false |
|
protected
mixed
|
$setup_url | null |
|
protected
array
|
$headers | array() |
|
protected static
array
|
$ax_to_sreg | array(
'namePerson/friendly' => 'nickname',
'contact/email' => 'email',
'namePerson' => 'fullname',
'birthDate' => 'dob',
'person/gender' => 'gender',
'contact/postalCode/home' => 'postcode',
'contact/country/home' => 'country',
'pref/language' => 'language',
'pref/timezone' => 'timezone',
) |