Vault Gatekeeper

Vault Gatekeeper

  • Docs
  • API
  • CLI

›Documentation

Documentation

  • Documentation
  • API Reference
  • CLI Documentation

API Reference

Gatekeeper exposes a JSON HTTP API. The primary way of communicating with Gatekeeper is through the API.

Standard Responses

The API will return a standard response for several the endpoints.

{
    "unsealed": bool,
    "message": "string",
    "error": "string"
}
NameTypeDescription
unsealedbooleanSeal status of the Gatekeeper instance.
messagestringIf the request succeeded, this field may contain a message.
errorstringIf an error occurred, this field will describe the error.

POST /token

Retrieve a response wrapped Vault token.

Parameters

NameTypeDescription
task_idstring, requiredThe task ID, as reported to the service by the container scheduler. On Mesos, this will usually be in the environment variable $MESOS_TASK_ID.
schedulerstringThe scheduler that the task is scheduled on. If none is provided, Gatekeeper assumes the default.
rolestringThe AppRole name requested by the task. If none is provided, Gatekeeper assigns the default for the task.

Response

JSON

A successful response will return a JSON object including the token.

NameTypeDescription
tokenstringThe response wrapped token ID. Use this token ID in the call to sys/wrapping/unwrap to retrieve the actual token.
ttlstringThe time-to-live on the response wrapped token.
vault_addrstringThe address to the vault server were the token was created.

HTTP Status Code

CodeDescription
200The token was generated successfully.
401The task_id provided, or the host requesting a token is not authorized to request tokens.
403The request for a token is no longer valid, may be because the task has been running for too long.
429The task has already been given its full allotment of tokens. Under normal conditions this may be considered a security error. If a service had expected to receive a token, and got this error, the token may have been stolen.
500An internal server error occurred.
503A token cannot be retrieved because the Gatekeeper is sealed.

Example

import os
import json
import requests

r = requests.post("https://gatekeeper.internal:9201/token",
                  data=json.dumps({"task_id": os.environ['MESOS_TASK_ID']}))

if r.status_code == 200:
    t = r.json()['token']
    vault_addr = r.json()['vault_addr']
    r = requests.post(vault_addr + "v1/sys/wrapping/unwrap",
                      headers={"X-Vault-Token": t})
    if r.status_code == 200:
        print("Got the vault token: ", r.json()['auth']['client_token'])
    else:
        print("An error occurred: {}".format(r.text))
else:
    print("An error occurred: {}".format(r.text))

GET /status

Get the status of the Gatekeeper instance.

Response

JSON

NameTypeDescription
idstringPeer ID of this instance.
uptimestringThe uptime of this instance.
unsealedboolSealed status of this instance.
startedtimestampThe time this instance was started.
versionstringThe version this instance is running.
peerslistThe list of peers, if running in high availability mode.
peers[].idstringThe id of the peer.
peers[].addressstringThe address of the peer.
peers[].unsealedboolSealed status of the peer.
statsobjectVarious metrics for this instance.
stats.requestsintegerThe number of token requests served by this instance.
stats.successfulintegerThe number of token successful requests served by this instance.
stats.deniedintegerThe number of token denied requests served by this instance.
stats.failedintegerThe number of token failed requests served by this instance.

A denied request is one that Gatekeeper denied due to authorization policies. A failed request is one Gatekeeper was unable to serve due to any server issues.

HTTP Status Code

CodeDescription
200Gatekeeper is unsealed and serving requests.
503Gatekeeper is sealed.

POST /seal

Seals the gatekeeper instance.

POST /unseal

Unseal the gatekeeper instance.

Parameters

NameTypeDescription
methodstring, requiredThe method to use for unsealing. One of token, token-wrapped, approle or aws.
tokenstringThe token for token or token-wrapped authentication methods.
role_idstringThe role_id for the approle authentication method.
secret_idstringThe secret_id for the approle authentication method.
aws_rolestringThe AWS IAM role for the aws authentication method.
aws_noncestringThe AWS nonce for the aws authentication method.

Response

HTTP Status Code

CodeDescription
200Gatekeeper was unsealed successfully.
400There was a problem parsing the request.
422The request could not be served - likely an invalid method.
401Unsealing failed with the provided method.
500An internal server error occurred.

POST /policies/reload

Reloads the policies from Vault into memory. If this instance is running in High Availability mode, it will also forward the reload command to any unsealed peers.

← DocumentationCLI Documentation →
  • Standard Responses
  • POST /token
    • Parameters
    • Response
    • Example
  • GET /status
    • Response
  • POST /seal
  • POST /unseal
    • Parameters
    • Response
  • POST /policies/reload
Vault Gatekeeper
Docs
DocumentationAPI ReferenceCLI Documentation
Social
GitHubStar
Copyright © 2018 nemosupremo