Skip to content

Commit 01fa5f0

Browse files
committed
两个项目同时存在,修改命名空间
1 parent 5d3261c commit 01fa5f0

19 files changed

+41
-148
lines changed

Bootstrap.php

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
namespace filsh\yii2\oauth2server;
3+
namespace wind\oauth2;
44

55
use yii\web\GroupUrlRule;
66

@@ -10,26 +10,26 @@ class Bootstrap implements \yii\base\BootstrapInterface
1010
* @var array Model's map
1111
*/
1212
private $_modelMap = [
13-
'OauthClients' => 'filsh\yii2\oauth2server\models\OauthClients',
14-
'OauthAccessTokens' => 'filsh\yii2\oauth2server\models\OauthAccessTokens',
15-
'OauthAuthorizationCodes' => 'filsh\yii2\oauth2server\models\OauthAuthorizationCodes',
16-
'OauthRefreshTokens' => 'filsh\yii2\oauth2server\models\OauthRefreshTokens',
17-
'OauthScopes' => 'filsh\yii2\oauth2server\models\OauthScopes',
13+
'OauthClients' => 'wind\oauth2\models\OauthClients',
14+
'OauthAccessTokens' => 'wind\oauth2\models\OauthAccessTokens',
15+
'OauthAuthorizationCodes' => 'wind\oauth2\models\OauthAuthorizationCodes',
16+
'OauthRefreshTokens' => 'wind\oauth2\models\OauthRefreshTokens',
17+
'OauthScopes' => 'wind\oauth2\models\OauthScopes',
1818
];
1919

2020
/**
2121
* @var array Storage's map
2222
*/
2323
private $_storageMap = [
24-
'access_token' => 'filsh\yii2\oauth2server\storage\Pdo',
25-
'authorization_code' => 'filsh\yii2\oauth2server\storage\Pdo',
26-
'client_credentials' => 'filsh\yii2\oauth2server\storage\Pdo',
27-
'client' => 'filsh\yii2\oauth2server\storage\Pdo',
28-
'refresh_token' => 'filsh\yii2\oauth2server\storage\Pdo',
29-
'user_credentials' => 'filsh\yii2\oauth2server\storage\Pdo',
30-
'public_key' => 'filsh\yii2\oauth2server\storage\Pdo',
31-
'jwt_bearer' => 'filsh\yii2\oauth2server\storage\Pdo',
32-
'scope' => 'filsh\yii2\oauth2server\storage\Pdo',
24+
'access_token' => 'wind\oauth2\storage\Pdo',
25+
'authorization_code' => 'wind\oauth2\storage\Pdo',
26+
'client_credentials' => 'wind\oauth2\storage\Pdo',
27+
'client' => 'wind\oauth2\storage\Pdo',
28+
'refresh_token' => 'wind\oauth2\storage\Pdo',
29+
'user_credentials' => 'wind\oauth2\storage\Pdo',
30+
'public_key' => 'wind\oauth2\storage\Pdo',
31+
'jwt_bearer' => 'wind\oauth2\storage\Pdo',
32+
'scope' => 'wind\oauth2\storage\Pdo',
3333
];
3434

3535
/**
@@ -60,7 +60,7 @@ public function bootstrap($app)
6060
}
6161

6262
if ($app instanceof \yii\console\Application) {
63-
$module->controllerNamespace = 'filsh\yii2\oauth2server\commands';
63+
$module->controllerNamespace = 'wind\oauth2\commands';
6464
}
6565
}
6666
}

Module.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
namespace filsh\yii2\oauth2server;
3+
namespace wind\oauth2;
44

55
use \Yii;
66
use yii\i18n\PhpMessageSource;
@@ -11,7 +11,7 @@
1111
*
1212
* ```php
1313
* 'oauth2' => [
14-
* 'class' => 'filsh\yii2\oauth2server\Module',
14+
* 'class' => 'wind\oauth2\Module',
1515
* 'tokenParamName' => 'accessToken',
1616
* 'tokenAccessLifetime' => 3600 * 24,
1717
* 'storageMap' => [
@@ -70,7 +70,7 @@ public function init()
7070
/**
7171
* Gets Oauth2 Server
7272
*
73-
* @return \filsh\yii2\oauth2server\Server
73+
* @return \wind\oauth2\Server
7474
* @throws \yii\base\InvalidConfigException
7575
*/
7676
public function getServer()

