Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
@doodle/vault / kubernetesLogin.js
Size: Mime:
const fetch = require('node-fetch');
/**
 * Exchanges a Kubernetes service account token for a authenticated Vault token
 *
 * @see https://www.vaultproject.io/api/auth/kubernetes/index.html#login
 *
 * @param {Object} options
 * @param {String} options.jwt A valid Kubernetes ServiceAccount secret token
 * @param {String} options.role With which vault role to log in using the service account token
 * @param {String} [options.endpoint=http://127.0.0.1:8200] Vault host
 * @param {String} [options.apiVersion=v1] Vault API version
 */


module.exports = async ({
  jwt,
  role,
  endpoint = 'http://127.0.0.1:8200',
  apiVersion = 'v1'
}) => fetch(`${endpoint}/${apiVersion}/auth/kubernetes/login`, {
  method: 'POST',
  body: JSON.stringify({
    jwt,
    role
  }),
  headers: {
    'Content-Type': 'application/json'
  }
}).then(response => response.json()).then(({
  auth
}) => auth.client_token).catch(error => {
  throw error;
});