Skip to content

Commit ee3d872

Browse files
kakocKonstantin Matsiushonak
andauthored
feat(vault-namespace): set 'X-Vault-Namespace' when a client has it (#137)
Co-authored-by: Konstantin Matsiushonak <Konstantin_Matsiushonak@epam.com>
1 parent 6d6a6fa commit ee3d872

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

src/index.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ module.exports = (config = {}) => {
6969
client.pathPrefix = config.pathPrefix || process.env.VAULT_PREFIX || '';
7070
client.token = config.token || process.env.VAULT_TOKEN;
7171
client.noCustomHTTPVerbs = config.noCustomHTTPVerbs || false;
72+
client.namespace = config.namespace || process.env.VAULT_NAMESPACE;
7273

7374
const requestSchema = {
7475
type: 'object',
@@ -94,6 +95,9 @@ module.exports = (config = {}) => {
9495
if (typeof client.token === 'string' && client.token.length) {
9596
options.headers['X-Vault-Token'] = options.headers['X-Vault-Token'] || client.token;
9697
}
98+
if (typeof client.namespace === 'string' && client.namespace.length) {
99+
options.headers['X-Vault-Namespace'] = client.namespace;
100+
}
97101
options.uri = uri;
98102
debug(options.method, uri);
99103
if (options.json) debug(options.json);

test/unit.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ describe('node-vault', () => {
125125
const vaultConfig = {
126126
endpoint: 'http://localhost:8200',
127127
token: '123',
128+
namespace: 'test',
128129
'request-promise': {
129130
defaults: () => request, // dependency injection of stub
130131
},

0 commit comments

Comments
 (0)