* conversion stage 1 * correct image paths * add sidebar title to frontmatter * docs/concepts and docs/internals * configuration docs and multi-level nav corrections * commands docs, index file corrections, small item nav correction * secrets converted * auth * add enterprise and agent docs * add extra dividers * secret section, wip * correct sidebar nav title in front matter for apu section, start working on api items * auth and backend, a couple directory structure fixes * remove old docs * intro side nav converted * reset sidebar styles, add hashi-global-styles * basic styling for nav sidebar * folder collapse functionality * patch up border length on last list item * wip restructure for content component * taking middleman hacking to the extreme, but its working * small css fix * add new mega nav * fix a small mistake from the rebase * fix a content resolution issue with middleman * title a couple missing docs pages * update deps, remove temporary markup * community page * footer to layout, community page css adjustments * wip downloads page * deps updated, downloads page ready * fix community page * homepage progress * add components, adjust spacing * docs and api landing pages * a bunch of fixes, add docs and api landing pages * update deps, add deploy scripts * add readme note * update deploy command * overview page, index title * Update doc fields Note this still requires the link fields to be populated -- this is solely related to copy on the description fields * Update api_basic_categories.yml Updated API category descriptions. Like the document descriptions you'll still need to update the link headers to the proper target pages. * Add bottom hero, adjust CSS, responsive friendly * Add mega nav title * homepage adjustments, asset boosts * small fixes * docs page styling fixes * meganav title * some category link corrections * Update API categories page updated to reflect the second level headings for api categories * Update docs_detailed_categories.yml Updated to represent the existing docs structure * Update docs_detailed_categories.yml * docs page data fix, extra operator page remove * api data fix * fix makefile * update deps, add product subnav to docs and api landing pages * Rearrange non-hands-on guides to _docs_ Since there is no place for these on learn.hashicorp, we'll put them under _docs_. * WIP Redirects for guides to docs * content and component updates * font weight hotfix, redirects * fix guides and intro sidenavs * fix some redirects * small style tweaks * Redirects to learn and internally to docs * Remove redirect to `/vault` * Remove `.html` from destination on redirects * fix incorrect index redirect * final touchups * address feedback from michell for makefile and product downloads
9.5 KiB
layout | page_title | sidebar_title | sidebar_current | description |
---|---|---|---|---|
api | TOTP - Secrets Engines - HTTP API | TOTP | api-http-secret-totp | This is the API documentation for the Vault TOTP secrets engine. |
TOTP Secrets Engine (API)
This is the API documentation for the Vault TOTP secrets engine. For general information about the usage and operation of the TOTP secrets engine, please see the TOTP documentation.
This documentation assumes the TOTP secrets engine is enabled at the /totp
path in Vault. Since it is possible to enable secrets engines at any location,
please update your API calls accordingly.
Create Key
This endpoint creates or updates a key definition.
Method | Path | Produces |
---|---|---|
POST |
/totp/keys/:name |
if generating a key and exported is true: 200 application/json else: 204 (empty body) |
Parameters
-
name
(string: <required>)
– Specifies the name of the key to create. This is specified as part of the URL. -
generate
(bool: false)
– Specifies if a key should be generated by Vault or if a key is being passed from another service. -
exported
(bool: true)
– Specifies if a QR code and url are returned upon generating a key. Only used if generate is true. -
key_size
(int: 20)
– Specifies the size in bytes of the Vault generated key. Only used if generate is true. -
url
(string: "")
– Specifies the TOTP key url string that can be used to configure a key. Only used if generate is false. -
key
(string: <required - if generate is false and url is empty>)
– Specifies the master key used to generate a TOTP code. Only used if generate is false. -
issuer
(string: "" <required - if generate is true>)
– Specifies the name of the key’s issuing organization. -
account_name
(string: "" <required - if generate is true>)
– Specifies the name of the account associated with the key. -
period
(int or duration format string: 30)
– Specifies the length of time in seconds used to generate a counter for the TOTP code calculation. -
algorithm
(string: "SHA1")
– Specifies the hashing algorithm used to generate the TOTP code. Options include "SHA1", "SHA256" and "SHA512". -
digits
(int: 6)
– Specifies the number of digits in the generated TOTP code. This value can be set to 6 or 8. -
skew
(int: 1)
– Specifies the number of delay periods that are allowed when validating a TOTP code. This value can be either 0 or 1. Only used if generate is true. -
qr_size
(int: 200)
– Specifies the pixel size of the square QR code when generating a new key. Only used if generate is true and exported is true. If this value is 0, a QR code will not be returned.
Sample Payload
{
"url": "otpauth://totp/Google:test@gmail.com?secret=Y64VEVMBTSXCYIWRSHRNDZW62MPGVU2G&issuer=Google"
}
Sample Request
$ curl \
--header "X-Vault-Token: ..." \
--request POST \
--data @payload.json \
http://127.0.0.1:8200/v1/totp/keys/my-key
Sample Payload
{
"generate": true,
"issuer": "Google",
"account_name": "test@gmail.com",
}
Sample Request
$ curl \
--header "X-Vault-Token: ..." \
--request POST \
--data @payload.json \
http://127.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XtthIWYgiBkIYsbWh3T3nNS1dXqe6tReW8S0Hr1b5/LAQvxAEDMQxIw3H9I9nzU9R6XGHdn41dx4d4+rGp9En7OX9ReAIGYgiBlff6IWG2KwEDP+DQAA//+TDHXGhqE4+AAAAABJRU5ErkJggg==",
"url" : "otpauth://totp/Google:test@gmail.com?algorithm=SHA1&digits=6&issuer=Google&period=30&secret=HTXT7KJFVNAJUPYWQRWMNVQE5AF5YZI2",
}
}
If a QR code is returned, it consists of base64-formatted PNG bytes. You can embed it in a web page by including the base64 string in an img
tag with the prefix data:image/png;base64
<img src="data:image/png;base64,iVBORw0KGgoAAAANSUh.." />
Read Key
This endpoint queries the key definition.
Method | Path | Produces |
---|---|---|
GET |
/totp/keys/:name |
200 application/json |
Parameters
name
(string: <required>)
– Specifies the name of the key to read. This is specified as part of the URL.
Sample Request
$ curl \
--header "X-Vault-Token: ..." \
http://127.0.0.1:8200/v1/totp/keys/my-key
Sample Response
{
"data": {
"account_name": "test@gmail.com",
"algorithm" : "SHA1",
"digits" : 6,
"issuer": "Google",
"period" : 30,
}
}
List Keys
This endpoint returns a list of available keys. Only the key names are returned, not any values.
Method | Path | Produces |
---|---|---|
LIST |
/totp/keys |
200 application/json |
Sample Request
$ curl \
--header "X-Vault-Token: ..." \
--request LIST \
http://127.0.0.1:8200/v1/totp/keys
Sample Response
{
"auth": null,
"data": {
"keys": ["my-key"]
},
"lease_duration": 0,
"lease_id": "",
"renewable": false
}
Delete Key
This endpoint deletes the key definition.
Method | Path | Produces |
---|---|---|
DELETE |
/totp/keys/:name |
204 (empty body) |
Parameters
name
(string: <required>)
– Specifies the name of the key to delete. This is specified as part of the URL.
Sample Request
$ curl \
--header "X-Vault-Token: ..." \
--request DELETE \
http://127.0.0.1:8200/v1/totp/keys/my-key
Generate Code
This endpoint generates a new time-based one-time use password based on the named key.
Method | Path | Produces |
---|---|---|
GET |
/totp/code/:name |
200 application/json |
Parameters
name
(string: <required>)
– Specifies the name of the key to create credentials against. This is specified as part of the URL.
Sample Request
$ curl \
--header "X-Vault-Token: ..." \
http://127.0.0.1:8200/v1/totp/code/my-key
Sample Response
{
"data": {
"code": "810920",
}
}
Validate Code
This endpoint validates a time-based one-time use password generated from the named key.
Method | Path | Produces |
---|---|---|
POST |
/totp/code/:name |
200 application/json |
Parameters
-
name
(string: <required>)
– Specifies the name of the key used to generate the password. This is specified as part of the URL. -
code
(string: <required>)
– Specifies the password you want to validate.
Sample Payload
{
"code": "123802"
}
Sample Request
$ curl \
--header "X-Vault-Token: ..." \
--request POST \
--data @payload.json \
http://127.0.0.1:8200/v1/totp/code/my-key
Sample Response
{
"data": {
"valid": true,
}
}