> ## Documentation Index
> Fetch the complete documentation index at: https://docs.opal.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# HashiCorp Vault

> Learn how to connect your Opal instance with HashiCorp Vault.

Opal's integration with HashiCorp Vault allows you to manage access to Vault KV secrets and identity groups.

## Supported resources

| Resource | Read | Grant and revoke access | Notes |
| - | - | - | - |
| Users | ✔️ | | Vault identity entities that have an email address. Disabled entities and entities without one are skipped. |
| Secrets (KV paths) | ✔️ | ✔️ | KV v1 and KV v2 secret paths. |
| Identity groups | ✔️ | ✔️ | Synced as groups. Opal adds and removes identity entities as members. |
| Policies | ✔️ | | |
| OIDC roles | ✔️ | | |

## Requirements

Before you begin, you must:

* Be an Opal Admin
* Be on version `1.1263.0` or later, if you self-host Opal
* Have the [AppRole auth method](https://developer.hashicorp.com/vault/docs/auth/approle) enabled at its default `approle` path in Vault
* To grant access to secrets, have the [OIDC auth method](https://developer.hashicorp.com/vault/docs/auth/jwt) enabled at its default `oidc` path, with your identity provider as the OIDC provider

## 1. Create an AppRole for Opal

In Opal, go to **Inventory** > **+ App** and select **HashiCorp Vault**. The form shows the Vault policy Opal needs. Copy it and create it in Vault as the AppRole's policy, for example `opal-approle`:

* Replace `secret-kv2` and `secret-kv1` with the mount paths of the KV secret engines you want Opal to sync.
* Replace `opal-approle` with the name of your policy. The policy gives the AppRole only `read` on its own policy. If the AppRole can change its own policy, Opal flags it as a privilege escalation risk when you save the app.

Then create an AppRole with that policy, and copy its role ID and a secret ID.

## 2. Create the HashiCorp Vault app in Opal

Back in the Opal form, fill in the following fields:

| Field | Value |
| - | - |
| App name | A name for the Vault app in Opal. |
| App admin | The owner who administers the app in Opal. |
| Description | A short description that helps requesters understand what this app is. |
| Instance Address | The address of your Vault instance, for example `https://vault.yourcompany.com`. |
| AppRole Name | The name of the AppRole's policy from step 1, for example `opal-approle`. |
| AppRole ID | The AppRole's role ID. |
| AppRole Secret | The AppRole's secret ID. |
| What to sync | The item types Opal imports: **Secrets (KV paths)**, **Policies**, **OIDC roles**, and **Identity groups**. Identity entities always sync as users. |

Select **Read-only (do not push membership or secret grants)** to sync without changing anything in Vault. Opal then checks only the read capabilities it needs.

When you save the app, Opal checks the AppRole's capabilities. A missing read capability is critical. A missing write capability only affects granting and revoking access.

## 3. Import assets

After you save the app, import the secrets and identity groups you want to manage from the app's **Assets** tab by selecting **Import assets**, and turn on requests for them.

## How Opal matches users

Opal matches each Vault identity entity to an Opal user by email. It uses the first of these that is a valid email address:

1. The entity's `email` metadata
2. The entity's name
3. The name or `email` metadata of one of the entity's aliases

## How secret access works

When Opal grants a user access to a secret, it creates an `opal-`-prefixed policy for that user and secret path, and an `opal-`-prefixed OIDC role bound to the user's email addresses. The user signs in to Vault with OIDC using that role. When access ends, Opal deletes the policy, which also invalidates sessions that use it, and then deletes the role.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.