Browse Source

Documentation at "yii\authclient" updated.

tags/2.0.0-beta
Paul Klimov 11 years ago
parent
commit
c1a810ba8d
  1. 55
      extensions/yii/authclient/README.md
  2. 34
      extensions/yii/authclient/clients/Facebook.php
  3. 18
      extensions/yii/authclient/clients/GitHub.php
  4. 18
      extensions/yii/authclient/clients/GoogleOAuth.php
  5. 16
      extensions/yii/authclient/clients/GoogleOpenId.php
  6. 34
      extensions/yii/authclient/clients/LinkedIn.php
  7. 34
      extensions/yii/authclient/clients/Twitter.php
  8. 18
      extensions/yii/authclient/clients/YandexOAuth.php
  9. 16
      extensions/yii/authclient/clients/YandexOpenId.php
  10. 11
      extensions/yii/authclient/widgets/assets/authchoice.js

55
extensions/yii/authclient/README.md

@ -27,4 +27,57 @@ to the require section of your composer.json.
Usage & Documentation
---------------------
This extension...
This extension provides the ability of the authentication via external credentials providers.
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']
]); ?>
```

34
extensions/yii/authclient/clients/Facebook.php

@ -13,6 +13,24 @@ use yii\authclient\OAuth2;
* Facebook allows authentication via Facebook OAuth.
* 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 http://developers.facebook.com/docs/reference/api
*
@ -45,4 +63,20 @@ class Facebook extends OAuth2
{
return $this->api('me', 'GET');
}
/**
* @inheritdoc
*/
protected function defaultName()
{
return 'facebook';
}
/**
* @inheritdoc
*/
protected function defaultTitle()
{
return 'Facebook';
}
}

18
extensions/yii/authclient/clients/GitHub.php

@ -13,6 +13,24 @@ use yii\authclient\OAuth2;
* GitHub allows authentication via GitHub OAuth.
* 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 https://github.com/settings/applications/new
*

18
extensions/yii/authclient/clients/GoogleOAuth.php

@ -13,6 +13,24 @@ use yii\authclient\OAuth2;
* 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]].
*
* 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://developers.google.com/google-apps/contacts/v3/
*

16
extensions/yii/authclient/clients/GoogleOpenId.php

@ -13,6 +13,22 @@ use yii\authclient\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.
*
* Example application configuration:
*
* ~~~
* 'components' => [
* 'authClientCollection' => [
* 'class' => 'yii\authclient\Collection',
* 'clients' => [
* 'google' => [
* 'class' => 'yii\authclient\clients\GoogleOpenId'
* ],
* ],
* ]
* ...
* ]
* ~~~
*
* @author Paul Klimov <klimov.paul@gmail.com>
* @since 2.0
*/

34
extensions/yii/authclient/clients/LinkedIn.php

@ -15,6 +15,24 @@ use Yii;
* LinkedIn allows authentication via LinkedIn OAuth.
* 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 https://www.linkedin.com/secure/developer
* @see http://developer.linkedin.com/apis
@ -130,4 +148,20 @@ class LinkedIn extends OAuth2
protected function generateAuthState() {
return sha1(uniqid(get_class($this), true));
}
/**
* @inheritdoc
*/
protected function defaultName()
{
return 'linkedin';
}
/**
* @inheritdoc
*/
protected function defaultTitle()
{
return 'LinkedIn';
}
}

34
extensions/yii/authclient/clients/Twitter.php

@ -13,6 +13,24 @@ use yii\authclient\OAuth1;
* Twitter allows authentication via Twitter OAuth.
* 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/docs/api
*
@ -53,4 +71,20 @@ class Twitter extends OAuth1
{
return $this->api('account/verify_credentials.json', 'GET');
}
/**
* @inheritdoc
*/
protected function defaultName()
{
return 'twitter';
}
/**
* @inheritdoc
*/
protected function defaultTitle()
{
return 'Twitter';
}
}

18
extensions/yii/authclient/clients/YandexOAuth.php

@ -13,6 +13,24 @@ use yii\authclient\OAuth2;
* YandexOAuth allows authentication via Yandex OAuth.
* 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 http://api.yandex.ru/login/doc/dg/reference/response.xml
*

16
extensions/yii/authclient/clients/YandexOpenId.php

@ -13,6 +13,22 @@ use yii\authclient\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.
*
* Example application configuration:
*
* ~~~
* 'components' => [
* 'authClientCollection' => [
* 'class' => 'yii\authclient\Collection',
* 'clients' => [
* 'yandex' => [
* 'class' => 'yii\authclient\clients\YandexOpenId'
* ],
* ],
* ]
* ...
* ]
* ~~~
*
* @author Paul Klimov <klimov.paul@gmail.com>
* @since 2.0
*/

11
extensions/yii/authclient/widgets/assets/authchoice.js

@ -1,3 +1,14 @@
/**
* 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($) {
$.fn.authchoice = function(options) {
options = $.extend({

Loading…
Cancel
Save