Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Vault EngineType #14

Merged
merged 1 commit into from
Oct 2, 2019
Merged

Add Vault EngineType #14

merged 1 commit into from
Oct 2, 2019

Conversation

sergiosalvatore
Copy link
Collaborator

Apparently, Vault secrets engines have slightly different API responses
which need to be parsed differently. In particular, kv-v2 (version 2 of
the Key/Value secrets engine) has an extra layer of data wrapping so
responses look like this:

{
  "request_id": "78b921ae-79a8-d7e3-da16-336b634fff22",
  "lease_id": "",
  "renewable": false,
  "lease_duration": 0,
  "data": {
    "data": {
      "foo": "world"
    },
    "metadata": {
      "created_time": "2019-10-01T19:36:25.285387Z",
      "deletion_time": "",
      "destroyed": false,
      "version": 1
    }
  },
  "wrap_info": null,
  "warnings": null,
  "auth": null
}

Data data data data data.

kv version1 secrets look like this:

{
  "request_id": "12a0c057-f475-4bbd-6305-e4c07e66805c",
  "lease_id": "",
  "renewable": false,
  "lease_duration": 2764800,
  "data": {
    "foo": "world"
  },
  "wrap_info": null,
  "warnings": null,
  "auth": null
}

Since we don't know which version Vault will have mounted where we have
to specify an engine type per mapping. This is inconvenient, so I've
also added a defaultEngineType which will be used when one isn't
defined at the mapping level.

Also, all tests have been updated to run with all engine types to catch
any issues.

Copy link
Collaborator

@dfinkel dfinkel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just one nit

vault/vault.go Outdated Show resolved Hide resolved
Apparently, Vault secrets engines have slightly different API responses
which need to be parsed differently.  In particular, kv-v2 (version 2 of
the Key/Value secrets engine) has an extra layer of data wrapping so
responses look like this:

```json
{
  "request_id": "78b921ae-79a8-d7e3-da16-336b634fff22",
  "lease_id": "",
  "renewable": false,
  "lease_duration": 0,
  "data": {
    "data": {
      "foo": "world"
    },
    "metadata": {
      "created_time": "2019-10-01T19:36:25.285387Z",
      "deletion_time": "",
      "destroyed": false,
      "version": 1
    }
  },
  "wrap_info": null,
  "warnings": null,
  "auth": null
}
```

Data data data data data.

kv version1 secrets look like this:
```json
{
  "request_id": "12a0c057-f475-4bbd-6305-e4c07e66805c",
  "lease_id": "",
  "renewable": false,
  "lease_duration": 2764800,
  "data": {
    "foo": "world"
  },
  "wrap_info": null,
  "warnings": null,
  "auth": null
}
```

Since we don't know which version Vault will have mounted where we have
to specify an engine type per mapping.  This is inconvenient, so I've
also added a `defaultEngineType` which will be used when one isn't
defined at the mapping level.

Also, all tests have been updated to run with all engine types to catch
any issues.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants