Welcome Guest, Not a member yet? Register   Sign In
ExtID - External Identification Library
#1

[eluser]kbjr[/eluser]
A little while ago, I released the EasyOpenID library for CI (http://ellislab.com/forums/viewthread/162349/). Since then, I have received requests from multiple people about implementing Facebook and Twitter support. On that note, I am releasing my new ExtID library (still beta); An identity library which uses both OpenID and OAuth to provide a simple interface to authenticating users with external providers.

It has built-in support for many providers: Google, Facebook, Twitter, AOL, Yahoo, Blogger, MySpace, and OpenID. There is also an additional feature in the works to allow the creating of custom providers.

Links:
GitHub Repository
Project Homepage (Still under development)

Example
Code:
<?php

class Auth extend Controller {

    function Auth()
    {
        parent::Controller();
        
        // load the library
        $this->load->library('ExtID');
    }
    
    /**
     * Starts the authentication proccess
     *
     * This is just a normal page. It will have your login options
     * as links for the user to select from.
     */
    function index()
    {
        // Build the needed markup using the default config
        $data['login_code'] = $this->extid->generate_login('default');
        
        // Load your page
        $this->load->view('login_page', $data);
        
        //
        // $data['login_code'] is now a block of markup that you can
        // insert into your document containing a list of options for
        // your user to select from.
        //
    }
    
    /**
     * Handles the actual logging in
     *
     * This is where the login link in the /auth/index route direct
     * your user. The name of this route is set in the config.
     */
    function login()
    {
        $this->extid->authenticate();
        
        //
        // The authenticate() method will redirect you users to the
        // identity provider's website for authentication. This should
        // be the only call in this route (except, possibly, some
        // internal functions of some kind, but nothing which would
        // generate output).
        //
    }
    
    /**
     * Completes the authentication proccess
     *
     * This function collects the data sent back from the provider.
     */
    function finish_auth()
    {
        $data = $this->extid->finish_auth();
        
        //
        // $data now contains the user's info sent back from the
        // provider. Any values not provided will be NULL. If the
        // provider is Facebook, there is an extra value, 'id',
        // which refers to the user's Facebook ID number.
        //
        // $data = array(
        //   'fullname' => string, the user's name
        //   'nickname' => string, the user's username/nickname
        //   'email'    => string, the user's email address (never
        //                 provided by Twitter)
        //   'id'       => string, only if provider is Facebook/Twitter
        // )
        //
    }
    
    /**
     * Loads icons
     */
    function load_icon()
    {
        $this->extid->load_image();
    }

}

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


Messages In This Thread
ExtID - External Identification Library - by El Forum - 10-13-2010, 11:22 PM
ExtID - External Identification Library - by El Forum - 10-14-2010, 03:03 AM
ExtID - External Identification Library - by El Forum - 10-14-2010, 06:46 AM
ExtID - External Identification Library - by El Forum - 10-14-2010, 08:10 AM
ExtID - External Identification Library - by El Forum - 01-10-2011, 08:03 PM
ExtID - External Identification Library - by El Forum - 01-10-2011, 08:43 PM
ExtID - External Identification Library - by El Forum - 01-11-2011, 11:35 AM
ExtID - External Identification Library - by El Forum - 01-14-2011, 08:06 AM
ExtID - External Identification Library - by El Forum - 01-14-2011, 08:24 AM
ExtID - External Identification Library - by El Forum - 01-14-2011, 08:30 AM
ExtID - External Identification Library - by El Forum - 01-14-2011, 02:31 PM
ExtID - External Identification Library - by El Forum - 01-14-2011, 03:15 PM
ExtID - External Identification Library - by El Forum - 01-14-2011, 09:49 PM
ExtID - External Identification Library - by El Forum - 01-15-2011, 12:55 AM
ExtID - External Identification Library - by El Forum - 01-15-2011, 12:59 AM
ExtID - External Identification Library - by El Forum - 01-15-2011, 01:16 AM
ExtID - External Identification Library - by El Forum - 01-15-2011, 01:27 AM
ExtID - External Identification Library - by El Forum - 01-15-2011, 04:04 AM



Theme © iAndrew 2016 - Forum software by © MyBB