-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathOauthModule.php
48 lines (43 loc) · 1.66 KB
/
OauthModule.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<?php
namespace mozzler\auth;
use yii\helpers\ArrayHelper;
use OAuth2\Request;
class OauthModule extends \filsh\yii2\oauth2server\Module
{
public function __construct($id, $parent=null, $config=[])
{
$defaultConfig = [
'tokenParamName' => 'accessToken',
'tokenAccessLifetime' => 3600 * 24,
'options' => [
// Server options
'allow_implicit' => true
],
'storageMap' => [
'user_credentials' => 'mozzler\auth\yii\oauth\storage\MongoDB',
'access_token' => 'mozzler\auth\yii\oauth\storage\MongoDB',
'authorization_code' => 'mozzler\auth\yii\oauth\storage\MongoDB',
'client_credentials' => 'mozzler\auth\yii\oauth\storage\MongoDB',
'client' => 'mozzler\auth\yii\oauth\storage\MongoDB',
'refresh_token' => 'mozzler\auth\yii\oauth\storage\MongoDB',
'public_key' => 'mozzler\auth\yii\oauth\storage\MongoDB',
'jwt_bearer' => 'mozzler\auth\yii\oauth\storage\MongoDB',
'scope' => 'mozzler\auth\yii\oauth\storage\MongoDB',
],
'grantTypes' => [
'user_credentials' => [
'class' => 'OAuth2\GrantType\UserCredentials',
],
'refresh_token' => [
'class' => 'OAuth2\GrantType\RefreshToken',
'always_issue_new_refresh_token' => true
]
]
];
return parent::__construct($id, $parent, ArrayHelper::merge($defaultConfig, $config));
}
public function getRequest()
{
return new Request(\Yii::$app->request->get(), \Yii::$app->request->post(), [], $_COOKIE, $_FILES, $_SERVER);
}
}