Completed
Pull Request — master (#925)
by
unknown
01:39
created

BearerTokenIntrospectionResponse   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 73.32%

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 1
dl 0
loc 34
ccs 11
cts 15
cp 0.7332
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A validIntrospectionResponse() 0 17 1
A getTokenFromRequest() 0 7 1
1
<?php
2
3
namespace League\OAuth2\Server\ResponseTypes;
4
5
use Lcobucci\JWT\Parser;
6
use Lcobucci\JWT\Token;
7
8
class BearerTokenIntrospectionResponse extends IntrospectionResponse
9
{
10
    /**
11
     * @return array
12
     */
13 2
    protected function validIntrospectionResponse()
14
    {
15 2
        $token = $this->getTokenFromRequest();
16
17
        $responseParams = [
18 2
            'active' => true,
19 2
            'token_type' => 'access_token',
20 2
            'scope' => $token->getClaim('scopes', ''),
21 2
            'client_id' => $token->getClaim('aud'),
22 2
            'exp' => $token->getClaim('exp'),
23 2
            'iat' => $token->getClaim('iat'),
24 2
            'sub' => $token->getClaim('sub'),
25 2
            'jti' => $token->getClaim('jti'),
26
        ];
27
28 2
        return array_merge($this->getExtraParams(), $responseParams);
29
    }
30
31
    /**
32
     * @return Token
33
     */
34
    protected function getTokenFromRequest()
35
    {
36
        $jwt = $this->request->getParsedBody()['token'] ?? null;
37
38
        return (new Parser())
39
            ->parse($jwt);
40
    }
41
}
42