Azure auth method
The azure
auth method allows authentication against Vault using
Azure Active Directory credentials. It treats Azure as a Trusted Third Party
and expects a JSON Web Token (JWT)
signed by Azure Active Directory for the configured tenant.
This method supports authentication for system-assigned and user-assigned managed identities. See Azure Managed Service Identity (MSI) for more information about these resources.
System-assigned identities are unique to every virtual machine in Azure. If the virtual machines using Azure auth are recreated frequently, using system-assigned identities could result in a lot of Vault entities. For environments with high ephemeral workloads, user-assigned identities are recommended.
Prerequisites:
The following documentation assumes that the method has been
mounted at auth/azure
.
- A configured Azure AD application which is used as the resource for generating MSI access tokens.
- Client credentials (shared secret) for accessing the Azure Resource Manager with read access to compute endpoints. See Azure AD Service to Service Client Credentials
Required Azure API permissions to be granted to Vault user:
NOTE: The above permissions are only required when the associated vm* parameters are used on login. Please see the API doc for more details.
If Vault is hosted on Azure, Vault can use MSI to access Azure instead of a shared secret. MSI must be enabled on the VMs hosting Vault.
The next sections review how the authN/Z workflows work. If you have already reviewed these sections, here are some quick links to:
- Usage
- API documentation docs.
Authentication
Via the CLI
The default path is /auth/azure
. If this auth method was enabled at a different
path, specify auth/my-path/login
instead.
The role
and jwt
parameters are required. When using bound_service_principal_ids
and bound_group_ids
in the token roles, all the information is required in the JWT (except for vm_name and vmss_name). When using other bound_*
parameters, calls to Azure APIs will be made and subscription id, resource group name, and vm name/vmss_name are all required and can be obtained through instance metadata.
For example:
Via the API
The default endpoint is auth/azure/login
. If this auth method was enabled
at a different path, use that value instead of azure
.
The response will contain the token at auth.client_token
:
Configuration
Auth methods must be configured in advance before machines can authenticate. These steps are usually completed by an operator or configuration management tool.
Via the CLI
Enable Azure authentication in Vault:
Configure the Azure auth method:
For the complete list of configuration options, please see the API documentation.
Create a role:
Roles are associated with an authentication type/entity and a set of Vault policies. Roles are configured with constraints specific to the authentication type, as well as overall constraints and configuration for the generated auth tokens.
For the complete list of role options, please see the API documentation.
Via the API
Enable Azure authentication in Vault:
Configure the Azure auth method:
Create a role:
Plugin setup
The following section is only relevant if you decide to enable the azure auth method as an external plugin. The azure plugin method is integrated into Vault as a builtin method by default.
Assuming you have saved the binary vault-plugin-auth-azure
to some folder and
configured the plugin directory
for your server at path/to/plugins
:
Enable the plugin in the catalog:
Enable the azure auth method as a plugin:
Azure debug logs
The Azure auth plugin supports debug logging which includes additional information about requests and responses from the Azure API.
To enable the Azure debug logs, set the following environment variable on the Vault server:
API
The Azure Auth Plugin has a full HTTP API. Please see the API documentation for more details.
Code example
The following example demonstrates the Azure auth method to authenticate with Vault.