Skip to content

Commit e632ba8

Browse files
authored
Merge pull request #156 from aquach/master
Add audit_hash endpoint and fix typo.
2 parents 7ace97a + 905d412 commit e632ba8

1 file changed

Lines changed: 18 additions & 1 deletion

File tree

lib/vault/api/sys/audit.rb

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class Audit < Response
1919
end
2020

2121
class Sys
22-
# List all audis for the vault.
22+
# List all audits for the vault.
2323
#
2424
# @example
2525
# Vault.sys.audits #=> { :file => #<Audit> }
@@ -70,5 +70,22 @@ def disable_audit(path)
7070
client.delete("/v1/sys/audit/#{encode_path(path)}")
7171
return true
7272
end
73+
74+
# Generates a HMAC verifier for a given input.
75+
#
76+
# @example
77+
# Vault.sys.audit_hash("file-audit", "my input") #=> "hmac-sha256:30aa7de18a5e90bbc1063db91e7c387b32b9fa895977eb8c177bbc91e7d7c542"
78+
#
79+
# @param [String] path
80+
# the path of the audit backend
81+
# @param [String] input
82+
# the input to generate a HMAC for
83+
#
84+
# @return [String]
85+
def audit_hash(path, input)
86+
json = client.post("/v1/sys/audit-hash/#{encode_path(path)}", JSON.fast_generate(input: input))
87+
json = json[:data] if json[:data]
88+
json[:hash]
89+
end
7390
end
7491
end

0 commit comments

Comments
 (0)