Sso is a project mainly written in PHP, it's free.
Single sign on module for Kohana to use with OAuth providers
With this module you can login (and sign up) your users via OAuth providers while using the Auth module of Kohana. The currently supported providers:
Thanks goes to Geert De Deckere for his work on OAuth login for KohanaJobs.
Read the following to get started.
See the included auth-schema-mysql.sql
file for the correct table structure.
By default the module supports Jelly. Drivers for Kohana's ORM can be downloaded here.
Enable the oauth
module in bootstrap.php
and do the following with the needed providers:
bootstrap.php
application/vendor/facebook
directoryCopy oauth.php
from the oauth module's config
directory to application/config
directory and edit it.
Set the key and secret for the providers like this (for Facebook use your App Id as key):
return array(
'twitter' => array(
'key' => 'xxx',
'secret' => 'xxx'
),
);
Copy sso.php
from the config
directory to application/config
directory and edit it.
You will have to set 2 URLs for each provider:
IMPORTANT: in many cases you want the 2 URLs to be the same as the login completion is not called seperately from initiating the login process. This feature is for only the sake of flexibility.
In your controller all you have to do is something like this (the example is for Twitter):
// Load Auth instance
$auth = Auth::instance();
// Login the user via Twitter
if ($auth->sso('twitter'))
{
// The SSO module returns TRUE if user is logged in, we can issue a redirect in this case
$this->request->redirect('');
}
If the user wasn't found during the login process the current sign up method saves the user as a new user. It also merges the OAuth account with a standard account if they share the same e-mail address.
You can define your own sign up method. Check out the following files depending on your ORM:
module_directory/classes/model/builder/user.php
to application_directory/classes/model/builder/user.php
.sso_signup()
methodin
application_directory/classes/model/builder/user.php` and customize it to your needs.To get an example on how to create the method check it out in module_directory/classes/model/builder/auth/user.php
.
orm_driver_directory/classes/model/user.php
to application_directory/classes/model/user.php
.sso_signup()
method to your needs.