Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions lib/vault/api/approle.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class AppRole < Request
# @return [true]
def set_role(name, options = {})
headers = extract_headers!(options)
client.post("/v1/auth/approle/role/#{encode_path(name)}", JSON.fast_generate(options), headers)
client.post("/v1/auth/approle/role/#{encode_path(name)}", JSON.generate(options), headers)
return true
end

Expand Down Expand Up @@ -118,7 +118,7 @@ def role_id(name)
# @return [true]
def set_role_id(name, role_id)
options = { role_id: role_id }
client.post("/v1/auth/approle/role/#{encode_path(name)}/role-id", JSON.fast_generate(options))
client.post("/v1/auth/approle/role/#{encode_path(name)}/role-id", JSON.generate(options))
return true
end

Expand Down Expand Up @@ -163,9 +163,9 @@ def delete_role(name)
def create_secret_id(role_name, options = {})
headers = extract_headers!(options)
if options[:secret_id]
json = client.post("/v1/auth/approle/role/#{encode_path(role_name)}/custom-secret-id", JSON.fast_generate(options), headers)
json = client.post("/v1/auth/approle/role/#{encode_path(role_name)}/custom-secret-id", JSON.generate(options), headers)
else
json = client.post("/v1/auth/approle/role/#{encode_path(role_name)}/secret-id", JSON.fast_generate(options), headers)
json = client.post("/v1/auth/approle/role/#{encode_path(role_name)}/secret-id", JSON.generate(options), headers)
end
return Secret.decode(json)
end
Expand All @@ -184,7 +184,7 @@ def create_secret_id(role_name, options = {})
# @return [Secret, nil]
def secret_id(role_name, secret_id)
opts = { secret_id: secret_id }
json = client.post("/v1/auth/approle/role/#{encode_path(role_name)}/secret-id/lookup", JSON.fast_generate(opts), {})
json = client.post("/v1/auth/approle/role/#{encode_path(role_name)}/secret-id/lookup", JSON.generate(opts), {})
return nil unless json
return Secret.decode(json)
rescue HTTPError => e
Expand Down
16 changes: 8 additions & 8 deletions lib/vault/api/auth.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def token(new_token)
# @return [Secret]
def app_id(app_id, user_id, options = {})
payload = { app_id: app_id, user_id: user_id }.merge(options)
json = client.post("/v1/auth/app-id/login", JSON.fast_generate(payload))
json = client.post("/v1/auth/app-id/login", JSON.generate(payload))
secret = Secret.decode(json)
client.token = secret.auth.client_token
return secret
Expand All @@ -95,7 +95,7 @@ def app_id(app_id, user_id, options = {})
def approle(role_id, secret_id=nil)
payload = { role_id: role_id }
payload[:secret_id] = secret_id if secret_id
json = client.post("/v1/auth/approle/login", JSON.fast_generate(payload))
json = client.post("/v1/auth/approle/login", JSON.generate(payload))
secret = Secret.decode(json)
client.token = secret.auth.client_token
return secret
Expand All @@ -120,7 +120,7 @@ def approle(role_id, secret_id=nil)
# @return [Secret]
def userpass(username, password, options = {})
payload = { password: password }.merge(options)
json = client.post("/v1/auth/userpass/login/#{encode_path(username)}", JSON.fast_generate(payload))
json = client.post("/v1/auth/userpass/login/#{encode_path(username)}", JSON.generate(payload))
secret = Secret.decode(json)
client.token = secret.auth.client_token
return secret
Expand All @@ -142,7 +142,7 @@ def userpass(username, password, options = {})
# @return [Secret]
def ldap(username, password, options = {})
payload = { password: password }.merge(options)
json = client.post("/v1/auth/ldap/login/#{encode_path(username)}", JSON.fast_generate(payload))
json = client.post("/v1/auth/ldap/login/#{encode_path(username)}", JSON.generate(payload))
secret = Secret.decode(json)
client.token = secret.auth.client_token
return secret
Expand All @@ -160,7 +160,7 @@ def ldap(username, password, options = {})
# @return [Secret]
def github(github_token, path="/v1/auth/github/login")
payload = {token: github_token}
json = client.post(path, JSON.fast_generate(payload))
json = client.post(path, JSON.generate(payload))
secret = Secret.decode(json)
client.token = secret.auth.client_token
return secret
Expand All @@ -185,7 +185,7 @@ def aws_ec2(role, pkcs7, nonce = nil, route = nil)
payload = { role: role, pkcs7: pkcs7 }
# Set a custom nonce if client is providing one
payload[:nonce] = nonce if nonce
json = client.post(route, JSON.fast_generate(payload))
json = client.post(route, JSON.generate(payload))
secret = Secret.decode(json)
client.token = secret.auth.client_token
return secret
Expand Down Expand Up @@ -242,7 +242,7 @@ def aws_iam(role, credentials_provider, iam_auth_header_value = nil, sts_endpoin
iam_request_body: Base64.strict_encode64(request_body)
}

