File tree Expand file tree Collapse file tree 1 file changed +16
-12
lines changed Expand file tree Collapse file tree 1 file changed +16
-12
lines changed Original file line number Diff line number Diff line change @@ -25,12 +25,16 @@ export class VaultKubernetesAuthClient extends AbstractVaultClient implements IV
25
25
if ( ! this . config ) {
26
26
throw new Error ( "Kubernetes Auth Client not configured" ) ;
27
27
}
28
- if ( ! this . config . jwt ) {
29
- this . initConfig ( this . config ) ;
30
- }
31
- return this . rawWrite ( [ "/login" ] , this . config , {
32
- retryWithTokenRenew : false ,
33
- } ) . then ( ( res ) => {
28
+ return this . rawWrite (
29
+ [ "/login" ] ,
30
+ {
31
+ role : this . config . role ,
32
+ jwt : this . config . jwt ?? this . loadJwtFromPath ( ) ,
33
+ } ,
34
+ {
35
+ retryWithTokenRenew : false ,
36
+ } ,
37
+ ) . then ( ( res ) => {
34
38
tiChecker . IVaultTokenAuthResponse . check ( res ) ;
35
39
return res ;
36
40
} ) ;
@@ -42,16 +46,16 @@ export class VaultKubernetesAuthClient extends AbstractVaultClient implements IV
42
46
*/
43
47
public async login ( config ?: IVaultKubernetesAuthLoginConfig ) : Promise < IVaultKubernetesAuthLoginResponse > {
44
48
if ( config ) {
45
- this . initConfig ( config ) ;
49
+ this . config = config ;
46
50
}
47
51
return this . auth ( ) ;
48
52
}
49
53
50
- private initConfig ( config : IVaultKubernetesAuthLoginConfig ) : void {
51
- if ( ! config . jwt ) {
52
- config . jwt = fs . readFileSync ( config . jwt_path ?? "/run/secrets/kubernetes.io/serviceaccount/token" , "utf8" ) ;
53
- delete config . jwt_path ;
54
+ private loadJwtFromPath ( ) : string {
55
+ if ( ! this . config ) {
56
+ throw new Error ( "Kubernetes Auth Client not configured" ) ;
54
57
}
55
- this . config = config ;
58
+ const jwt = fs . readFileSync ( this . config . jwt_path ?? "/run/secrets/kubernetes.io/serviceaccount/token" , "utf8" ) ;
59
+ return jwt ;
56
60
}
57
61
}
You can’t perform that action at this time.
0 commit comments