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
d6f35f07
Commit
d6f35f07
authored
Dec 23, 2013
by
Paul Klimov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
OAuth classes refactored.
parent
7a4c1cd3
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
53 additions
and
46 deletions
+53
-46
BaseOAuth.php
extensions/yii/authclient/BaseOAuth.php
+6
-6
OAuth1.php
extensions/yii/authclient/OAuth1.php
+5
-5
OAuth2.php
extensions/yii/authclient/OAuth2.php
+3
-3
GoogleOAuth.php
extensions/yii/authclient/clients/GoogleOAuth.php
+18
-14
Twitter.php
extensions/yii/authclient/clients/Twitter.php
+21
-18
No files found.
extensions/yii/authclient/BaseOAuth.php
View file @
d6f35f07
...
@@ -36,19 +36,19 @@ abstract class BaseOAuth extends BaseClient implements ClientInterface
...
@@ -36,19 +36,19 @@ abstract class BaseOAuth extends BaseClient implements ClientInterface
* Note: this should be absolute URL (with http:// or https:// leading).
* Note: this should be absolute URL (with http:// or https:// leading).
* By default current URL will be used.
* By default current URL will be used.
*/
*/
private
$_returnUrl
=
''
;
private
$_returnUrl
;
/**
/**
* @var string API base URL.
* @var string API base URL.
*/
*/
public
$apiBaseUrl
=
''
;
public
$apiBaseUrl
;
/**
/**
* @var string authorize URL.
* @var string authorize URL.
*/
*/
public
$authUrl
=
''
;
public
$authUrl
;
/**
/**
* @var string auth request scope.
* @var string auth request scope.
*/
*/
public
$scope
=
''
;
public
$scope
;
/**
/**
* @var array cURL request options. Option values from this field will overwrite corresponding
* @var array cURL request options. Option values from this field will overwrite corresponding
* values from {@link defaultCurlOptions()}.
* values from {@link defaultCurlOptions()}.
...
@@ -57,7 +57,7 @@ abstract class BaseOAuth extends BaseClient implements ClientInterface
...
@@ -57,7 +57,7 @@ abstract class BaseOAuth extends BaseClient implements ClientInterface
/**
/**
* @var OAuthToken|array access token instance or its array configuration.
* @var OAuthToken|array access token instance or its array configuration.
*/
*/
private
$_accessToken
=
null
;
private
$_accessToken
;
/**
/**
* @var signature\BaseMethod|array signature method instance or its array configuration.
* @var signature\BaseMethod|array signature method instance or its array configuration.
*/
*/
...
@@ -76,7 +76,7 @@ abstract class BaseOAuth extends BaseClient implements ClientInterface
...
@@ -76,7 +76,7 @@ abstract class BaseOAuth extends BaseClient implements ClientInterface
*/
*/
public
function
getReturnUrl
()
public
function
getReturnUrl
()
{
{
if
(
empty
(
$this
->
_returnUrl
)
)
{
if
(
$this
->
_returnUrl
===
null
)
{
$this
->
_returnUrl
=
$this
->
defaultReturnUrl
();
$this
->
_returnUrl
=
$this
->
defaultReturnUrl
();
}
}
return
$this
->
_returnUrl
;
return
$this
->
_returnUrl
;
...
...
extensions/yii/authclient/OAuth1.php
View file @
d6f35f07
...
@@ -40,15 +40,15 @@ class OAuth1 extends BaseOAuth
...
@@ -40,15 +40,15 @@ class OAuth1 extends BaseOAuth
/**
/**
* @var string OAuth consumer key.
* @var string OAuth consumer key.
*/
*/
public
$consumerKey
=
''
;
public
$consumerKey
;
/**
/**
* @var string OAuth consumer secret.
* @var string OAuth consumer secret.
*/
*/
public
$consumerSecret
=
''
;
public
$consumerSecret
;
/**
/**
* @var string OAuth request token URL.
* @var string OAuth request token URL.
*/
*/
public
$requestTokenUrl
=
''
;
public
$requestTokenUrl
;
/**
/**
* @var string request token HTTP method.
* @var string request token HTTP method.
*/
*/
...
@@ -56,7 +56,7 @@ class OAuth1 extends BaseOAuth
...
@@ -56,7 +56,7 @@ class OAuth1 extends BaseOAuth
/**
/**
* @var string OAuth access token URL.
* @var string OAuth access token URL.
*/
*/
public
$accessTokenUrl
=
''
;
public
$accessTokenUrl
;
/**
/**
* @var string access token HTTP method.
* @var string access token HTTP method.
*/
*/
...
@@ -179,7 +179,7 @@ class OAuth1 extends BaseOAuth
...
@@ -179,7 +179,7 @@ class OAuth1 extends BaseOAuth
$curlOptions
[
CURLOPT_POSTFIELDS
]
=
$params
;
$curlOptions
[
CURLOPT_POSTFIELDS
]
=
$params
;
}
}
$authorizationHeader
=
$this
->
composeAuthorizationHeader
(
$params
);
$authorizationHeader
=
$this
->
composeAuthorizationHeader
(
$params
);
if
(
!
empty
(
$authorizationHeader
)
/* && $this->curlAuthHeader*/
)
{
if
(
!
empty
(
$authorizationHeader
))
{
$curlOptions
[
CURLOPT_HTTPHEADER
]
=
[
'Content-Type: application/atom+xml'
,
$authorizationHeader
];
$curlOptions
[
CURLOPT_HTTPHEADER
]
=
[
'Content-Type: application/atom+xml'
,
$authorizationHeader
];
}
}
break
;
break
;
...
...
extensions/yii/authclient/OAuth2.php
View file @
d6f35f07
...
@@ -40,15 +40,15 @@ class OAuth2 extends BaseOAuth
...
@@ -40,15 +40,15 @@ class OAuth2 extends BaseOAuth
/**
/**
* @var string OAuth client ID.
* @var string OAuth client ID.
*/
*/
public
$clientId
=
''
;
public
$clientId
;
/**
/**
* @var string OAuth client secret.
* @var string OAuth client secret.
*/
*/
public
$clientSecret
=
''
;
public
$clientSecret
;
/**
/**
* @var string token request URL endpoint.
* @var string token request URL endpoint.
*/
*/
public
$tokenUrl
=
''
;
public
$tokenUrl
;
/**
/**
* Composes user authorization URL.
* Composes user authorization URL.
...
...
extensions/yii/authclient/clients/GoogleOAuth.php
View file @
d6f35f07
...
@@ -24,23 +24,27 @@ class GoogleOAuth extends OAuth2
...
@@ -24,23 +24,27 @@ class GoogleOAuth extends OAuth2
/**
/**
* @inheritdoc
* @inheritdoc
*/
*/
public
function
__construct
(
$config
=
[])
public
$authUrl
=
'https://accounts.google.com/o/oauth2/auth'
;
/**
* @inheritdoc
*/
public
$tokenUrl
=
'https://accounts.google.com/o/oauth2/token'
;
/**
* @inheritdoc
*/
public
$apiBaseUrl
=
'https://www.googleapis.com/oauth2/v1'
;
/**
* @inheritdoc
*/
public
function
init
()
{
{
$config
=
array_merge
(
if
(
$this
->
scope
===
null
)
{
[
$this
->
scope
=
implode
(
' '
,
[
'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.profile'
,
'https://www.googleapis.com/auth/userinfo.email'
,
'https://www.googleapis.com/auth/userinfo.email'
,
]),
]);
],
}
$config
);
parent
::
__construct
(
$config
);
}
}
/**
/**
...
...
extensions/yii/authclient/clients/Twitter.php
View file @
d6f35f07
...
@@ -24,24 +24,27 @@ class Twitter extends OAuth1
...
@@ -24,24 +24,27 @@ class Twitter extends OAuth1
/**
/**
* @inheritdoc
* @inheritdoc
*/
*/
public
function
__construct
(
$config
=
[])
public
$authUrl
=
'https://api.twitter.com/oauth/authorize'
;
{
/**
$config
=
array_merge
(
* @inheritdoc
[
*/
'consumerKey'
=>
'anonymous'
,
public
$requestTokenUrl
=
'https://api.twitter.com/oauth/request_token'
;
'consumerSecret'
=>
'anonymous'
,
/**
'requestTokenUrl'
=>
'https://api.twitter.com/oauth/request_token'
,
* @inheritdoc
'requestTokenMethod'
=>
'POST'
,
*/
'accessTokenUrl'
=>
'https://api.twitter.com/oauth/access_token'
,
public
$requestTokenMethod
=
'POST'
;
'accessTokenMethod'
=>
'POST'
,
/**
'authUrl'
=>
'https://api.twitter.com/oauth/authorize'
,
* @inheritdoc
'scope'
=>
''
,
*/
'apiBaseUrl'
=>
'https://api.twitter.com/1.1'
,
public
$accessTokenUrl
=
'https://api.twitter.com/oauth/access_token'
;
],
/**
$config
* @inheritdoc
);
*/
parent
::
__construct
(
$config
);
public
$accessTokenMethod
=
'POST'
;
}
/**
* @inheritdoc
*/
public
$apiBaseUrl
=
'https://api.twitter.com/1.1'
;
/**
/**
* @inheritdoc
* @inheritdoc
...
...
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