Skip to content

Commit bd7e60c

Browse files
Eric Jacobssethvargo
authored andcommitted
Add custom mount path support to Authentication#tls
- Adds `path` parameter to auth.tls() to support cert backends mounted at non-default locations.
1 parent 85e2883 commit bd7e60c

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

lib/vault/api/auth.rb

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,15 +194,21 @@ def aws_ec2(role, pkcs7, nonce)
194194
# @example Reading a pem from disk
195195
# Vault.auth.tls(File.read("/path/to/my/certificate.pem")) #=> #<Vault::Secret lease_id="">
196196
#
197+
# @example Sending to a cert authentication backend mounted at a custom location
198+
# Vault.auth.tls(pem_contents, 'custom/location') #=> #<Vault::Secret lease_id="">
199+
#
197200
# @param [String] pem (default: the configured SSL pem file or contents)
198201
# The raw pem contents to use for the login procedure.
199202
#
203+
# @param [String] path (default: 'cert')
204+
# The path to the auth backend to use for the login procedure.
205+
#
200206
# @return [Secret]
201-
def tls(pem = nil)
207+
def tls(pem = nil, path = 'cert')
202208
new_client = client.dup
203209
new_client.ssl_pem_contents = pem if !pem.nil?
204210

205-
json = new_client.post("/v1/auth/cert/login")
211+
json = new_client.post("/v1/auth/#{path}/login")
206212
secret = Secret.decode(json)
207213
client.token = secret.auth.client_token
208214
return secret

0 commit comments

Comments
 (0)