Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yii2
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PSDI Army
yii2
Commits
3c8c8551
Commit
3c8c8551
authored
Dec 23, 2013
by
Paul Klimov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
'GoogleOAuth' auth client added.
parent
a286f309
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
68 additions
and
12 deletions
+68
-12
AuthAction.php
extensions/yii/authclient/AuthAction.php
+12
-11
GoogleOAuth.php
extensions/yii/authclient/clients/GoogleOAuth.php
+55
-0
Choice.php
extensions/yii/authclient/widgets/Choice.php
+1
-1
No files found.
extensions/yii/authclient/AuthAction.php
View file @
3c8c8551
...
...
@@ -29,7 +29,7 @@ class AuthAction extends Action
/**
* @var string name of the GET param, which is used to passed auth client id to this action.
*/
public
$clientIdGetParamName
=
'
client_id
'
;
public
$clientIdGetParamName
=
'
authclient
'
;
/**
* @var callable PHP callback, which should be triggered in case of successful authentication.
*/
...
...
@@ -119,19 +119,20 @@ class AuthAction extends Action
}
/**
* @param mixed $provider
* @throws \yii\base\NotSupportedException
* @param mixed $client auth client instance.
* @return \yii\web\Response response instance.
* @throws \yii\base\NotSupportedException on invalid client.
*/
protected
function
auth
(
$
provider
)
protected
function
auth
(
$
client
)
{
if
(
$
provider
instanceof
OpenId
)
{
return
$this
->
authOpenId
(
$
provider
);
}
elseif
(
$
provider
instanceof
OAuth2
)
{
return
$this
->
authOAuth2
(
$
provider
);
}
elseif
(
$
provider
instanceof
OAuth1
)
{
return
$this
->
authOAuth1
(
$
provider
);
if
(
$
client
instanceof
OpenId
)
{
return
$this
->
authOpenId
(
$
client
);
}
elseif
(
$
client
instanceof
OAuth2
)
{
return
$this
->
authOAuth2
(
$
client
);
}
elseif
(
$
client
instanceof
OAuth1
)
{
return
$this
->
authOAuth1
(
$
client
);
}
else
{
throw
new
NotSupportedException
(
'Provider "'
.
get_class
(
$
provider
)
.
'" is not supported.'
);
throw
new
NotSupportedException
(
'Provider "'
.
get_class
(
$
client
)
.
'" is not supported.'
);
}
}
...
...
extensions/yii/authclient/clients/GoogleOAuth.php
0 → 100644
View file @
3c8c8551
<?php
/**
* @link http://www.yiiframework.com/
* @copyright Copyright (c) 2008 Yii Software LLC
* @license http://www.yiiframework.com/license/
*/
namespace
yii\authclient\clients
;
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]].
*
* @see https://code.google.com/apis/console#access
* @see https://developers.google.com/google-apps/contacts/v3/
*
* @author Paul Klimov <klimov.paul@gmail.com>
* @since 2.0
*/
class
GoogleOAuth
extends
OAuth2
{
/**
* @inheritdoc
*/
public
function
__construct
(
$config
=
[])
{
$config
=
array_merge
(
[
'clientId'
=>
'anonymous'
,
'clientSecret'
=>
'anonymous'
,
'authUrl'
=>
'https://accounts.google.com/o/oauth2/auth'
,
'tokenUrl'
=>
'https://accounts.google.com/o/oauth2/token'
,
'apiBaseUrl'
=>
'https://www.googleapis.com/oauth2/v1'
,
'scope'
=>
implode
(
' '
,
[
'https://www.googleapis.com/auth/userinfo.profile'
,
'https://www.googleapis.com/auth/userinfo.email'
,
]),
],
$config
);
parent
::
__construct
(
$config
);
}
/**
* @inheritdoc
*/
protected
function
initUserAttributes
()
{
$attributes
=
$this
->
api
(
'userinfo'
,
'GET'
);
return
$attributes
;
}
}
\ No newline at end of file
extensions/yii/authclient/widgets/Choice.php
View file @
3c8c8551
...
...
@@ -40,7 +40,7 @@ class Choice extends Widget
* @var string name of the GET param , which should be used to passed auth client id to URL
* defined by {@link baseAuthUrl}.
*/
public
$clientIdGetParamName
=
'
client_id
'
;
public
$clientIdGetParamName
=
'
authclient
'
;
/**
* @var array the HTML attributes that should be rendered in the div HTML tag representing the container element.
*/
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment