Completed
Pull Request — master (#20)
by Дмитрий
09:49 queued 07:44
created

AbstractProvider::getAuthUrlParameters()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 10
ccs 0
cts 9
cp 0
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 6
nc 1
nop 0
crap 2
1
<?php
2
/**
3
 * SocialConnect project
4
 * @author: Patsura Dmitry https://github.com/ovr <[email protected]>
5
 */
6
7
namespace SocialConnect\OpenIDConnect;
8
9
use SocialConnect\Provider\Exception\InvalidAccessToken;
10
11
abstract class AbstractProvider extends \SocialConnect\OAuth2\AbstractProvider
12
{
13
    /**
14
     * @return array
15
     */
16
    abstract public function getKeys();
17
18
    /**
19
     * Default parameters for auth url, can be redeclared inside implementation of the Provider
20
     *
21
     * @return array
22
     */
23
    public function getAuthUrlParameters()
24
    {
25
        return [
26
            'client_id' => $this->consumer->getKey(),
27
            'redirect_uri' => $this->getRedirectUrl(),
28
            'response_type' => 'code',
29
            //'response_mode' => 'form_post',
30
            'scope' => 'openid'
31
        ];
32
    }
33
34
    /**
35
     * {@inheritdoc}
36
     */
37
    public function parseToken($body)
38
    {
39
        $result = json_decode($body, true);
40
        if ($result) {
41
            $token = new AccessToken($result);
42
            $token->setJwt(new JWT($result['id_token'], $this->getKeys()));
43
44
            return $token;
45
        }
46
47
        throw new InvalidAccessToken('Provider response with not valid JSON');
48
    }
49
}
50