Skip to content

Commit bc08191

Browse files
author
Ramesh Sencha
committed
Add Azure auth method
1 parent 714a305 commit bc08191

1 file changed

Lines changed: 33 additions & 0 deletions

File tree

lib/vault/api/auth.rb

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,39 @@ def gcp(role, jwt, path = 'gcp')
267267
return secret
268268
end
269269

270+
# Authenticate via the Azure authentication method. If authentication is
271+
# successful, the resulting token will be stored on the client and used
272+
# for future requests.
273+
#
274+
# @example
275+
# Vault.auth.azure("read-only", "jwt", "subscription_id", "resource_group", "vm_name", "vmss_name") #=> #<Vault::Secret lease_id="">
276+
#
277+
# @param [String] role
278+
# @param [String] jwt
279+
# jwt returned by the instance identity metadata,
280+
# @param [String] subscription_id
281+
# @param [String] resource_group
282+
# @param [String] vm_name
283+
# @param [String] mount_point optional
284+
# the path were the azure auth backend is mounted
285+
#
286+
# @return [Secret]
287+
def azure(role, jwt, subscription_id, resource_group, vm_name, mount_point = 'azure')
288+
route = "/v1/auth/#{mount_point}/login"
289+
290+
payload = {
291+
role: role,
292+
jwt: jwt,
293+
subscription_id: subscription_id,
294+
resource_group_name: resource_group,
295+
vm_name: vm_name
296+
}
297+
json = client.post(route, JSON.fast_generate(payload))
298+
secret = Secret.decode(json)
299+
client.token = secret.auth.client_token
300+
return secret
301+
end
302+
270303
# Authenticate via a TLS authentication method. If authentication is
271304
# successful, the resulting token will be stored on the client and used
272305
# for future requests.

0 commit comments

Comments
 (0)