Class: Vault::AuthToken

Inherits:
Request show all
Defined in:
lib/vault/api/auth_token.rb

Instance Attribute Summary

Attributes inherited from Request

#client

Instance Method Summary collapse

Methods inherited from Request

#initialize, #inspect, #to_s

Constructor Details

This class inherits a constructor from Vault::Request

Instance Method Details

#create(options = {}) ⇒ Secret

Create an authentication token.

Examples:

Vault.auth_token.create #=> #<Vault::Secret lease_id="">

Parameters:

  • options (Hash) (defaults to: {})

Returns:



26
27
28
29
# File 'lib/vault/api/auth_token.rb', line 26

def create(options = {})
  json = client.post("/v1/auth/token/create", JSON.fast_generate(options))
  return Secret.decode(json)
end

#renew(id, increment = 0) ⇒ Secret

Renew the given authentication token.

Examples:

Vault.auth_token.renew("abcd-1234") #=> #<Vault::Secret lease_id="">

Parameters:

  • id (String)

    the auth id

  • increment (Fixnum) (defaults to: 0)

Returns:



41
42
43
44
45
46
# File 'lib/vault/api/auth_token.rb', line 41

def renew(id, increment = 0)
  json = client.put("/v1/auth/token/renew/#{id}", JSON.fast_generate(
    increment: increment,
  ))
  return Secret.decode(json)
end

#revoke_orphan(id) ⇒ true

Revoke exactly the orphans at the id.

Examples:

Vault.auth_token.revoke_orphan("abcd-1234") #=> true

Parameters:

  • id (String)

    the auth id

Returns:

  • (true)


57
58
59
60
# File 'lib/vault/api/auth_token.rb', line 57

def revoke_orphan(id)
  client.put("/v1/auth/token/revoke-orphan/#{id}", nil)
  return true
end

#revoke_prefix(prefix) ⇒ true

Revoke all auth at the given prefix.

Examples:

Vault.auth_token.revoke_prefix("abcd-1234") #=> true

Parameters:

  • id (String)

    the auth id

Returns:

  • (true)


71
72
73
74
# File 'lib/vault/api/auth_token.rb', line 71

def revoke_prefix(prefix)
  client.put("/v1/auth/token/revoke-prefix/#{prefix}", nil)
  return true
end

#revoke_tree(id) ⇒ true

Revoke all auths in the tree.

Examples:

Vault.auth_token.revoke_tree("abcd-1234") #=> true

Parameters:

  • id (String)

    the auth id

Returns:

  • (true)


85
86
87
88
# File 'lib/vault/api/auth_token.rb', line 85

def revoke_tree(id)
  client.put("/v1/auth/token/revoke/#{id}", nil)
  return true
end