1C-Bitrix
25.700.0
Загрузка...
Поиск...
Не найдено
jwt.php
См. документацию.
1
<?php
2
3
namespace
Bitrix\Pull\Auth
;
4
5
use
Bitrix\Main
;
6
use
Bitrix\Pull\Config
;
7
8
final
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
}
$userId
if(!is_object($USER)||! $USER->IsAuthorized()) $userId
Определения
check_mail.php:18
Bitrix\Main\ArgumentException
Определения
ArgumentException.php:9
Bitrix\Main\Web\JWT\decode
static decode($jwt, $key, array $allowed_algs=array())
Определения
jwt.php:69
Bitrix\Main\Web\JWT\encode
static encode($payload, $key, $alg='HS256', $keyId=null, $head=null)
Определения
jwt.php:161
Bitrix\Pull\Auth\Jwt
Определения
jwt.php:9
Bitrix\Pull\Auth\Jwt\DEFAULT_TTL
const DEFAULT_TTL
Определения
jwt.php:10
Bitrix\Pull\Auth\Jwt\create
static create(array $channels=[], int $userId=0, array $options=[])
Определения
jwt.php:15
Bitrix\Pull\Auth\Jwt\decode
static decode(string $jwt, string $secret)
Определения
jwt.php:44
$options
$options
Определения
commerceml2.php:49
$data
$data['IS_AVAILABLE']
Определения
.description.php:13
array
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения
file_new.php:804
Bitrix\Main\Config
Определения
configuration.php:3
Bitrix\Main
Bitrix\Pull\Auth
Определения
jwt.php:3
$time
$time
Определения
payment.php:61
bitrix
modules
pull
lib
auth
jwt.php
Создано системой
1.14.0