File tree Expand file tree Collapse file tree 4 files changed +15
-14
lines changed
schemaregistry/rules/encryption Expand file tree Collapse file tree 4 files changed +15
-14
lines changed Original file line number Diff line number Diff line change @@ -9,10 +9,6 @@ export class HcVaultClient implements KmsClient {
9
9
private keyName : string
10
10
11
11
constructor ( keyUri : string , namespace ?: string , token ?: string ) {
12
- if ( token == null )
13
- {
14
- namespace = process . env [ "VAULT_NAMESPACE" ]
15
- }
16
12
if ( ! keyUri . startsWith ( HcVaultDriver . PREFIX ) ) {
17
13
throw new Error ( `key uri must start with ${ HcVaultDriver . PREFIX } ` )
18
14
}
Original file line number Diff line number Diff line change @@ -20,8 +20,13 @@ export class HcVaultDriver implements KmsDriver {
20
20
21
21
newKmsClient ( config : Map < string , string > , keyUrl ?: string ) : KmsClient {
22
22
const uriPrefix = keyUrl != null ? keyUrl : HcVaultDriver . PREFIX
23
- const tokenId = config . get ( HcVaultDriver . TOKEN_ID )
24
- const ns = config . get ( HcVaultDriver . NAMESPACE )
23
+ let tokenId = config . get ( HcVaultDriver . TOKEN_ID )
24
+ let ns = config . get ( HcVaultDriver . NAMESPACE )
25
+ if ( tokenId == null )
26
+ {
27
+ tokenId = process . env [ "VAULT_TOKEN" ]
28
+ ns = process . env [ "VAULT_NAMESPACE" ]
29
+ }
25
30
return new HcVaultClient ( uriPrefix , ns , tokenId )
26
31
}
27
32
}
Original file line number Diff line number Diff line change @@ -10,13 +10,7 @@ export class LocalKmsClient implements KmsClient {
10
10
private secret : string
11
11
private cryptor : Cryptor
12
12
13
- constructor ( secret ?: string ) {
14
- if ( secret == null ) {
15
- secret = process . env [ 'LOCAL_SECRET' ]
16
- }
17
- if ( secret == null ) {
18
- throw new Error ( 'cannot load secret' )
19
- }
13
+ constructor ( secret : string ) {
20
14
this . secret = secret
21
15
this . cryptor = new Cryptor ( DekFormat . AES128_GCM )
22
16
}
Original file line number Diff line number Diff line change @@ -18,7 +18,13 @@ export class LocalKmsDriver implements KmsDriver {
18
18
}
19
19
20
20
newKmsClient ( config : Map < string , string > , keyUrl : string ) : KmsClient {
21
- const secret = config . get ( LocalKmsDriver . SECRET )
21
+ let secret = config . get ( LocalKmsDriver . SECRET )
22
+ if ( secret == null ) {
23
+ secret = process . env [ 'LOCAL_SECRET' ]
24
+ }
25
+ if ( secret == null ) {
26
+ throw new Error ( 'cannot load secret' )
27
+ }
22
28
return new LocalKmsClient ( secret )
23
29
}
24
30
}
You can’t perform that action at this time.
0 commit comments