namecheap / node-vault-client

A Vault Client implemented in pure javascript for HashiCorp Vault
Apache License 2.0
22 stars 21 forks source link

custom namespace settings #22

Closed venkatakondaveti closed 1 year ago

venkatakondaveti commented 2 years ago

Hi Team,

First of all thanks. I'm trying to use this library and connect to vault for a custom namespace rather than default (root) namespace using aws IAM Auth.

But looks like it's always trying to connect to ROOT namespace. Cant find the any vars/config to set namespace as parameter during client initialisation.

If I create a same aws IAM auth role in ROOT namespace it works.

Am I missing anything here or could someone please redirect me to the right settings for this. Thanks.

mh377 commented 2 years ago

I have created a pull request to set an X-Vault-Namespace header that can be configured with a new namespace config property

VaultClient.boot('main', {
        api: { url: VAULT_ADDR },
        auth: {
            type: 'iam',
            mount: 'some_other_aws_mount_point',          // Optional
            config: {
                role: 'my_iam_role',
                iam_server_id_header_value: VAULT_ADDR,   // Optional
                namespace: 'some_namespace',              // Optional
                credentials: new AWS.Credentials({
                 accessKeyId: AWS_ACCESS_KEY,
                  secretAccessKey: AWS_SECRET_KEY,
                })
            }
        }
    })

Please see my Pull Request

b1ff commented 2 years ago

0.6.0 is published with the updates from @mh377