1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
jwt.php
См. документацию.
1<?php
2
4
7
8final class Jwt
9{
10 public const DEFAULT_TTL = 12 * 3600;
11
15 public static function create(array $channels = [], int $userId = 0, array $options = []): array
16 {
17 if (empty($channels) && $userId === 0)
18 {
19 throw new Main\ArgumentException("Either channel list or user id must be specified");
20 }
21
22 $ttl = is_integer($options['ttl']) && $options['ttl'] > 0 ? $options['ttl'] : self::DEFAULT_TTL;
23
24 $time = time();
25 $exp = $time + $ttl;
26 $data = [
27 'iss' => (string)Config::getHostId(),
28 'iat' => $time,
29 'exp' => $exp,
30 ];
31 if ($userId > 0)
32 {
33 $data['sub'] = (string)$userId;
34 }
35 if (!empty($channels))
36 {
37 $data['chan'] = implode(',', $channels);
38 }
39 $secret = Config::getSignatureKey();
40
41 return [Main\Web\JWT::encode($data, $secret), $exp];
42 }
43
44 public static function decode(string $jwt, string $secret)
45 {
46 return Main\Web\JWT::decode($jwt, $secret);
47 }
48}
if(!is_object($USER)||! $USER->IsAuthorized()) $userId
Определения check_mail.php:18
static decode($jwt, $key, array $allowed_algs=array())
Определения jwt.php:69
static encode($payload, $key, $alg='HS256', $keyId=null, $head=null)
Определения jwt.php:161
Определения jwt.php:9
const DEFAULT_TTL
Определения jwt.php:10
static create(array $channels=[], int $userId=0, array $options=[])
Определения jwt.php:15
static decode(string $jwt, string $secret)
Определения jwt.php:44
$options
Определения commerceml2.php:49
$data['IS_AVAILABLE']
Определения .description.php:13
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
Определения jwt.php:3
$time
Определения payment.php:61