File tree Expand file tree Collapse file tree 1 file changed +40
-0
lines changed Expand file tree Collapse file tree 1 file changed +40
-0
lines changed Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace YdbPlatform \Ydb \Auth ;
4
+
5
+ use YdbPlatform \Ydb \Auth \Implement \AccessTokenAuthentication ;
6
+ use YdbPlatform \Ydb \Auth \Implement \AnonymousAuthentication ;
7
+ use YdbPlatform \Ydb \Auth \Implement \JwtWithJsonAuthentication ;
8
+ use YdbPlatform \Ydb \Auth \Implement \MetadataAuthentication ;
9
+
10
+ class EnvironCredentials extends \YdbPlatform \Ydb \Auth \Auth
11
+ {
12
+ /**
13
+ * @var Auth
14
+ */
15
+ protected $ auth ;
16
+ public function __construct ()
17
+ {
18
+ if ($ jsonfile = getenv ("YDB_SERVICE_ACCOUNT_KEY_FILE_CREDENTIALS " )){
19
+ $ this ->auth = new JwtWithJsonAuthentication ($ jsonfile );
20
+ } elseif (getenv ("YDB_ANONYMOUS_CREDENTIALS " ) == 1 ){
21
+ $ this ->auth = new AnonymousAuthentication ();
22
+ } elseif (getenv ("YDB_METADATA_CREDENTIALS " ) == 1 ){
23
+ $ this ->auth = new MetadataAuthentication ();
24
+ } elseif ($ token = getenv ("YDB_ACCESS_TOKEN_CREDENTIALS " )){
25
+ $ this ->auth = new AccessTokenAuthentication ($ token );
26
+ } else {
27
+ $ this ->auth = new MetadataAuthentication ();
28
+ }
29
+ }
30
+
31
+ public function getTokenInfo (): TokenInfo
32
+ {
33
+ return $ this ->auth ->getTokenInfo ();
34
+ }
35
+
36
+ public function getName (): string
37
+ {
38
+ return $ this ->auth ->getName ();
39
+ }
40
+ }
You can’t perform that action at this time.
0 commit comments