Vault
Create a service account library
Create a library of service accounts that users and machines can check out as needed. Vault automatically rotates the account password when clients return the service account to the library.
Before you start
- Check your Vault permissions. You must have permission to enable and configure plugins in Vault.
- You must have an LDAP plugin configured for OpenLDAP or Active Directory. If you do not already have an LDAP plugin enabled, follow the setup guide.
- Create the library accounts on your LDAP server. We highly recommend creating a dedicated accounts for the library.
Step 1: Create a library configuration file
For easier maintenance and reuse, create a JSON file library.json, with the
credential library configuration details.
{
"service_account_names": "<list_of_LDAP_accounts>",
"ttl": "<default_checkout_period>",
"max_ttl": "<max_allowed_checkout_period>",
"disable_check_in_enforcement": "false"
}
For example:
{
"service_account_names": "fizz@example.com,buzz@example.com",
"ttl": "10h",
"max_ttl": "24h",
"disable_check_in_enforcement": "false"
}
the following configuration file:
- defines the set of accounts in the library as
fizz@example.comandbuzz@example.com - sets a default checkout time of 10 hours
- disallows renewals after 24 hours
- requires that the same Vault entity or client token checking out a service account also be the one to check the account back into the library.
Step 2: Configure the plugin
Apply the libray configuration file to your plugin.
Use vault write with the
{mount_path}/library/{set_name}
path to apply your library.json configuration file:
$ vault write <mount_path>/library/<set_name> @library.json
For example:
$ vault write devcreds/library/accounting-team @library.json
Step 3: Verify the service account settings
To verify the library settings, view the set status.
Use vault read with the
{mount_path}/library/{set_name}
path to check the status of your library:
$ vault read <mount_path>/library/<set_name>
For example:
$ vault read devcreds/library/accounting-team
Key Value
--- -----
buzz@example.com map[available:true]
fizz@example.com map[available:true]
Step 3: Test the check-out process
To test the connection between Vault and your LDAP server, try checking out and returning a service account.
Use vault write with the -f flag and
{mount_path}/library/{set_name}/check-out
path to request a service account:
$ vault write -f <mount_path>/library/<set_name>/checkout
For example:
$ vault write -f devcreds/library/accounting-team/checkout
Key Value
--- -----
lease_id devcreds/library/accounting-team/check-out/EpuS8cX7uEsDzOwW9kkKOyGW
lease_duration 10h
lease_renewable true
password ?@09AZKh03hBORZPJcTDgLfntlHqxLy29tcQjPVThzuwWAx/Twx4a2ZcRQRqrZ1w
service_account_name fizz@example.com
Use vault write with the service account name and
{mount_path}/library/{set_name}/check-out
path to request a service account:
$ vault write <mount_path>/library/<set_name>/check-in \
service_account_names=[<account_list>]
For example:
$ vault write -f devcreds/library/accounting-team/check-in \
service_account_names=["fizz@example.com"]