Example setup

This configuration is an example, which shows how you can connect OpenID Connect with Hashicorp Vault.

Create vault.json with the following content:


Create docker-compose.yaml with the following content:

    image: vault:latest
    container_name: vault
      - "8200:8200"
      - ./volumes/vault:/vault/file:rw
      - ./vault.json:/vault/config/vault.json:rw
      - IPC_LOCK
    entrypoint: vault server -config=/vault/config/vault.json -dev

Run it using docker-compose up command.

Create root token using docker exec -it vault vault operator init -n 1 -t 1, write down the root token and unseal key.

Defguard configuration

  1. Go to OpenID Apps and click Add new button.

  2. Use Scopes: openid email profile

  3. Use as Redirect URI

  4. Copy and save Client ID and Client secret, we will need them later.

Vault configuration

  1. Unseal vault by accessing and using unseal key.

  2. Login into Vault using method TOKEN and using root token.

  3. Navigate to Access -> Auth Methods and click Enable new method button.

  4. Enable OIDC method.

  5. Use values below: OIDC discovery URL: OIDC client ID: <YOUR_CLIENT_ID> OIDC secret ID: <YOUR_CLIENT_SECRET>

Creating role in vault

  1. Login into vault CLI using root token: docker exec -it vault vault login <ROOT_TOKEN>

  2. To create role reader use command below:

docker exec -it vault vault write auth/oidc/role/reader \
    bound_audiences="<YOUR_CLIENT_ID>" \
    allowed_redirect_uris="" \
    user_claim="sub" \

Now you can login into vault using Defguard. Use OIDC as login method and role reader. Please note this role will only allow you to login, to add permissions you need to create policy and assign it to role.

Last updated