/
githubmirror
/
ydb-php-sdk
Обзор
Документация
Войти
/
githubmirror
/
ydb-php-sdk
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
v1.13.0
src/AuthService.php
48 строк
1 KB
Илья
Added StaticAuthentication
04 сен 2023, 17:47
04 сен 2023, 17:47
1402d45
Код
Авторство
О чём код?
<?php namespace YdbPlatform\Ydb; use Ydb\Auth\V1\AuthServiceClient as ServiceClient; class AuthService{ use Traits\RequestTrait; use Traits\ParseResultTrait; use Traits\LoggerTrait; /** * @var ServiceClient */ protected $client; /** * @var */ protected $logger; /** * @var array|mixed */ protected $meta; /** * @var Iam */ protected $credentials; public function __construct(Ydb $ydb, $logger) { $this->ydb = $ydb; $this->logger = $logger; $this->client = new ServiceClient($ydb->endpoint(), [ 'credentials' => $ydb->iam()->getCredentials(), ]); $this->credentials = $ydb->iam(); $this->meta = [ 'x-ydb-database' => [$ydb->database()], 'x-ydb-sdk-build-info' => ['ydb-php-sdk/' . Ydb::VERSION], ];; } public function getToken(string $user, string $password){ $data = []; $data["user"] = $user; $data["password"] = $password; $data["skip_get_token"] = true; return $this->doRequest('Auth', 'Login', $data)->getToken(); } }