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 Managed identities for Azure resources for more information about these resources.
This documentation assumes the Azure method is mounted at the /auth/azure
path in Vault. Since it is possible to enable auth methods at any location,
please update your API calls accordingly.
Prerequisites:
The Azure auth method requires client credentials to access Azure APIs. The following are required to configure the auth method:
- A configured Azure AD application which is used as the resource for generating MSI access tokens.
- Client credentials (shared secret) with read access to particular Azure Resource Manager resources. See Azure AD Service to Service Client Credentials.
If Vault is hosted on Azure, Vault can use MSI to access Azure instead of a shared secret. A managed identity must be enabled on the resource that acquires the access token.
The following Azure role assignments must be granted to the Azure AD application in order for the auth method to access Azure APIs during authentication.
Role assignments
Note: The role assignments are only required when the
vm_name
, vmss_name
,
or resource_id
parameters are used on login.
Azure Environment | Login Parameter | Azure API Permission |
---|---|---|
Virtual Machine | vm_name | Microsoft.Compute/virtualMachines/*/read |
Virtual Machine Scale Set (Uniform Orchestration) | vmss_name | Microsoft.Compute/virtualMachineScaleSets/*/read |
Virtual Machine Scale Set (Flexible Orchestration) | vmss_name | Microsoft.Compute/virtualMachineScaleSets/*/read Microsoft.ManagedIdentity/userAssignedIdentities/*/read |
Services that (support managed identities) for Azure resources | resource_id | read on the resource used to obtain the JWT |
API permissions
The following API permissions must be assigned to the service principal provided to Vault for managing the root rotation in Azure:
Permission Name | Type |
---|---|
Application.ReadWrite.All | Application |
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
, vmss_name
, resource_id
). 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.
In some cases, you cannot set sensitive account credentials in your Vault configuration. For example, your organization may require that all security credentials are short-lived or explicitly tied to a machine identity.
To provide managed identity security credentials to Vault, we recommend using Vault plugin workload identity federation (WIF) as shown below.
Alternatively, configure the audience claim value and the Client, Tenant IDs for plugin workload identity federation:
The Vault identity token provider signs the plugin identity token JWT internally. If a trust relationship exists between Vault and Azure through WIF, the auth method can exchange the Vault identity token for a federated access token.
To configure a trusted relationship between Vault and Azure:
Establishing a trusted relationship between Vault and Azure ensures that Azure can fetch JWKS public keys and verify the plugin identity token signature.
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:
Azure managed identities
There are two types of managed identities in Azure: System-assigned and User-assigned. System-assigned identities are unique to every virtual machine in Azure. If the resources using Azure auth are recreated frequently, using system-assigned identities could result in many Vault entities being created. For environments with high ephemeral workloads, user-assigned identities are recommended.
Limitations
The TTL of the access token returned by Azure AD for a managed identity is 24hrs and is not configurable. See (limitations of using managed identities) for more info.
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:
Plugin Workload Identity Federation (WIF)
This feature requires Vault Enterprise(opens in new tab).
The Azure auth method supports the plugin WIF workflow, and has a source of identity called a plugin identity token. A plugin identity token is a JWT that is signed internally by Vault's plugin identity token issuer.
If there is a trust relationship configured between Vault and Azure through workload identity federation, the auth method can exchange its identity token for short-lived access tokens needed to perform its actions.
Exchanging identity tokens for access tokens lets the Azure auth method operate without configuring explicit access to sensitive client credentials.
To configure the auth method to use plugin WIF:
Ensure that Vault openid-configuration and public JWKS APIs are network-reachable by Azure. We recommend using an API proxy or gateway if you need to limit Vault API exposure.
Configure a federated identity credential on a dedicated application registration in Azure to establish a trust relationship with Vault.
- The issuer URL must point at your Vault plugin identity token issuer with the
/.well-known/openid-configuration
suffix removed. For example:https://host:port/v1/identity/oidc/plugins
. - The subject identifier must match the unique
sub
claim issued by plugin identity tokens. The subject identifier should have the formplugin-identity:<NAMESPACE>:auth:<AZURE_MOUNT_ACCESSOR>
. - The audience should be under 600 characters. The default value in Azure is
api://AzureADTokenExchange
.
- The issuer URL must point at your Vault plugin identity token issuer with the
Configure the Azure auth method with the client and tenant IDs and the OIDC audience value.
Your auth method can now use plugin WIF for its configuration credentials. By default, WIF credentials have a time-to-live of 1 hour and automatically refresh when they expire.
Please see the API documentation for more details on the fields associated with plugin WIF.
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.