json = client.post(route, JSON.fast_generate(payload))
json = client.post(route, JSON.generate(payload))
secret = Secret.decode(json)
client.token = secret.auth.client_token
return secret
Expand All @@ -264,7 +264,7 @@ def aws_iam(role, credentials_provider, iam_auth_header_value = nil, sts_endpoin
# @return [Secret]
def gcp(role, jwt, path = 'gcp')
payload = { role: role, jwt: jwt }
json = client.post("/v1/auth/#{CGI.escape(path)}/login", JSON.fast_generate(payload))
json = client.post("/v1/auth/#{CGI.escape(path)}/login", JSON.generate(payload))
secret = Secret.decode(json)
client.token = secret.auth.client_token
return secret
Expand Down
2 changes: 1 addition & 1 deletion lib/vault/api/auth_tls.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class AuthTLS < Request
# @return [true]
def set_certificate(name, options = {})
headers = extract_headers!(options)
client.post("/v1/auth/cert/certs/#{encode_path(name)}", JSON.fast_generate(options), headers)
client.post("/v1/auth/cert/certs/#{encode_path(name)}", JSON.generate(options), headers)
return true
end

Expand Down
20 changes: 10 additions & 10 deletions lib/vault/api/auth_token.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def accessors(options = {})
# @return [Secret]
def create(options = {})
headers = extract_headers!(options)
json = client.post("/v1/auth/token/create", JSON.fast_generate(options), headers)
json = client.post("/v1/auth/token/create", JSON.generate(options), headers)
return Secret.decode(json)
end

Expand All @@ -84,7 +84,7 @@ def create(options = {})
# @return [Secret]
def create_orphan(options = {})
headers = extract_headers!(options)
json = client.post("/v1/auth/token/create-orphan", JSON.fast_generate(options), headers)
json = client.post("/v1/auth/token/create-orphan", JSON.generate(options), headers)
return Secret.decode(json)
end

Expand All @@ -98,7 +98,7 @@ def create_orphan(options = {})
# @return [Secret]
def create_with_role(name, options = {})
headers = extract_headers!(options)
json = client.post("/v1/auth/token/create/#{encode_path(name)}", JSON.fast_generate(options), headers)
json = client.post("/v1/auth/token/create/#{encode_path(name)}", JSON.generate(options), headers)
return Secret.decode(json)
end

Expand All @@ -113,7 +113,7 @@ def create_with_role(name, options = {})
# @return [Secret]
def lookup(token, options = {})
headers = extract_headers!(options)
json = client.post("/v1/auth/token/lookup", JSON.fast_generate(
json = client.post("/v1/auth/token/lookup", JSON.generate(
token: token,
), headers)
return Secret.decode(json)
Expand All @@ -128,7 +128,7 @@ def lookup(token, options = {})
# @param [Hash] options
def lookup_accessor(accessor, options = {})
headers = extract_headers!(options)
json = client.post("/v1/auth/token/lookup-accessor", JSON.fast_generate(
json = client.post("/v1/auth/token/lookup-accessor", JSON.generate(
accessor: accessor,
), headers)
return Secret.decode(json)
Expand Down Expand Up @@ -157,7 +157,7 @@ def lookup_self
# @return [Secret]
def renew(token, increment = 0, options = {})
headers = extract_headers!(options)
json = client.put("/v1/auth/token/renew", JSON.fast_generate(
json = client.put("/v1/auth/token/renew", JSON.generate(
token: token,
increment: increment,
), headers)
Expand All @@ -174,7 +174,7 @@ def renew(token, increment = 0, options = {})
# @return [Secret]
def renew_self(increment = 0, options = {})
headers = extract_headers!(options)
json = client.put("/v1/auth/token/renew-self", JSON.fast_generate(
json = client.put("/v1/auth/token/renew-self", JSON.generate(
increment: increment,
), headers)
return Secret.decode(json)
Expand All @@ -201,7 +201,7 @@ def revoke_self
# @return [true]
def revoke_orphan(token, options = {})
headers = extract_headers!(options)
client.put("/v1/auth/token/revoke-orphan", JSON.fast_generate(
client.put("/v1/auth/token/revoke-orphan", JSON.generate(
token: token,
), headers)
return true
Expand All @@ -218,7 +218,7 @@ def revoke_orphan(token, options = {})
# @return [true]
def revoke_accessor(accessor, options = {})
headers = extract_headers!(options)
client.put("/v1/auth/token/revoke-accessor", JSON.fast_generate(
client.put("/v1/auth/token/revoke-accessor", JSON.generate(
accessor: accessor,
), headers)
return true
Expand All @@ -235,7 +235,7 @@ def revoke_accessor(accessor, options = {})
# @return [true]
def revoke(token, options = {})
headers = extract_headers!(options)
client.put("/v1/auth/token/revoke", JSON.fast_generate(
client.put("/v1/auth/token/revoke", JSON.generate(
token: token,
), headers)
return true
Expand Down
12 changes: 6 additions & 6 deletions lib/vault/api/kv.rb
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ def read_metadata(path)
# @return [Secret]
def write(path, data = {}, options = {})
headers = extract_headers!(options)
json = client.post("/v1/#{mount}/data/#{encode_path(path)}", JSON.fast_generate(:data => data), headers)
json = client.post("/v1/#{mount}/data/#{encode_path(path)}", JSON.generate(:data => data), headers)
if json.nil?
return true
else
Expand All @@ -120,7 +120,7 @@ def write(path, data = {}, options = {})
#
# @return [true]
def write_metadata(path, metadata = {})
client.post("/v1/#{mount}/metadata/#{encode_path(path)}", JSON.fast_generate(metadata))
client.post("/v1/#{mount}/metadata/#{encode_path(path)}", JSON.generate(metadata))

true
end
Expand All @@ -140,7 +140,7 @@ def write_metadata(path, metadata = {})
def patch_metadata(path, metadata = {}, options = {})
headers = extract_headers!(options)
headers["Content-Type"] = "application/merge-patch+json"
client.patch("/v1/#{mount}/metadata/#{encode_path(path)}", JSON.fast_generate(metadata), headers)
client.patch("/v1/#{mount}/metadata/#{encode_path(path)}", JSON.generate(metadata), headers)

true
end
Expand Down Expand Up @@ -173,7 +173,7 @@ def delete(path)
#
# @return [true]
def delete_versions(path, versions)
client.post("/v1/#{mount}/delete/#{encode_path(path)}", JSON.fast_generate(versions: versions))
client.post("/v1/#{mount}/delete/#{encode_path(path)}", JSON.generate(versions: versions))

true
end
Expand All @@ -190,7 +190,7 @@ def delete_versions(path, versions)
#
# @return [true]
def undelete_versions(path, versions)
client.post("/v1/#{mount}/undelete/#{encode_path(path)}", JSON.fast_generate(versions: versions))
client.post("/v1/#{mount}/undelete/#{encode_path(path)}", JSON.generate(versions: versions))

true
end
Expand Down Expand Up @@ -222,7 +222,7 @@ def destroy(path)
#
# @return [true]
def destroy_versions(path, versions)
client.post("/v1/#{mount}/destroy/#{encode_path(path)}", JSON.fast_generate(versions: versions))
client.post("/v1/#{mount}/destroy/#{encode_path(path)}", JSON.generate(versions: versions))

true
end
Expand Down
2 changes: 1 addition & 1 deletion lib/vault/api/logical.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def read(path, options = {})
# @return [Secret]
def write(path, data = {}, options = {})
headers = extract_headers!(options)
json = client.put("/v1/#{encode_path(path)}", JSON.fast_generate(data), headers)
json = client.put("/v1/#{encode_path(path)}", JSON.generate(data), headers)
if json.nil?
return true
else
Expand Down
4 changes: 2 additions & 2 deletions lib/vault/api/sys/audit.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def audits
#
# @return [true]
def enable_audit(path, type, description, options = {})
client.put("/v1/sys/audit/#{encode_path(path)}", JSON.fast_generate(
client.put("/v1/sys/audit/#{encode_path(path)}", JSON.generate(
type: type,
description: description,
options: options,
Expand Down Expand Up @@ -86,7 +86,7 @@ def disable_audit(path)
#
# @return [String]
def audit_hash(path, input)
json = client.post("/v1/sys/audit-hash/#{encode_path(path)}", JSON.fast_generate(input: input))
json = client.post("/v1/sys/audit-hash/#{encode_path(path)}", JSON.generate(input: input))
json = json[:data] if json[:data]
json[:hash]
end
Expand Down
4 changes: 2 additions & 2 deletions lib/vault/api/sys/auth.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def enable_auth(path, type, description = nil)
payload = { type: type }
payload[:description] = description if !description.nil?

client.post("/v1/sys/auth/#{encode_path(path)}", JSON.fast_generate(payload))
client.post("/v1/sys/auth/#{encode_path(path)}", JSON.generate(payload))
return true
end

Expand Down Expand Up @@ -108,7 +108,7 @@ def auth_tune(path)
# @return [AuthConfig]
# configuration of the given auth path
def put_auth_tune(path, config = {})
json = client.put("/v1/sys/auth/#{encode_path(path)}/tune", JSON.fast_generate(config))
json = client.put("/v1/sys/auth/#{encode_path(path)}/tune", JSON.generate(config))
if json.nil?
return true
else
Expand Down
2 changes: 1 addition & 1 deletion lib/vault/api/sys/init.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def init_status
#
# @return [InitResponse]
def init(options = {})
json = client.put("/v1/sys/init", JSON.fast_generate(
json = client.put("/v1/sys/init", JSON.generate(
root_token_pgp_key: options.fetch(:root_token_pgp_key, nil),
secret_shares: options.fetch(:secret_shares, options.fetch(:shares, 5)),
secret_threshold: options.fetch(:secret_threshold, options.fetch(:threshold, 3)),
Expand Down
2 changes: 1 addition & 1 deletion lib/vault/api/sys/lease.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class Sys
#
# @return [Secret]
def renew(id, increment = 0)
json = client.put("/v1/sys/renew/#{id}", JSON.fast_generate(
json = client.put("/v1/sys/renew/#{id}", JSON.generate(
increment: increment,
))
return Secret.decode(json)
Expand Down
6 changes: 3 additions & 3 deletions lib/vault/api/sys/mount.rb
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def mount(path, type, description = nil, options = {})
payload = options.merge type: type
payload[:description] = description if !description.nil?

client.post("/v1/sys/mounts/#{encode_path(path)}", JSON.fast_generate(payload))
client.post("/v1/sys/mounts/#{encode_path(path)}", JSON.generate(payload))
return true
end

Expand All @@ -124,7 +124,7 @@ def get_mount_tune(path)
# @param [Hash] data
# the data to write
def mount_tune(path, data = {})
json = client.post("/v1/sys/mounts/#{encode_path(path)}/tune", JSON.fast_generate(data))
json = client.post("/v1/sys/mounts/#{encode_path(path)}/tune", JSON.generate(data))
return true
end

Expand Down Expand Up @@ -155,7 +155,7 @@ def unmount(path)
#
# @return [true]
def remount(from, to)
client.post("/v1/sys/remount", JSON.fast_generate(
client.post("/v1/sys/remount", JSON.generate(
from: from,
to: to,
))
Expand Down
2 changes: 1 addition & 1 deletion lib/vault/api/sys/policy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def policy(name)
#
# @return [true]
def put_policy(name, rules)
client.put("/v1/sys/policy/#{encode_path(name)}", JSON.fast_generate(
client.put("/v1/sys/policy/#{encode_path(name)}", JSON.generate(
rules: rules,
))
return true
Expand Down
4 changes: 2 additions & 2 deletions lib/vault/api/sys/quota.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def quotas(type)

def create_quota(type, name, opts={})
path = generate_path(type, name)
client.post(path, JSON.fast_generate(opts))
client.post(path, JSON.generate(opts))
return true
end

Expand All @@ -83,7 +83,7 @@ def get_quota_config
end

def update_quota_config(opts={})
client.post("v1/sys/quotas/config", JSON.fast_generate(opts))
client.post("v1/sys/quotas/config", JSON.generate(opts))
return true
end

Expand Down
2 changes: 1 addition & 1 deletion lib/vault/api/sys/seal.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def seal
#
# @return [SealStatus]
def unseal(shard)
json = client.put("/v1/sys/unseal", JSON.fast_generate(
json = client.put("/v1/sys/unseal", JSON.generate(
key: shard,
))
return SealStatus.decode(json)
Expand Down
Loading