2
2
3
3
namespace YdbPlatform \Ydb \Auth \Implement ;
4
4
5
- use YdbPlatform \Ydb \Auth \Auth ;
5
+ use YdbPlatform \Ydb \Auth \IamAuth ;
6
6
use YdbPlatform \Ydb \Auth \TokenInfo ;
7
7
use YdbPlatform \Ydb \Auth \UseConfigInterface ;
8
- use YdbPlatform \Ydb \AuthService ;
9
8
use YdbPlatform \Ydb \Ydb ;
10
9
11
- class StaticAuthentication extends Auth implements UseConfigInterface
10
+ class StaticAuthentication extends IamAuth implements UseConfigInterface
12
11
{
13
12
protected $ user ;
14
13
protected $ password ;
@@ -27,10 +26,11 @@ public function __construct(string $user, string $password)
27
26
public function getTokenInfo (): TokenInfo
28
27
{
29
28
$ this ->token = $ this ->ydb ->auth ()->getToken ($ this ->user , $ this ->password );
30
- $ expiresIn = 12 *60 *60 ;
29
+ $ jwtData = $ this ->decodeHeaderAndPayload ($ this ->token );
30
+ $ expiresIn = $ this ->convertExpiresAt ($ jwtData ['payload ' ]['exp ' ]);
31
31
$ ratio = $ this ->getRefreshTokenRatio ();
32
32
33
- return new TokenInfo ($ this ->token , time ()+ $ expiresIn , $ ratio );
33
+ return new TokenInfo ($ this ->token , $ expiresIn , $ ratio );
34
34
}
35
35
36
36
public function getName (): string
@@ -41,7 +41,7 @@ public function getName(): string
41
41
public function setYdbConnectionConfig (array $ config )
42
42
{
43
43
unset($ config ['credentials ' ]);
44
- $ config ['credentials ' ] = new AccessTokenAuthentication ( '' );
44
+ $ config ['credentials ' ] = new AnonymousAuthentication ( );
45
45
$ this ->ydb = new Ydb ($ config , $ this ->logger );
46
46
}
47
47
}
0 commit comments