Completed
Pull Request — master (#648)
by Lukáš
41:28 queued 06:19
created

S256Verifier::verifyCodeChallenge()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 7
rs 9.4285
cc 1
eloc 4
nc 1
nop 2
1
<?php
2
/**
3
 * @author      Alex Bilbie <[email protected]>
4
 * @copyright   Copyright (c) Alex Bilbie
5
 * @license     http://mit-license.org/
6
 *
7
 * @link        https://github.com/thephpleague/oauth2-server
8
 */
9
10
namespace League\OAuth2\Server\CodeChallengeVerifiers;
11
12
class S256Verifier implements CodeChallengeVerifierInterface
13
{
14
    /**
15
     * Return code challenge method.
16
     *
17
     * @return string
18
     */
19
    public function getMethod()
20
    {
21
        return 'S256';
22
    }
23
24
    /**
25
     * Verify the code challenge.
26
     *
27
     * @param string $codeVerifier
28
     * @param string $codeChallenge
29
     *
30
     * @return bool
31
     */
32
    public function verifyCodeChallenge($codeVerifier, $codeChallenge)
33
    {
34
        return hash_equals(
35
            urlencode(base64_encode(hash('sha256', $codeVerifier))),
36
            $codeChallenge
37
        );
38
    }
39
}
40