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 */
#2

[eluser]Berserk[/eluser]
bookmarked Smile
good job kbjr, i'm building a similar lib for my project, hope i'll get something interests from your lib
#3

[eluser]Unknown[/eluser]
Nice library, trying to use it now...
#4

[eluser]janogarcia[/eluser]
Definitely an interesting library. Thanks James for the contribution!
#5

[eluser]demagu[/eluser]
Hi James,

Not sure what I'm doing wrong but fresh install of your lib + CI throws:

Quote:A PHP Error was encountered
Severity: Notice
Message: Undefined index: callback
Filename: libraries/ExtID.php
Line Number: 484
#6

[eluser]kbjr[/eluser]
Hmmm.... haven't seen this one before. This library is still beta, so bugs are to be expected, though.
I will take a look and get back to you.
#7

[eluser]Schnyder[/eluser]
Has anyone successfully implemented this library yet? I'm running into issues and the documentation is not yet completed. I'm trying to determine whether or not I should keep hacking my way through it or not.

Some sample config data (with dummy keys/secrets, of course) would be AWESOME, since I'm pretty sure that's where I'm currently failing.

Thanks,
Chris
#8

[eluser]kbjr[/eluser]
[quote author="Schnyder" date="1294788959"]Has anyone successfully implemented this library yet? I'm running into issues and the documentation is not yet completed. I'm trying to determine whether or not I should keep hacking my way through it or not.

Some sample config data (with dummy keys/secrets, of course) would be AWESOME, since I'm pretty sure that's where I'm currently failing.

Thanks,
Chris[/quote]

I know that it has been implemented successfully (by myself) but not with all the bells and whistles. The docs aren't finished yet because the library itself isn't finished yet; its still in a very rough beta state. As far as sample config, I have a copy on my desktop computer, and I will post some examples when I can.

And, as far as if you should keep hacking through or not; I am still working on this library. If you want to keep working through and tell me about any issues you may encounter, that would be very helpful to getting this library finished and stable. If you feel you would rather not (because of a deadline or just not interested), that's fine too Smile
#9

[eluser]kbjr[/eluser]
[quote author="demagu" date="1294732983"]Hi James,

Not sure what I'm doing wrong but fresh install of your lib + CI throws:

Quote:A PHP Error was encountered
Severity: Notice
Message: Undefined index: callback
Filename: libraries/ExtID.php
Line Number: 484
[/quote]

That error is telling you that you don't have a callback route specified in the config file (I guess I should probably add one by default so people realize they need one...). In the config/extid.php file try adding the following:
Code:
$config['default']['callback'] = 'auth/finish_auth';
#10

[eluser]kbjr[/eluser]
[quote author="Schnyder" date="1294788959"]Some sample config data (with dummy keys/secrets, of course) would be AWESOME, since I'm pretty sure that's where I'm currently failing.[/quote]
Code:
$config['default']['providers']  = array('openid', 'google', 'facebook', 'twitter', 'yahoo', 'aol', 'blogger');
$config['default']['classname']  = 'extid-item';
$config['default']['route']      = 'auth/login';
$config['default']['icon_route'] = 'auth/load_icon';
$config['default']['callback']   = 'auth/finish_auth';
$config['default']['force_link'] = false;
$config['default']['list_id']    = 'extid';
$config['default']['facebook']   = array(
    'app_id' => '000000000000000',
    'secret' => 'f4f43ttg45t3wtg4553h3yh5eg'
);
$config['default']['twitter']    = array(
    'app_id' => 'NUIJh7H78y8h787y897g897',
    'secret' => 'khjfhwef8433ytyh4735684709456978247t84yg'
);




Theme © iAndrew 2016 - Forum software by © MyBB