Class: Vaultez::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/vaultez/client.rb

Constant Summary collapse

MAX_RESPONSE_BYTES =

A legitimate response (companies/projects/secrets, all short strings) is a handful of KB at most. This bounds how much of a compromised or malicious response - a compromised API backend, a MITM'd/redirected api_url, or a compromised account crafting an oversized payload - this process will hold in memory, independent of any size limit a caller (e.g. the oma-vaultez plugin) enforces on this CLI's own stdout.

4 * 1024 * 1024

Instance Method Summary collapse

Constructor Details

#initializeClient

Returns a new instance of Client.



15
16
17
18
19
# File 'lib/vaultez/client.rb', line 15

def initialize
  @api_url       = Vaultez::Config.api_url
  @token         = Vaultez::Config.token
  @project_token = ENV["VAULTEZ_TOKEN"]
end

Instance Method Details

#companiesObject



33
34
35
# File 'lib/vaultez/client.rb', line 33

def companies
  get("/api/v1/companies")
end

#login(email, password, otp_code) ⇒ Object



21
22
23
# File 'lib/vaultez/client.rb', line 21

def (email, password, otp_code)
  post("/api/v1/auth/login", { email: email, password: password, otp_code: otp_code }, authenticated: false)
end

#logoutObject



25
26
27
# File 'lib/vaultez/client.rb', line 25

def logout
  delete("/api/v1/auth/logout")
end

#project_token_mode?Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/vaultez/client.rb', line 29

def project_token_mode?
  !@project_token.nil?
end

#projects(company_id) ⇒ Object



37
38
39
# File 'lib/vaultez/client.rb', line 37

def projects(company_id)
  get("/api/v1/companies/#{company_id}/projects")
end

#secrets(project_id) ⇒ Object



41
42
43
# File 'lib/vaultez/client.rb', line 41

def secrets(project_id)
  get("/api/v1/projects/#{project_id}/secrets")
end