forked from filsh/yii2-oauth2-server
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Server.php
52 lines (42 loc) · 2.02 KB
/
Server.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
49
50
51
52
<?php
namespace filsh\yii2\oauth2server;
class Server extends \OAuth2\Server
{
use traits\ClassNamespace;
/**
* @var \filsh\yii2\oauth2server\Module
*/
protected $module;
public function __construct(Module $module, $storage = array(), array $config = array(), array $grantTypes = array(), array $responseTypes = array(), \OAuth2\TokenType\TokenTypeInterface $tokenType = null, \OAuth2\ScopeInterface $scopeUtil = null, \OAuth2\ClientAssertionType\ClientAssertionTypeInterface $clientAssertionType = null)
{
$this->module = $module;
parent::__construct($storage, $config, $grantTypes, $responseTypes, $tokenType, $scopeUtil, $clientAssertionType);
}
public function createAccessToken($clientId, $userId, $scope = null, $includeRefreshToken = true)
{
$accessToken = $this->getAccessTokenResponseType();
return $accessToken->createAccessToken($clientId, $userId, $scope, $includeRefreshToken);
}
public function verifyResourceRequest(\OAuth2\RequestInterface $request = null, \OAuth2\ResponseInterface $response = null, $scope = null)
{
if($request === null) {
$request = $this->module->getRequest();
}
return parent::verifyResourceRequest($request, $response, $scope);
}
public function handleTokenRequest(\OAuth2\RequestInterface $request = null, \OAuth2\ResponseInterface $response = null)
{
if($request === null) {
$request = $this->module->getRequest();
}
return parent::handleTokenRequest($request, $response);
}
public function handleAuthorizeRequest(\OAuth2\RequestInterface $request = null, \OAuth2\ResponseInterface $response = null, $is_authorized = false, $user_id = null)
{
if($request === null)
$request = $this->module->getRequest();
if($response === null)
$response = $this->module->getResponse();
return parent::handleAuthorizeRequest($request, $response, $is_authorized, $user_id);
}
}