4 EAuth extension allows to authenticate users with accounts on other websites.
5 Supported protocols: OpenID, OAuth 1.0 and OAuth 2.0.
7 EAuth is a extension
for provide a unified (does not depend on the selected service) method to authenticate the user. So, the extension itself does not perform login, does not
register the user and does not bind the user accounts from different providers.
10 ### Why own extension and not a third-party service?
11 The implementation of the authorization on your own server has several advantages:
13 * Full control over the process: what will be written in the authorization window, what data we
get, etc.
14 * Ability to change the appearance of the widget.
15 * When logging via OAuth is possible to invoke methods on API.
16 * Fewer dependencies on third-party services - more reliable application.
19 ### The extension allows you to:
21 * Ignore the nuances of authorization through the different types of services, use the
class based adapters for each service.
22 * Get a unique user ID that can be used to
register user in your application.
23 * Extend the standard authorization classes to obtain additional data about the user.
24 * Work with the API of social networks by extending the authorization classes.
25 * Set up a list of supported services, customize the appearance of the widget, use the popup window without closing your application.
28 ### Extension includes:
30 * The component that contains utility functions.
31 * A widget that displays a list of services in the form of icons and allowing authorization in the popup window.
32 * Base classes to create your own services.
33 * Ready
for authenticate via Google, Twitter, Facebook and other providers.
36 ### Supported providers
"out of box":
38 * OpenID: Google, Yandex(ru)
40 * OAuth 2.0: Google, Facebook, VKontake(ru), Mail.ru(ru), Moi Krug(ru), Odnoklassniki(ru)
46 * [Yii Framework](http:
50 * [
loid extension](http:
51 * [EOAuth extension](http:
58 * [
loid extension](http:
59 * [EOAuth extension](http:
64 * Install
loid and EOAuth extensions
65 * Extract the release file under `
protected/extensions`
66 * In your `
protected/config/main.php`, add the following:
76 'ext.eauth.services.*',
81 'class' =>
'ext.lightopenid.loid',
84 'class' =>
'ext.eauth.EAuth',
88 'class' =>
'GoogleOpenIDService',
91 'class' =>
'YandexOpenIDService',
95 'class' =>
'TwitterOAuthService',
99 'google_oauth' => array(
101 'class' =>
'GoogleOAuthService',
102 'client_id' =>
'...',
103 'client_secret' =>
'...',
104 'title' =>
'Google (OAuth)',
108 'class' =>
'FacebookOAuthService',
109 'client_id' =>
'...',
110 'client_secret' =>
'...',
112 'vkontakte' => array(
114 'class' =>
'VKontakteOAuthService',
115 'client_id' =>
'...',
116 'client_secret' =>
'...',
120 'class' =>
'MailruOAuthService',
121 'client_id' =>
'...',
122 'client_secret' =>
'...',
126 'class' =>
'MoikrugOAuthService',
127 'client_id' =>
'...',
128 'client_secret' =>
'...',
130 'odnoklassniki' => array(
132 'class' =>
'OdnoklassnikiOAuthService',
133 'client_id' =>
'...',
134 'client_public' =>
'...',
135 'client_secret' =>
'...',
136 'title' =>
'Odnokl.',
153 public function actionLogin() {
154 $service = Yii::app()->request->getQuery(
'service');
155 if (isset($service)) {
156 $authIdentity = Yii::app()->eauth->getIdentity($service);
157 $authIdentity->redirectUrl = Yii::app()->user->returnUrl;
158 $authIdentity->cancelUrl = $this->createAbsoluteUrl(
'site/login');
160 if ($authIdentity->authenticate()) {
164 if ($identity->authenticate()) {
165 Yii::app()->user->login($identity);
168 $authIdentity->redirect();
172 $authIdentity->cancel();
177 $this->redirect(array(
'site/login'));
187 <h2>Do you already have an account on one of these sites? Click the logo to log in with it here:</h2>
189 $this->widget(
'ext.eauth.EAuthWidget', array(
'action' =>
'site/login'));
193 #### Getting more user data (optional)
195 To receive all the necessary data to your application, you can
override the base
class of any provider.
196 Base classes are stored in `protected/extensions/eauth/services/`.
197 Examples of extended classes can be found in `protected/extensions/eauth/custom_services/`.
199 After overriding the base class, you need to modify your configuration file to set new name of the class.
200 Also you may need to override the `
EAuthUserIdentity` class to store additional data.
202 #### Translations (optional)
204 * Copy the file `/
protected/extensions/eauth/messages/[lang]/eauth.php` to `/
protected/messages/[lang]/eauth.php` to translate the
EAuth extension into other languages.
205 * To add a
new language, you can use the blank file `/
protected/extensions/eauth/messages/blank/eauth.php`.
209 Some time ago I developed
this extension
for [LiStick.ru](http:
211 The extension was released under the [New BSD License](http: