Issues (2)

Security Analysis    no request data  

This project does not seem to handle request data directly as such no vulnerable execution paths were found.

  Cross-Site Scripting
Cross-Site Scripting enables an attacker to inject code into the response of a web-request that is viewed by other users. It can for example be used to bypass access controls, or even to take over other users' accounts.
  File Exposure
File Exposure allows an attacker to gain access to local files that he should not be able to access. These files can for example include database credentials, or other configuration files.
  File Manipulation
File Manipulation enables an attacker to write custom data to files. This potentially leads to injection of arbitrary code on the server.
  Object Injection
Object Injection enables an attacker to inject an object into PHP code, and can lead to arbitrary code execution, file exposure, or file manipulation attacks.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  File Inclusion
File Inclusion enables an attacker to inject custom files into PHP's file loading mechanism, either explicitly passed to include, or for example via PHP's auto-loading mechanism.
  Command Injection
Command Injection enables an attacker to inject a shell command that is execute with the privileges of the web-server. This can be used to expose sensitive data, or gain access of your server.
  SQL Injection
SQL Injection enables an attacker to execute arbitrary SQL code on your database server gaining access to user data, or manipulating user data.
  XPath Injection
XPath Injection enables an attacker to modify the parts of XML document that are read. If that XML document is for example used for authentication, this can lead to further vulnerabilities similar to SQL Injection.
  LDAP Injection
LDAP Injection enables an attacker to inject LDAP statements potentially granting permission to run unauthorized queries, or modify content inside the LDAP tree.
  Header Injection
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  XML Injection
XML Injection enables an attacker to read files on your local filesystem including configuration files, or can be abused to freeze your web-server process.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
Unfortunately, the security analysis is currently not available for your project. If you are a non-commercial open-source project, please contact support to gain access.

src/OAuth2Service.php (1 issue)

Labels
Severity

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php namespace Nord\Lumen\OAuth2;
2
3
use League\OAuth2\Server\Grant\AuthCodeGrant;
4
use Nord\Lumen\OAuth2\Contracts\OAuth2Service as OAuth2ServiceContract;
5
use League\OAuth2\Server\AuthorizationServer;
6
use League\OAuth2\Server\ResourceServer;
7
8
class OAuth2Service implements OAuth2ServiceContract
9
{
10
11
    /**
12
     * @var AuthorizationServer
13
     */
14
    private $authorizationServer;
15
16
    /**
17
     * @var ResourceServer
18
     */
19
    private $resourceServer;
20
21
22
    /**
23
     * OAuth2Server constructor.
24
     *
25
     * @param AuthorizationServer $authorizationServer
26
     * @param ResourceServer      $resourceServer
27
     */
28
    public function __construct(AuthorizationServer $authorizationServer, ResourceServer $resourceServer)
29
    {
30
        $this->authorizationServer = $authorizationServer;
31
        $this->resourceServer      = $resourceServer;
32
    }
33
34
35
    /**
36
     * @return array
37
     * @throws \League\OAuth2\Server\Exception\InvalidRequestException
38
     * @throws \League\OAuth2\Server\Exception\UnsupportedGrantTypeException
39
     */
40
    public function issueAccessToken()
41
    {
42
        return $this->authorizationServer->issueAccessToken();
43
    }
44
45
46
    /**
47
     * @param bool        $headersOnly
48
     * @param null|string $accessToken
49
     *
50
     * @return bool
51
     * @throws \League\OAuth2\Server\Exception\AccessDeniedException
52
     */
53
    public function validateAccessToken($headersOnly = true, $accessToken = null)
54
    {
55
        return $this->resourceServer->isValidRequest($headersOnly, $accessToken);
0 ignored issues
show
It seems like $accessToken defined by parameter $accessToken on line 53 can also be of type string; however, League\OAuth2\Server\Res...erver::isValidRequest() does only seem to accept object<League\OAuth2\Ser...AccessTokenEntity>|null, maybe add an additional type check?

This check looks at variables that have been passed in as parameters and are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
56
    }
57
58
59
    /**
60
     * @return string
61
     */
62
    public function getResourceOwnerId()
63
    {
64
        // TODO: Calling validateAccessToken is kind of a hack, but it is necessary in order to load the access token.
65
        $this->validateAccessToken();
66
67
        return $this->resourceServer->getAccessToken()->getSession()->getOwnerId();
68
    }
69
70
71
    /**
72
     * @return string
73
     */
74
    public function getResourceOwnerType()
75
    {
76
        // TODO: Calling validateAccessToken is kind of a hack, but it is necessary in order to load the access token.
77
        $this->validateAccessToken();
78
79
        return $this->resourceServer->getAccessToken()->getSession()->getOwnerType();
80
    }
81
82
83
    /**
84
     * @return string
85
     */
86
    public function getClientId()
87
    {
88
        // TODO: Calling validateAccessToken is kind of a hack, but it is necessary in order to load the access token.
89
        $this->validateAccessToken();
90
91
        return $this->resourceServer->getAccessToken()->getSession()->getClient()->getId();
92
    }
93
94
    /**
95
     * Check authorize parameters
96
     *
97
     * @return array Authorize request parameters
98
     * @throws \League\OAuth2\Server\Exception\InvalidRequestException
99
     * @throws \League\OAuth2\Server\Exception\InvalidClientException
100
     * @throws \League\OAuth2\Server\Exception\UnsupportedResponseTypeException
101
     */
102
    public function checkAuthorizeParams()
103
    {
104
        if ($this->authorizationServer->hasGrantType('authorization_code')) {
105
            /** @var AuthCodeGrant $authGrant */
106
            $authGrant = $this->authorizationServer->getGrantType('authorization_code');
107
            return $authGrant->checkAuthorizeParams();
108
        }
109
110
        return [];
111
    }
112
113
    /**
114
     * Parse a new authorize request
115
     *
116
     * @param string $type The session owner's type
117
     * @param string $typeId The session owner's ID
118
     * @param array $authParams The authorize request $_GET parameters
119
     *
120
     * @return string
121
     */
122
    public function newAuthorizeRequest($type, $typeId, $authParams = [])
123
    {
124
        if ($this->authorizationServer->hasGrantType('authorization_code')) {
125
            /** @var AuthCodeGrant $authGrant */
126
            $authGrant = $this->authorizationServer->getGrantType('authorization_code');
127
            return $authGrant->newAuthorizeRequest($type, $typeId, $authParams);
128
        }
129
130
        return '';
131
    }
132
}
133