2015-04-14 00:56:59 +00:00
|
|
|
---
|
|
|
|
layout: "docs"
|
|
|
|
page_title: "Secret Backend: Generic"
|
|
|
|
sidebar_current: "docs-secrets-generic"
|
|
|
|
description: |-
|
|
|
|
The generic secret backend can store arbitrary secrets.
|
|
|
|
---
|
|
|
|
|
|
|
|
# Generic Secret Backend
|
|
|
|
|
|
|
|
Name: `generic`
|
|
|
|
|
|
|
|
The generic secret backend is used to store arbitrary secrets within
|
|
|
|
the configured physical storage for Vault. If you followed along with
|
|
|
|
the getting started guide, you interacted with a generic secret backend
|
2015-09-21 15:22:48 +00:00
|
|
|
via the `secret/` prefix that Vault mounts by default. You can mount as many
|
|
|
|
of these backends at different mount points as you like.
|
2015-04-14 00:56:59 +00:00
|
|
|
|
2016-01-14 19:18:27 +00:00
|
|
|
Writing to a key in the `generic` backend will replace the old value;
|
2015-09-21 15:22:48 +00:00
|
|
|
sub-fields are not merged together.
|
2015-05-11 17:58:21 +00:00
|
|
|
|
2016-01-07 20:10:05 +00:00
|
|
|
This backend honors the distinction between the `create` and `update`
|
|
|
|
capabilities inside ACL policies.
|
|
|
|
|
2015-10-29 15:21:40 +00:00
|
|
|
**Note**: Path and key names are _not_ obfuscated or encrypted; only the values
|
|
|
|
set on keys are. You should not store sensitive information as part of a
|
|
|
|
secret's path.
|
|
|
|
|
2015-04-14 00:56:59 +00:00
|
|
|
## Quick Start
|
|
|
|
|
2016-06-09 00:14:36 +00:00
|
|
|
The generic backend allows for writing keys with arbitrary values. When data is
|
|
|
|
returned, the `lease_duration` field (in the API JSON) or `refresh_interval`
|
|
|
|
field (on the CLI) gives a hint as to how often a reader should look for a new
|
|
|
|
value. This comes from the value of the `default_lease_ttl` set on the mount,
|
|
|
|
or the system value.
|
|
|
|
|
|
|
|
There is one piece of special data handling: if a `ttl` key is provided, it
|
|
|
|
will be treated as normal data, but on read the backend will attempt to parse
|
|
|
|
it as a duration (either as a string like `1h` or an integer number of seconds
|
|
|
|
like `3600`). If successful, the backend will use this value in place of the
|
|
|
|
normal `lease_duration`. However, the given value will also still be returned
|
|
|
|
exactly as specified, so you are free to use that key in any way that you like
|
|
|
|
if it fits your input data.
|
2015-08-20 23:41:25 +00:00
|
|
|
|
2016-03-18 13:57:21 +00:00
|
|
|
As an example, we can write a new key "foo" to the generic backend mounted at
|
|
|
|
"secret/" by default:
|
2015-04-27 02:14:41 +00:00
|
|
|
|
|
|
|
```
|
2015-10-12 16:10:22 +00:00
|
|
|
$ vault write secret/foo \
|
|
|
|
zip=zap \
|
|
|
|
ttl=1h
|
2015-04-27 02:14:41 +00:00
|
|
|
Success! Data written to: secret/foo
|
|
|
|
```
|
|
|
|
|
2015-09-21 15:22:48 +00:00
|
|
|
This writes the key with the "zip" field set to "zap" and a one hour TTL.
|
|
|
|
We can test this by doing a read:
|
2015-04-27 02:14:41 +00:00
|
|
|
|
|
|
|
```
|
|
|
|
$ vault read secret/foo
|
2016-06-09 00:14:36 +00:00
|
|
|
Key Value
|
|
|
|
--- -----
|
|
|
|
refresh_interval 3600
|
|
|
|
ttl 1h
|
|
|
|
zip zap
|
2015-04-27 02:14:41 +00:00
|
|
|
```
|
|
|
|
|
2016-06-09 00:14:36 +00:00
|
|
|
As expected, we get the values previously set back as well as our custom TTL
|
2016-03-18 13:57:21 +00:00
|
|
|
both as specified and translated to seconds. The duration has been set to 3600
|
2015-09-21 15:22:48 +00:00
|
|
|
seconds (one hour) as specified.
|
|
|
|
|
|
|
|
## API
|
|
|
|
|
|
|
|
#### GET
|
|
|
|
|
|
|
|
<dl class="api">
|
|
|
|
<dt>Description</dt>
|
|
|
|
<dd>
|
|
|
|
Retrieves the secret at the specified location.
|
|
|
|
</dd>
|
|
|
|
|
|
|
|
<dt>Method</dt>
|
|
|
|
<dd>GET</dd>
|
|
|
|
|
|
|
|
<dt>URL</dt>
|
|
|
|
<dd>`/secret/<path>`</dd>
|
|
|
|
|
|
|
|
<dt>Parameters</dt>
|
|
|
|
<dd>
|
|
|
|
None
|
|
|
|
</dd>
|
|
|
|
|
|
|
|
<dt>Returns</dt>
|
|
|
|
<dd>
|
|
|
|
|
|
|
|
```javascript
|
|
|
|
{
|
2015-10-12 16:10:22 +00:00
|
|
|
"auth": null,
|
|
|
|
"data": {
|
|
|
|
"foo": "bar"
|
|
|
|
},
|
2016-09-28 22:32:49 +00:00
|
|
|
"lease_duration": 2764800,
|
2015-10-12 16:10:22 +00:00
|
|
|
"lease_id": "",
|
|
|
|
"renewable": false
|
2015-09-21 15:22:48 +00:00
|
|
|
}
|
|
|
|
```
|
2015-10-12 16:10:22 +00:00
|
|
|
|
2015-09-21 15:22:48 +00:00
|
|
|
</dd>
|
|
|
|
</dl>
|
|
|
|
|
2016-01-14 19:18:27 +00:00
|
|
|
#### LIST
|
|
|
|
|
|
|
|
<dl class="api">
|
|
|
|
<dt>Description</dt>
|
|
|
|
<dd>
|
2016-04-20 22:13:58 +00:00
|
|
|
Returns a list of key names at the specified location. Folders are
|
2016-01-19 22:05:01 +00:00
|
|
|
suffixed with `/`. The input must be a folder; list on a file will not
|
2016-04-20 22:13:58 +00:00
|
|
|
return a value. Note that no policy-based filtering is performed on keys;
|
|
|
|
do not encode sensitive information in key names. The values themselves
|
|
|
|
are not accessible via this command.
|
2016-01-14 19:18:27 +00:00
|
|
|
</dd>
|
|
|
|
|
|
|
|
<dt>Method</dt>
|
2016-09-30 19:47:33 +00:00
|
|
|
<dd>LIST/GET</dd>
|
2016-01-14 19:18:27 +00:00
|
|
|
|
|
|
|
<dt>URL</dt>
|
2016-09-30 19:47:33 +00:00
|
|
|
<dd>`/secret/<path>` (LIST) or `/secret/<path>?list=true` (GET)</dd>
|
2016-01-14 19:18:27 +00:00
|
|
|
|
|
|
|
<dt>Parameters</dt>
|
|
|
|
<dd>
|
|
|
|
None
|
|
|
|
</dd>
|
|
|
|
|
|
|
|
<dt>Returns</dt>
|
|
|
|
<dd>
|
|
|
|
The example below shows output for a query path of `secret/` when there are
|
|
|
|
secrets at `secret/foo` and `secret/foo/bar`; note the difference in the two
|
|
|
|
entries.
|
|
|
|
|
|
|
|
```javascript
|
|
|
|
{
|
|
|
|
"auth": null,
|
|
|
|
"data": {
|
2016-01-19 22:05:01 +00:00
|
|
|
"keys": ["foo", "foo/"]
|
2016-01-14 19:18:27 +00:00
|
|
|
},
|
2016-09-28 22:32:49 +00:00
|
|
|
"lease_duration": 2764800,
|
2016-01-14 19:18:27 +00:00
|
|
|
"lease_id": "",
|
|
|
|
"renewable": false
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
</dd>
|
|
|
|
</dl>
|
|
|
|
|
2015-09-21 15:22:48 +00:00
|
|
|
#### POST/PUT
|
|
|
|
|
|
|
|
<dl class="api">
|
|
|
|
<dt>Description</dt>
|
|
|
|
<dd>
|
2016-01-07 20:10:05 +00:00
|
|
|
Stores a secret at the specified location. If the value does not yet exist,
|
|
|
|
the calling token must have an ACL policy granting the `create` capability.
|
|
|
|
If the value already exists, the calling token must have an ACL policy
|
|
|
|
granting the `update` capability.
|
2015-09-21 15:22:48 +00:00
|
|
|
</dd>
|
|
|
|
|
|
|
|
<dt>Method</dt>
|
|
|
|
<dd>POST/PUT</dd>
|
|
|
|
|
|
|
|
<dt>URL</dt>
|
|
|
|
<dd>`/secret/<path>`</dd>
|
|
|
|
|
|
|
|
<dt>Parameters</dt>
|
|
|
|
<dd>
|
|
|
|
<ul>
|
|
|
|
<li>
|
|
|
|
<span class="param">(key)</span>
|
|
|
|
<span class="param-flags">optional</span>
|
2016-06-09 00:14:36 +00:00
|
|
|
A key, paired with an associated value, to be held at the given
|
|
|
|
location. Multiple key/value pairs can be specified, and all will be
|
|
|
|
returned on a read operation. A key called `ttl` will trigger some
|
|
|
|
special behavior; see above for details.
|
2015-09-21 15:22:48 +00:00
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
</dd>
|
|
|
|
|
|
|
|
<dt>Returns</dt>
|
|
|
|
<dd>
|
|
|
|
A `204` response code.
|
|
|
|
</dd>
|
|
|
|
</dl>
|
2016-01-26 07:56:33 +00:00
|
|
|
|
|
|
|
#### DELETE
|
|
|
|
|
|
|
|
<dl class="api">
|
|
|
|
<dt>Description</dt>
|
|
|
|
<dd>
|
|
|
|
Deletes the secret at the specified location.
|
|
|
|
</dd>
|
|
|
|
|
|
|
|
<dt>Method</dt>
|
|
|
|
<dd>DELETE</dd>
|
|
|
|
|
|
|
|
<dt>URL</dt>
|
|
|
|
<dd>`/secret/<path>`</dd>
|
|
|
|
|
|
|
|
<dt>Parameters</dt>
|
|
|
|
<dd>
|
|
|
|
None
|
|
|
|
</dd>
|
|
|
|
|
|
|
|
<dt>Returns</dt>
|
|
|
|
<dd>
|
|
|
|
A `204` response code.
|
|
|
|
</dd>
|
|
|
|
</dl>
|