AppRole auth method
The approle
auth method allows machines or apps to authenticate with
Vault-defined roles. The open design of AppRole
enables a varied set of
workflows and configurations to handle large numbers of apps. This auth method
is oriented to automated workflows (machines and services), and is less useful
for human operators.
An "AppRole" represents a set of Vault policies and login constraints that must be met to receive a token with those policies. The scope can be as narrow or broad as desired. An AppRole can be created for a particular machine, or even a particular user on that machine, or a service spread across machines. The credentials required for successful login depend upon the constraints set on the AppRole associated with the credentials.
Authentication
Via the CLI
The default path is /approle
. If this auth method was enabled at a different
path, specify auth/my-path/login
instead.
Via the API
The default endpoint is auth/approle/login
. If this auth method was enabled
at a different path, use that value instead of approle
.
The response will contain the token at auth.client_token
:
Application Integration: See the Code Example section for a code snippet demonstrating the authentication with Vault using the AppRole auth method.
Configuration
Auth methods must be configured in advance before users or machines can authenticate. These steps are usually completed by an operator or configuration management tool.
Via the CLI
Enable the AppRole auth method:
Create a named role:
Note: If the token issued by your approle needs the ability to create child tokens, you will need to set token_num_uses to 0.
For the complete list of configuration options, please see the API documentation.
Fetch the RoleID of the AppRole:
Get a SecretID issued against the AppRole:
Via the API
Enable the AppRole auth method:
Create an AppRole with desired set of policies:
Fetch the identifier of the role:
The response will look like:
Create a new secret identifier under the role:
The response will look like:
Credentials/Constraints
RoleID
RoleID is an identifier that selects the AppRole against which the other
credentials are evaluated. When authenticating against this auth method's login
endpoint, the RoleID is a required argument (via role_id
) at all times. By
default, RoleIDs are unique UUIDs, which allow them to serve as secondary
secrets to the other credential information. However, they can be set to
particular values to match introspected information by the client (for
instance, the client's domain name).
SecretID
SecretID is a credential that is required by default for any login (via
secret_id
) and is intended to always be secret. (For advanced usage,
requiring a SecretID can be disabled via an AppRole's bind_secret_id
parameter, allowing machines with only knowledge of the RoleID, or matching
other set constraints, to fetch a token). SecretIDs can be created against an
AppRole either via generation of a 128-bit purely random UUID by the role
itself (Pull
mode) or via specific, custom values (Push
mode). Similarly to
tokens, SecretIDs have properties like usage-limit, TTLs and expirations.
Pull and push SecretID modes
If the SecretID used for login is fetched from an AppRole, this is operating in Pull mode. If a "custom" SecretID is set against an AppRole by the client, it is referred to as a Push mode. Push mode mimics the behavior of the deprecated App-ID auth method; however, in most cases Pull mode is the better approach. The reason is that Push mode requires some other system to have knowledge of the full set of client credentials (RoleID and SecretID) in order to create the entry, even if these are then distributed via different paths. However, in Pull mode, even though the RoleID must be known in order to distribute it to the client, the SecretID can be kept confidential from all parties except for the final authenticating client by using Response Wrapping.
Push mode is available for App-ID workflow compatibility, which in some specific cases is preferable, but in most cases Pull mode is more secure and should be preferred.
Further constraints
role_id
is a required credential at the login endpoint. AppRole pointed to by
the role_id
will have constraints set on it. This dictates other required
credentials for login. The bind_secret_id
constraint requires secret_id
to
be presented at the login endpoint. Going forward, this auth method can support
more constraint parameters to support varied set of Apps. Some constraints will
not require a credential, but still enforce constraints for login. For
example, secret_id_bound_cidrs
will only allow logins coming from IP addresses
belonging to configured CIDR blocks on the AppRole.
Tutorial
Refer to the AppRole Pull Authentication tutorial to learn how to use the AppRole method to generate tokens for machines or apps.
User lockout
If a user provides bad credentials several times in quick succession, Vault will stop trying to validate their credentials for a while, instead returning immediately with a permission denied error. We call this behavior "user lockout". The time for which a user will be locked out is called “lockout duration”. The user will be able to login after the lockout duration has passed. The number of failed login attempts after which the user is locked out is called “lockout threshold”. The lockout threshold counter is reset to zero after a few minutes without login attempts, or upon a successful login attempt. The duration after which the counter will be reset to zero after no login attempts is called "lockout counter reset". This can defeat both automated and targeted requests i.e, user-based password guessing attacks as well as automated attacks.
The user lockout feature is enabled by default. The default values for "lockout threshold" is 5 attempts, "lockout duration" is 15 minutes, "lockout counter reset" is 15 minutes.
The user lockout feature can be disabled as follows:
- It can be disabled globally using environment variable
VAULT_DISABLE_USER_LOCKOUT
. - It can be disabled for all supported auth methods (ldap, userpass and approle) or a specific supported auth method using the
disable_lockout
parameter withinuser_lockout
stanza in configuration file. Please see user lockout configuration for more details. - It can be disabled for a specific auth mount using "auth tune". Please see auth tune command or auth tune api for more details.
NOTE: This feature is available from Vault version 1.13 and is only supported by the userpass, ldap, and approle auth methods.
API
The AppRole auth method has a full HTTP API. Please see the AppRole API for more details.
Code example
The following example demonstrates AppRole authentication with response wrapping.