chiefy / vaulted

nodejs based wrapper for HashiCorp's Vault HTTP API
https://chiefy.github.io/vaulted
MIT License
47 stars 6 forks source link

cannot pass array of rules #57

Closed jmls closed 8 years ago

jmls commented 8 years ago

Following on from the excellent work done in https://github.com/chiefy/vaulted/issues/46 , there is a small problem in that although the vaulted code allows it, passing an array of rules to createPolicy barfs on the vault side

 vault.createPolicy({
            id: "path1",
            body: {
              rules: [{"secret/path1": {policy: "write"}}]
            }
        })

gives an error of

error: { errors: [ 'Failed to parse ACL rules: Line 1, column 1: syntax error' ] },

but if you pass in

 rules: {"secret/path1": {policy: "write"}}

all is well

kenjones-cisco commented 8 years ago

There are no arrays, it is all still a hash. In the Vault issues, the question of getting examples of policies in json was submitted (https://github.com/hashicorp/vault/issues/582). The last entry shows multiple policies example.

jmls commented 8 years ago

yeah, I was just looking at line 76 of policy.js where the code says

 (_.isPlainObject(options.body.rules) || _.isArray(options.body.rules))) {

so you are explicitly allowing an array to be passed - this will obviously not work, so I thought it would be better to throw an error at this point rather than at the vault side

kenjones-cisco commented 8 years ago

I thought an array might work at first but forgot to remove it. I will be dropping the check for array shortly.

kenjones-cisco commented 8 years ago

I will create add an item to include type checking for all parameters. Currently there is only checking for required inputs, but type checking has not been included as of yet.

Array check removed with commit a9afcb76fd4e5470e9993d9b41a572abd21cad24

kenjones-cisco commented 8 years ago

Feature request #61 created

closing this request.