|
10 | 10 | use YdbPlatform\Ydb\Auth\Implement\AnonymousAuthentication; |
11 | 11 | use YdbPlatform\Ydb\Auth\Implement\JwtWithJsonAuthentication; |
12 | 12 | use YdbPlatform\Ydb\Auth\Implement\JwtWithPrivateKeyAuthentication; |
| 13 | +use YdbPlatform\Ydb\Auth\Implement\MetadataAuthentication; |
13 | 14 | use YdbPlatform\Ydb\Auth\Implement\OAuthTokenAuthentication; |
14 | 15 | use YdbPlatform\Ydb\Contracts\IamTokenContract; |
15 | 16 |
|
@@ -153,6 +154,10 @@ protected function parseConfig(array $config) |
153 | 154 | $parsedConfig["credentials"] = $config["credentials"]; |
154 | 155 | } |
155 | 156 |
|
| 157 | + if (isset($config["refresh_token_ratio"])){ |
| 158 | + $parsedConfig["refresh_token_ratio"] = $config["refresh_token_ratio"]; |
| 159 | + } |
| 160 | + |
156 | 161 | foreach ($stringParams as $param) |
157 | 162 | { |
158 | 163 | $parsedConfig[$param] = (string)($config[$param] ?? ''); |
@@ -197,6 +202,8 @@ protected function initConfig() |
197 | 202 | else if ($this->config('use_metadata')) |
198 | 203 | { |
199 | 204 | $this->logger()->info('YDB: Authentication method: Metadata URL'); |
| 205 | + $this->config['credentials'] = new MetadataAuthentication(); |
| 206 | + $this->config['credentials']->setLogger($this->logger()); |
200 | 207 | } |
201 | 208 | else if ($serviceFile = $this->config('service_file')) |
202 | 209 | { |
@@ -237,6 +244,10 @@ protected function initConfig() |
237 | 244 | $this->config['credentials'] = new OAuthTokenAuthentication($oauthToken); |
238 | 245 | $this->config['credentials']->setLogger($this->logger()); |
239 | 246 | } |
| 247 | + |
| 248 | + if ($this->config('credentials') !== null){ |
| 249 | + $this->config['credentials']->setRefreshTokenRatio($this->config('refresh_token_ratio', 0.1)); |
| 250 | + } |
240 | 251 | else |
241 | 252 | { |
242 | 253 | throw new Exception('No authentication method is used.'); |
|
0 commit comments