phpPoA2
[ class tree: phpPoA2 ] [ index: phpPoA2 ] [ all elements ]

Class: LightOpenID

Source Location: /lib/third-party/LightOpenID.php

Class Overview


This class provides a simple interface for OpenID (1.1 and 2.0) authentication.


Author(s):

  • Mewp

Copyright:

  • Copyright (c) 2010, Mewp

Variables

Methods



Class Details

[line 47]
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:

  1.  $openid new LightOpenID;
  2.  $openid->identity 'ID supplied by user';
  3.  header('Location: ' $openid->authUrl());
The provider then sends various parameters via GET, one of them is openid_mode. Step two is verification:
  1.  if ($this->data['openid_mode']{
  2.      $openid new LightOpenID;
  3.      echo $openid->validate('Logged in.' 'Failed';
  4.  }

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.




Tags:

author:  Mewp
copyright:  Copyright (c) 2010, Mewp
license:  MIT


[ Top ]


Class Variables

static $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',
        )

[line 59]



Tags:

access:  protected

Type:   mixed


[ Top ]

$aliases =

[line 57]



Tags:

access:  protected

Type:   mixed


[ Top ]

$ax =  false

[line 58]



Tags:

access:  protected

Type:   mixed


[ Top ]

$cainfo =

[line 54]



Tags:

access:  public

Type:   mixed


[ Top ]

$capath =

[line 53]



Tags:

access:  public

Type:   mixed


[ Top ]

$data =

[line 55]



Tags:

access:  public

Type:   mixed


[ Top ]

$identifier_select =  false
            

[line 57]



Tags:

access:  protected

Type:   mixed


[ Top ]

$optional = array()

[line 51]



Tags:

access:  public

Type:   mixed


[ Top ]

$required = array()

[line 50]



Tags:

access:  public

Type:   mixed


[ Top ]

$returnUrl =

[line 49]



Tags:

access:  public

Type:   mixed


[ Top ]

$server =

[line 57]



Tags:

access:  protected

Type:   mixed


[ Top ]

$setup_url =  null

[line 58]



Tags:

access:  protected

Type:   mixed


[ Top ]

$sreg =  false

[line 58]



Tags:

access:  protected

Type:   mixed


[ Top ]

$trustRoot =

[line 57]



Tags:

access:  protected

Type:   mixed


[ Top ]

$verify_peer =

[line 52]



Tags:

access:  public

Type:   mixed


[ Top ]

$version =

[line 57]



Tags:

access:  protected

Type:   mixed


[ Top ]



Class Methods


constructor __construct [line 71]

LightOpenID __construct( )



[ Top ]

method authUrl [line 600]

String authUrl( [ $immediate = false], String $select_identifier)

Returns authentication url. Usually, you want to redirect your user to it.



Tags:

return:  The authentication url.
throws:  ErrorException


Parameters:

String   $select_identifier   Whether to request OP to select identity for an user in OpenID 2. Does not affect OpenID 1.
   $immediate  

[ Top ]

method authUrl_v1 [line 541]

void authUrl_v1( $immediate)



Tags:

access:  protected


Parameters:

   $immediate  

[ Top ]

method authUrl_v2 [line 562]

void authUrl_v2( $immediate)



Tags:

access:  protected


Parameters:

   $immediate  

[ Top ]

method axParams [line 502]

void axParams( )



Tags:

access:  protected


[ Top ]

method build_url [line 303]

void build_url( $url, $parts)



Tags:

access:  protected


Parameters:

   $url  
   $parts  

[ Top ]

method discover [line 341]

String discover( $url $url)

Performs Yadis and HTML discovery. Normally not used.



Tags:

return:  OP Endpoint (i.e. OpenID provider address).
throws:  ErrorException


Parameters:

$url   $url   Identity URL.

[ Top ]

method getAttributes [line 753]

void 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. * SREG names will be mapped to AX names. * @return Array Array of attributes with keys being the AX schema names, e.g. 'contact/email'




Tags:



[ Top ]

method getAxAttributes [line 678]

void getAxAttributes( )



Tags:

access:  protected


[ Top ]

method getSregAttributes [line 725]

void getSregAttributes( )



Tags:

access:  protected


[ Top ]

method hostExists [line 132]

true, hostExists( $url $url)

Checks if the server specified in the url exists.



Tags:

return:  if the server exists; false otherwise


Parameters:

$url   $url   url to check

[ Top ]

method htmlTag [line 326]

void htmlTag( $content, $tag, $attrName, $attrValue, $valueName)

Helper function used to scan for <meta>/<link> tags and extract information

from them




Tags:

access:  protected


Parameters:

   $content  
   $tag  
   $attrName  
   $attrValue  
   $valueName  

[ Top ]

method request [line 293]

void request( $url, [ $method = 'GET'], [ $params = array()])



Tags:

access:  protected


Parameters:

   $url  
   $method  
   $params  

[ Top ]

method request_curl [line 147]

void request_curl( $url, [ $method = 'GET'], [ $params = array()])



Tags:

access:  protected


Parameters:

   $url  
   $method  
   $params  

[ Top ]

method request_streams [line 203]

void request_streams( $url, [ $method = 'GET'], [ $params = array()])



Tags:

access:  protected


Parameters:

   $url  
   $method  
   $params  

[ Top ]

method sregParams [line 475]

void sregParams( )



Tags:

access:  protected


[ Top ]

method validate [line 616]

Bool validate( )

Performs OpenID verification with the OP.



Tags:

return:  Whether the verification was successful.
throws:  ErrorException


[ Top ]

method __get [line 110]

void __get( $name)



Parameters:

   $name  

[ Top ]

method __set [line 88]

void __set( $name, $value)



Parameters:

   $name  
   $value  

[ Top ]


Documentation generated on Mon, 20 Feb 2012 12:07:05 +0100 by phpDocumentor 1.4.3