Commit c1a810ba by Paul Klimov

Documentation at "yii\authclient" updated.

parent d8079cc6
...@@ -27,4 +27,57 @@ to the require section of your composer.json. ...@@ -27,4 +27,57 @@ to the require section of your composer.json.
Usage & Documentation Usage & Documentation
--------------------- ---------------------
This extension... This extension provides the ability of the authentication via external credentials providers.
\ No newline at end of file It covers OpenID, OAuth1 and OAuth2 protocols.
You need to setup auth client collection application component:
```
'components' => [
'authClientCollection' => [
'class' => 'yii\authclient\Collection',
'clients' => [
'google' => [
'class' => 'yii\authclient\clients\GoogleOpenId'
],
'facebook' => [
'class' => 'yii\authclient\clients\Facebook',
'clientId' => 'facebook_client_id',
'clientSecret' => 'facebook_client_secret',
],
],
]
...
]
```
Then you need to apply [[yii\authclient\AuthAction]] to some of your web controllers:
```
class SiteController extends Controller
{
public function actions()
{
return [
'auth' => [
'class' => 'yii\authclient\AuthAction',
'successCallback' => [$this, 'successCallback'],
],
]
}
public function successCallback($client)
{
$atributes = $client->getUserAttributes();
// user login or signup comes here
}
}
```
You may use [[yii\authclient\widgets\Choice]] to compose auth client selection:
```
<?= yii\authclient\Choice::widget([
'baseAuthUrl' => ['site/auth']
]); ?>
```
\ No newline at end of file
...@@ -13,6 +13,24 @@ use yii\authclient\OAuth2; ...@@ -13,6 +13,24 @@ use yii\authclient\OAuth2;
* Facebook allows authentication via Facebook OAuth. * Facebook allows authentication via Facebook OAuth.
* In order to use Facebook OAuth you must register your application at [[https://developers.facebook.com/apps]]. * In order to use Facebook OAuth you must register your application at [[https://developers.facebook.com/apps]].
* *
* Example application configuration:
*
* ~~~
* 'components' => [
* 'authClientCollection' => [
* 'class' => 'yii\authclient\Collection',
* 'clients' => [
* 'facebook' => [
* 'class' => 'yii\authclient\clients\Facebook',
* 'clientId' => 'facebook_client_id',
* 'clientSecret' => 'facebook_client_secret',
* ],
* ],
* ]
* ...
* ]
* ~~~
*
* @see https://developers.facebook.com/apps * @see https://developers.facebook.com/apps
* @see http://developers.facebook.com/docs/reference/api * @see http://developers.facebook.com/docs/reference/api
* *
...@@ -45,4 +63,20 @@ class Facebook extends OAuth2 ...@@ -45,4 +63,20 @@ class Facebook extends OAuth2
{ {
return $this->api('me', 'GET'); return $this->api('me', 'GET');
} }
/**
* @inheritdoc
*/
protected function defaultName()
{
return 'facebook';
}
/**
* @inheritdoc
*/
protected function defaultTitle()
{
return 'Facebook';
}
} }
\ No newline at end of file
...@@ -13,6 +13,24 @@ use yii\authclient\OAuth2; ...@@ -13,6 +13,24 @@ use yii\authclient\OAuth2;
* GitHub allows authentication via GitHub OAuth. * GitHub allows authentication via GitHub OAuth.
* In order to use GitHub OAuth you must register your application at [[https://github.com/settings/applications/new]]. * In order to use GitHub OAuth you must register your application at [[https://github.com/settings/applications/new]].
* *
* Example application configuration:
*
* ~~~
* 'components' => [
* 'authClientCollection' => [
* 'class' => 'yii\authclient\Collection',
* 'clients' => [
* 'github' => [
* 'class' => 'yii\authclient\clients\GitHub',
* 'clientId' => 'github_client_id',
* 'clientSecret' => 'github_client_secret',
* ],
* ],
* ]
* ...
* ]
* ~~~
*
* @see http://developer.github.com/v3/oauth/ * @see http://developer.github.com/v3/oauth/
* @see https://github.com/settings/applications/new * @see https://github.com/settings/applications/new
* *
......
...@@ -13,6 +13,24 @@ use yii\authclient\OAuth2; ...@@ -13,6 +13,24 @@ use yii\authclient\OAuth2;
* GoogleOAuth allows authentication via Google OAuth. * GoogleOAuth allows authentication via Google OAuth.
* In order to use Google OAuth you must register your application at [[https://code.google.com/apis/console#access]]. * In order to use Google OAuth you must register your application at [[https://code.google.com/apis/console#access]].
* *
* Example application configuration:
*
* ~~~
* 'components' => [
* 'authClientCollection' => [
* 'class' => 'yii\authclient\Collection',
* 'clients' => [
* 'google' => [
* 'class' => 'yii\authclient\clients\GoogleOAuth',
* 'clientId' => 'google_client_id',
* 'clientSecret' => 'google_client_secret',
* ],
* ],
* ]
* ...
* ]
* ~~~
*
* @see https://code.google.com/apis/console#access * @see https://code.google.com/apis/console#access
* @see https://developers.google.com/google-apps/contacts/v3/ * @see https://developers.google.com/google-apps/contacts/v3/
* *
......
...@@ -13,6 +13,22 @@ use yii\authclient\OpenId; ...@@ -13,6 +13,22 @@ use yii\authclient\OpenId;
* GoogleOpenId allows authentication via Google OpenId. * GoogleOpenId allows authentication via Google OpenId.
* Unlike Google OAuth you do not need to register your application anywhere in order to use Google OpenId. * Unlike Google OAuth you do not need to register your application anywhere in order to use Google OpenId.
* *
* Example application configuration:
*
* ~~~
* 'components' => [
* 'authClientCollection' => [
* 'class' => 'yii\authclient\Collection',
* 'clients' => [
* 'google' => [
* 'class' => 'yii\authclient\clients\GoogleOpenId'
* ],
* ],
* ]
* ...
* ]
* ~~~
*
* @author Paul Klimov <klimov.paul@gmail.com> * @author Paul Klimov <klimov.paul@gmail.com>
* @since 2.0 * @since 2.0
*/ */
......
...@@ -15,6 +15,24 @@ use Yii; ...@@ -15,6 +15,24 @@ use Yii;
* LinkedIn allows authentication via LinkedIn OAuth. * LinkedIn allows authentication via LinkedIn OAuth.
* In order to use linkedIn OAuth you must register your application at [[https://www.linkedin.com/secure/developer]]. * In order to use linkedIn OAuth you must register your application at [[https://www.linkedin.com/secure/developer]].
* *
* Example application configuration:
*
* ~~~
* 'components' => [
* 'authClientCollection' => [
* 'class' => 'yii\authclient\Collection',
* 'clients' => [
* 'linkedin' => [
* 'class' => 'yii\authclient\clients\LinkedIn',
* 'clientId' => 'linkedin_client_id',
* 'clientSecret' => 'linkedin_client_secret',
* ],
* ],
* ]
* ...
* ]
* ~~~
*
* @see http://developer.linkedin.com/documents/authentication * @see http://developer.linkedin.com/documents/authentication
* @see https://www.linkedin.com/secure/developer * @see https://www.linkedin.com/secure/developer
* @see http://developer.linkedin.com/apis * @see http://developer.linkedin.com/apis
...@@ -130,4 +148,20 @@ class LinkedIn extends OAuth2 ...@@ -130,4 +148,20 @@ class LinkedIn extends OAuth2
protected function generateAuthState() { protected function generateAuthState() {
return sha1(uniqid(get_class($this), true)); return sha1(uniqid(get_class($this), true));
} }
/**
* @inheritdoc
*/
protected function defaultName()
{
return 'linkedin';
}
/**
* @inheritdoc
*/
protected function defaultTitle()
{
return 'LinkedIn';
}
} }
\ No newline at end of file
...@@ -13,6 +13,24 @@ use yii\authclient\OAuth1; ...@@ -13,6 +13,24 @@ use yii\authclient\OAuth1;
* Twitter allows authentication via Twitter OAuth. * Twitter allows authentication via Twitter OAuth.
* In order to use Twitter OAuth you must register your application at [[https://dev.twitter.com/apps/new]]. * In order to use Twitter OAuth you must register your application at [[https://dev.twitter.com/apps/new]].
* *
* Example application configuration:
*
* ~~~
* 'components' => [
* 'authClientCollection' => [
* 'class' => 'yii\authclient\Collection',
* 'clients' => [
* 'twitter' => [
* 'class' => 'yii\authclient\clients\Twitter',
* 'consumerKey' => 'twitter_consumer_key',
* 'consumerSecret' => 'twitter_consumer_secret',
* ],
* ],
* ]
* ...
* ]
* ~~~
*
* @see https://dev.twitter.com/apps/new * @see https://dev.twitter.com/apps/new
* @see https://dev.twitter.com/docs/api * @see https://dev.twitter.com/docs/api
* *
...@@ -53,4 +71,20 @@ class Twitter extends OAuth1 ...@@ -53,4 +71,20 @@ class Twitter extends OAuth1
{ {
return $this->api('account/verify_credentials.json', 'GET'); return $this->api('account/verify_credentials.json', 'GET');
} }
/**
* @inheritdoc
*/
protected function defaultName()
{
return 'twitter';
}
/**
* @inheritdoc
*/
protected function defaultTitle()
{
return 'Twitter';
}
} }
\ No newline at end of file
...@@ -13,6 +13,24 @@ use yii\authclient\OAuth2; ...@@ -13,6 +13,24 @@ use yii\authclient\OAuth2;
* YandexOAuth allows authentication via Yandex OAuth. * YandexOAuth allows authentication via Yandex OAuth.
* In order to use Yandex OAuth you must register your application at [[https://oauth.yandex.ru/client/new]]. * In order to use Yandex OAuth you must register your application at [[https://oauth.yandex.ru/client/new]].
* *
* Example application configuration:
*
* ~~~
* 'components' => [
* 'authClientCollection' => [
* 'class' => 'yii\authclient\Collection',
* 'clients' => [
* 'yandex' => [
* 'class' => 'yii\authclient\clients\YandexOAuth',
* 'clientId' => 'yandex_client_id',
* 'clientSecret' => 'yandex_client_secret',
* ],
* ],
* ]
* ...
* ]
* ~~~
*
* @see https://oauth.yandex.ru/client/new * @see https://oauth.yandex.ru/client/new
* @see http://api.yandex.ru/login/doc/dg/reference/response.xml * @see http://api.yandex.ru/login/doc/dg/reference/response.xml
* *
......
...@@ -13,6 +13,22 @@ use yii\authclient\OpenId; ...@@ -13,6 +13,22 @@ use yii\authclient\OpenId;
* YandexOpenId allows authentication via Yandex OpenId. * YandexOpenId allows authentication via Yandex OpenId.
* Unlike Yandex OAuth you do not need to register your application anywhere in order to use Yandex OpenId. * Unlike Yandex OAuth you do not need to register your application anywhere in order to use Yandex OpenId.
* *
* Example application configuration:
*
* ~~~
* 'components' => [
* 'authClientCollection' => [
* 'class' => 'yii\authclient\Collection',
* 'clients' => [
* 'yandex' => [
* 'class' => 'yii\authclient\clients\YandexOpenId'
* ],
* ],
* ]
* ...
* ]
* ~~~
*
* @author Paul Klimov <klimov.paul@gmail.com> * @author Paul Klimov <klimov.paul@gmail.com>
* @since 2.0 * @since 2.0
*/ */
......
/**
* Yii auth choice widget.
*
* This is the JavaScript widget used by the yii\authclient\widgets\Choice widget.
*
* @link http://www.yiiframework.com/
* @copyright Copyright (c) 2008 Yii Software LLC
* @license http://www.yiiframework.com/license/
* @author Paul Klimov <klimov.paul@gmail.com>
* @since 2.0
*/
jQuery(function($) { jQuery(function($) {
$.fn.authchoice = function(options) { $.fn.authchoice = function(options) {
options = $.extend({ options = $.extend({
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment