/
githubmirror
/
ydb-php-sdk
Обзор
Документация
Войти
/
githubmirror
/
ydb-php-sdk
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
src/Auth/JwtAuth.php
32 строки
666 B
Ilya Kharev
Added credentials authentication
03 май 2023, 11:14
03 май 2023, 11:14
e4a5458
Код
Авторство
О чём код?
<?php namespace YdbPlatform\Ydb\Auth; use DateTimeImmutable; use YdbPlatform\Ydb\Iam; use YdbPlatform\Ydb\Jwt\Jwt; abstract class JwtAuth extends IamAuth { protected $key_id; protected $private_key; protected $service_account_id; /** * @return string */ protected function getJwtToken() { $now = new DateTimeImmutable; $token = (new Jwt($this->private_key, $this->key_id)) ->issuedBy($this->service_account_id) ->issuedAt($now) ->expiresAt($now->modify('+1 hour')) ->permittedFor(Iam::IAM_TOKEN_API_URL) ->getToken(); return $token; } }