README.md

Lines changed: 1 addition & 108 deletions
Original file line numberDiff line numberDiff line change
@@ -1,109 +1,2 @@
11
yii2-oauth2-server
2-
==================
3-
4-
A wrapper for implementing an OAuth2 Server(https://github.com/bshaffer/oauth2-server-php)
5-
6-
Installation
7-
------------
8-
9-
The preferred way to install this extension is through [composer](http://getcomposer.org/download/).
10-
11-
Either run
12-
13-
```
14-
php composer.phar require --prefer-dist filsh/yii2-oauth2-server "*"
15-
```
16-
17-
or add
18-
19-
```json
20-
"filsh/yii2-oauth2-server": "*"
21-
```
22-
23-
to the require section of your composer.json.
24-
25-
To use this extension, simply add the following code in your application configuration:
26-
27-
```php
28-
'oauth2' => [
29-
'class' => 'filsh\yii2\oauth2server\Module',
30-
'options' => [
31-
'token_param_name' => 'accessToken',
32-
'access_lifetime' => 3600 * 24
33-
],
34-
'storageMap' => [
35-
'user_credentials' => 'common\models\User'
36-
],
37-
'grantTypes' => [
38-
'client_credentials' => [
39-
'class' => 'OAuth2\GrantType\ClientCredentials',
40-
'allow_public_clients' => false
41-
],
42-
'user_credentials' => [
43-
'class' => 'OAuth2\GrantType\UserCredentials'
44-
],
45-
'refresh_token' => [
46-
'class' => 'OAuth2\GrantType\RefreshToken',
47-
'always_issue_new_refresh_token' => true
48-
]
49-
],
50-
]
51-
```
52-
53-
```common\models\User``` - user model implementing an interface ```\OAuth2\Storage\UserCredentialsInterface```, so the oauth2 credentials data stored in user table
54-
55-
The next step your shold run migration
56-
57-
```php
58-
yii migrate --migrationPath=@vendor/filsh/yii2-oauth2-server/migrations
59-
```
60-
61-
this migration create the oauth2 database scheme and insert test user credentials ```testclient:testpass``` for ```http://fake/```
62-
63-
add url rule to urlManager
64-
65-
```php
66-
'urlManager' => [
67-
'rules' => [
68-
'POST oauth2/<action:\w+>' => 'oauth2/default/<action>',
69-
...
70-
]
71-
]
72-
```
73-
74-
Usage
75-
-----
76-
77-
To use this extension, simply add the behaviors for your base controller:
78-
79-
```php
80-
use yii\helpers\ArrayHelper;
81-
use yii\filters\auth\HttpBearerAuth;
82-
use yii\filters\auth\QueryParamAuth;
83-
use filsh\yii2\oauth2server\filters\ErrorToExceptionFilter;
84-
use filsh\yii2\oauth2server\filters\auth\CompositeAuth;
85-
86-
class Controller extends \yii\rest\Controller
87-
{
88-
/**
89-
* @inheritdoc
90-
*/
91-
public function behaviors()
92-
{
93-
return ArrayHelper::merge(parent::behaviors(), [
94-
'authenticator' => [
95-
'class' => CompositeAuth::className(),
96-
'authMethods' => [
97-
['class' => HttpBearerAuth::className()],
98-
['class' => QueryParamAuth::className(), 'tokenParam' => 'accessToken'],
99-
]
100-
],
101-
'exceptionFilter' => [
102-
'class' => ErrorToExceptionFilter::className()
103-
],
104-
]);
105-
}
106-
}
107-
```
108-
109-
For more, see https://github.com/bshaffer/oauth2-server-php
2+
==================

Request.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
namespace filsh\yii2\oauth2server;
3+
namespace wind\oauth2;
44

55
class Request extends \OAuth2\Request
66
{

Response.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
namespace filsh\yii2\oauth2server;
3+
namespace wind\oauth2;
44

55
class Response extends \OAuth2\Response
66
{

Server.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
<?php
22

3-
namespace filsh\yii2\oauth2server;
3+
namespace wind\oauth2;
44

55
class Server extends \OAuth2\Server
66
{
77
use traits\ClassNamespace;
88

99
/**
10-
* @var \filsh\yii2\oauth2server\Module
10+
* @var \wind\oauth2\Module
1111
*/
1212
protected $module;
1313

controllers/DefaultController.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
<?php
22

3-
namespace filsh\yii2\oauth2server\controllers;
3+
namespace wind\oauth2\controllers;
44

55
use Yii;
66
use yii\helpers\ArrayHelper;
7-
use filsh\yii2\oauth2server\filters\ErrorToExceptionFilter;
7+
use wind\oauth2\filters\ErrorToExceptionFilter;
88

99
class DefaultController extends \yii\rest\Controller
1010
{

controllers/RestController.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
<?php
22

3-
namespace filsh\yii2\oauth2server\controllers;
3+
namespace wind\oauth2\controllers;
44

55
use Yii;
66
use yii\helpers\ArrayHelper;
7-
use filsh\yii2\oauth2server\filters\ErrorToExceptionFilter;
7+
use wind\oauth2\filters\ErrorToExceptionFilter;
88

99
class RestController extends \yii\rest\Controller
1010
{

exceptions/HttpException.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
namespace filsh\yii2\oauth2server\exceptions;
3+
namespace wind\oauth2\exceptions;
44

55
class HttpException extends \yii\web\HttpException
66
{

filters/ErrorToExceptionFilter.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
<?php
22

3-
namespace filsh\yii2\oauth2server\filters;
3+
namespace wind\oauth2\filters;
44

55
use Yii;
66
use yii\base\Controller;
7-
use filsh\yii2\oauth2server\Module;
8-
use filsh\yii2\oauth2server\exceptions\HttpException;
7+
use wind\oauth2\Module;
8+
use wind\oauth2\exceptions\HttpException;
99

1010
class ErrorToExceptionFilter extends \yii\base\Behavior
1111
{

filters/auth/CompositeAuth.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
namespace filsh\yii2\oauth2server\filters\auth;
3+
namespace wind\oauth2\filters\auth;
44

55
use \Yii;
66

grants/UserAuthCredentials.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
namespace filsh\yii2\oauth2server\grants;
3+
namespace wind\oauth2\grants;
44

55
use \OAuth2\Storage\ClientCredentialsInterface;
66
use \OAuth2\Storage\UserCredentialsInterface;

models/OauthAccessTokens.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
namespace filsh\yii2\oauth2server\models;
3+
namespace wind\oauth2\models;
44

55
use Yii;
66

models/OauthAuthorizationCodes.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
namespace filsh\yii2\oauth2server\models;
3+
namespace wind\oauth2\models;
44

55
use Yii;
66

models/OauthClients.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
namespace filsh\yii2\oauth2server\models;
3+
namespace wind\oauth2\models;
44

55
use Yii;
66

models/OauthRefreshTokens.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
namespace filsh\yii2\oauth2server\models;
3+
namespace wind\oauth2\models;
44

55
use Yii;
66

models/OauthScopes.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
namespace filsh\yii2\oauth2server\models;
3+
namespace wind\oauth2\models;
44

55
use Yii;
66

storage/Pdo.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
namespace filsh\yii2\oauth2server\storage;
3+
namespace wind\oauth2\storage;
44

55
class Pdo extends \OAuth2\Storage\Pdo
66
{

traits/ClassNamespace.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
namespace filsh\yii2\oauth2server\traits;
3+
namespace wind\oauth2\traits;
44

55
trait ClassNamespace
66
{

0 commit comments

Comments
 (0)