EasyOpenID

easy to use OpenID library for codeIgniter

6 years after

h1. EasyOpenID

Author: James Brumond Version 0.2.2-b

Copyright 2010 James Brumond Dual licensed under MIT and GPL

h2. NOTICE

(24 July, 2012) This library is no longer being maintained. I would be happy to hand over it's maintenance to someone else if they would like to continue the project, but I will not be making any updates. If you are interested, feel free to open an issue so we can discuss.

h2. Description

An easy to use OpenID library for CodeIgniter applications.

For full documentation, see the project home page at "http://code.kbjrweb.com/project/easyopenid":http://code.kbjrweb.com/project/easyopenid

h2. Installation

Download the "latest package":http://github.com/kbjr/EasyOpenID/downloads and extract the files. The file @[email protected] needs to be renamed to @[email protected] and placed in your @./system/application/[email protected] directory. Then, copy all of the files in the @[email protected] directory into your @./system/application/[email protected] directory. That's it, it's installed.

h2. Basic Usage

First things first, you need to load the library. There are two main libraries you can load (@[email protected] and @[email protected]), but I honestly can't think of any reason to interact directly with the @[email protected] library. So, load up the library with a call like:

bc. $this->load->library('EasyOpenID');

You are going to need to declare three controller functions (or, depending on how you use the system, more), so you might want to create a completely seperate OpenID controller. Following that model, the following example should explain fairly well how to use the library:

load->library('EasyOpenID');
    }

    /**
     * Starts the authentication proccess
     *
     * If successful, this function will redirect the page
     * to the OpenID provider's authentication page.
     */
    function try_auth()
    {
        // assuming that the provider is supplied in a URI segment,
        // fetch the provider ID.
        $provider = $this->uri->segment(3);

        // if we have a provider
        if ($provider)
        {
            $result = $this->easyopenid
                ->provider($provider)                     // what provider you're using
                ->return_to('openid_auth/finish_auth')    // where to redirect after authentication
                ->required('email')                       // what data do we want
                ->make_request();                         // start the authentication process

            // if an error occured
            if (is_int($result))
            {
                $error = $this->easyopenid->last_error();
                // handle error...
            }
        }
        else
        {
            // error, handle...
        }
    }

    /**
     * Completes the authentication proccess
     *
     * This function collects the data sent back from the
     * OpenID provider.
     */
    function finish_auth()
    {
        $result = $this->easyopenid
            ->fetch_response()    // collect the provider response
            ->result();           // return the response for processing

        // if an error occured
        if (is_int($result))
        {
            $error = $this->easyopenid->last_error();
            // handle error...
        }
        else
        {
            $user_data = $result;
            // handle success...
        }
    }

}

/* End of file openid_auth.php */
/* Location: ./system/application/controllers/openid_auth.php */

Top Contributors

kbjr indeyets tjohns brianellin robertmain conf arty-name willnorris harningt blueyed nikolasco dho subrasan

Releases

-   v0.2.4-b zip tar
-   v0.2.3-b zip tar
-   v0.2.2-b zip tar
-   v0.2.1-b zip tar
-   v0.1.1-a zip tar