Passed
Push — master ( 262b3f...86674d )
by Yannick
09:44
created

OnlyofficeJwtManager::decode()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 1
b 0
f 0
nc 1
nop 3
dl 0
loc 5
rs 10
1
<?php
2
/**
3
 * (c) Copyright Ascensio System SIA 2025.
4
 *
5
 * Licensed under the Apache License, Version 2.0 (the "License");
6
 * you may not use this file except in compliance with the License.
7
 * You may obtain a copy of the License at
8
 *
9
 *     http://www.apache.org/licenses/LICENSE-2.0
10
 *
11
 * Unless required by applicable law or agreed to in writing, software
12
 * distributed under the License is distributed on an "AS IS" BASIS,
13
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
 * See the License for the specific language governing permissions and
15
 * limitations under the License.
16
 */
17
use Firebase\JWT\JWT;
18
use Firebase\JWT\Key;
19
use Onlyoffice\DocsIntegrationSdk\Manager\Security\JwtManager;
20
21
class OnlyofficeJwtManager extends JwtManager
22
{
23
    public function __construct($settingsManager)
24
    {
25
        parent::__construct($settingsManager);
26
    }
27
28
    public function encode($payload, $key, $algorithm = 'HS256')
29
    {
30
        return JWT::encode($payload, $key, $algorithm);
31
    }
32
33
    public function decode($token, $key, $algorithm = 'HS256')
34
    {
35
        $payload = JWT::decode($token, new Key($key, $algorithm));
36
37
        return $payload;
38
    }
39
40
    public function getHash($object)
41
    {
42
        return $this->encode($object, api_get_security_key());
0 ignored issues
show
Bug introduced by
The function api_get_security_key was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

42
        return $this->encode($object, /** @scrutinizer ignore-call */ api_get_security_key());
Loading history...
43
    }
44
}
45