website/integrations/security/hashicorp-vault/index.md
Secure, store and tightly control access to tokens, passwords, certificates, encryption keys for protecting secrets and other sensitive data using a UI, CLI, or HTTP API.
:::info This is based on authentik 2022.2.1 and Vault 1.9.3. Instructions may differ between versions. This guide does not cover vault policies. See https://learn.hashicorp.com/tutorials/vault/oidc-auth?in=vault/auth-methods for a more in-depth vault guide :::
The following placeholders are used in this guide:
authentik.company is the FQDN of the authentik installation.vault.company is the FQDN of the Vault installation.:::info This documentation lists only the settings that you need to change from their default values. Be aware that any changes other than those explicitly mentioned in this guide could cause issues accessing your application. :::
To support the integration of Hashicorp Vault with authentik, you need to create an application/provider pair in authentik.
Strict redirect URIs and set them to https://vault.company/ui/vault/auth/oidc/oidc/callback, https://vault.company/oidc/callback, and http://localhost:8250/oidc/callback.Enable the oidc auth method
vault auth enable oidc
Configure the oidc auth method, oidc discovery url is the OpenID Configuration Issuer in your provider
vault write auth/oidc/config \
oidc_discovery_url="https://authentik.company/application/o/<application_slug>/" \
oidc_client_id="Client ID" \
oidc_client_secret="Client Secret" \
default_role="reader"
Create the reader role
vault write auth/oidc/role/reader \
bound_audiences="Client ID" \
allowed_redirect_uris="https://vault.company/ui/vault/auth/oidc/oidc/callback" \
allowed_redirect_uris="https://vault.company/oidc/callback" \
allowed_redirect_uris="http://localhost:8250/oidc/callback" \
user_claim="sub" \
policies="reader"
If you wish to manage group membership in Hashicorp Vault via Authentik you have to use external groups.
:::info This assumes that the steps above have already been completed and tested. :::
In authentik, edit the OIDC provider created above. Under Advanced protocol settings add authentik default OAuth Mapping: OpenID 'profile' This includes the groups mapping.
In Vault, change the reader role to have the following settings:
vault write auth/oidc/role/reader \
bound_audiences="Client ID" \
allowed_redirect_uris="https://vault.company/ui/vault/auth/oidc/oidc/callback" \
allowed_redirect_uris="https://vault.company/oidc/callback" \
allowed_redirect_uris="http://localhost:8250/oidc/callback" \
user_claim="sub" \
policies="reader" \
groups_claim="groups" \
oidc_scopes="openid,profile,email"
Add a group.
vault write identity/group \
name="reader" \
policies="reader" \
type="external"
Get the canonical ID of the group.
vault list identity/group/id
Get the ID of the OIDC accessor.
vault auth list
Add a group alias, this maps the group to the OIDC backend.
vault write identity/group-alias \
mount_accessor="auth_oidc_xxxxxx" \
canonical_id="group_id" \
name="group name in authentik"
You should then be able to sign in via OIDC.
vault login -method=oidc role="reader"