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

secret/generic: TTL ignored when sent as integer #2697

Closed
stampycode opened this issue May 9, 2017 · 7 comments
Closed

secret/generic: TTL ignored when sent as integer #2697

stampycode opened this issue May 9, 2017 · 7 comments
Milestone

Comments

@stampycode
Copy link
Contributor

Sets the TTL to 300 seconds:

curl --request PUT --data '{"2": "abcd", "ttl": "300"}' \
    --header "X-Vault-Token: ${VAULT_TOKEN}" \
    ${VAULT_ADDR}/v1/secret/foo

Ignores the TTL value, with no error or warning:

curl --request PUT --data '{"2": "efgh", "ttl": 300}' \
    --header "X-Vault-Token: ${VAULT_TOKEN}" \
    ${VAULT_ADDR}/v1/secret/foo

The behaviour of the TTL field also isn't explained in the api docs, which is another issue.

@jefferai
Copy link
Member

jefferai commented May 9, 2017

It actually is explained in the docs. From the docs:

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.

@jefferai
Copy link
Member

jefferai commented May 9, 2017

(I didn't close this because not properly handling a non-string is indeed a bug and we'll fix it.)

@jefferai jefferai added this to the 0.7.3 milestone May 9, 2017
@stampycode
Copy link
Contributor Author

stampycode commented May 9, 2017

@jefferai I was actually referring to the API docs which says:

see above for details.

The normal docs don't provide JSON formatted/CURL examples.

@jefferai
Copy link
Member

jefferai commented May 9, 2017

Ah. Whoever split the docs missed that "see above for details". I'll point that to the non-API section of the docs.

@stampycode
Copy link
Contributor Author

Also, is there something special that I have to do to the server to enforce the TTL values? Because I set a secret entry in there to 10 seconds a few minutes ago, and it's still just as available as it was when I created it.... Have I misunderstood the purpose of the TTL?

@jefferai
Copy link
Member

jefferai commented May 9, 2017

The generic backend does not remove values. It's meant for a writer of a piece of data to give a hint to a reader of a piece of data as to how often to refresh the data, to prevent readers from spin-looping and flooding Vault with requests (for instance, tools such as consul-template will honor this value).

@jefferai
Copy link
Member

jefferai commented May 9, 2017

The paragraph above what I quoted before explains this:

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.

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

No branches or pull requests

2 participants