--- stage: Verify group: Pipeline Security info: To determine the technical writer assigned to the Stage/Group associated with this page, see https://handbook.gitlab.com/handbook/product/ux/technical-writing/#assignments --- # Tutorial: Update HashiCorp Vault configuration to use ID Tokens **(PREMIUM ALL)** This tutorial demonstrates how to convert your existing CI/CD secrets configuration to use [ID Tokens](../secrets/id_token_authentication.md). The `CI_JOB_JWT` variables are deprecated, but updating to ID tokens requires some important configuration changes to work with Vault. If you have more than a handful of jobs, converting everything at once is a daunting task. There isn't one standard method to migrate to [ID tokens](../secrets/id_token_authentication.md), so this tutorial includes two variations for how to convert your existing CI/CD secrets. Choose the method that is most appropriate for your use case: 1. Update your Vault configuration: - Method A: Migrate JWT roles to the new Vault auth method 1. [Create a second JWT authentication path in Vault](#create-a-second-jwt-authentication-path-in-vault) 1. [Recreate roles to use the new authentication path](#recreate-roles-to-use-the-new-authentication-path) - Method B: Move `iss` claim to roles for the migration window 1. [Add `bound_issuers` claim map to each role](#add-bound_issuers-claim-map-to-each-role) 1. [Remove `bound_issuers` claim from auth method](#remove-bound_issuers-claim-from-auth-method) 1. [Update your CI/CD Jobs](#update-your-cicd-jobs) ## Prerequisites This tutorial assumes you are familiar with GitLab CI/CD and Vault. To follow along, you must have: - An instance running GitLab 16.0 or later, or be on GitLab.com. - A Vault server that you are already using. - CI/CD jobs retrieving secrets from Vault with `CI_JOB_JWT`. In the examples below, replace: - `vault.example.com` with the URL of your Vault server. - `gitlab.example.com` with the URL of your GitLab instance. - `jwt` or `jwt_v2` with your auth method names. ## Method A: Migrate JWT roles to the new Vault auth method This method creates a second JWT auth method in parallel to the existing one in use. Afterwards all Vault roles used for the GitLab integration are recreated in this new auth method. ### Create a second JWT authentication path in Vault As part of the transition from `CI_JOB_JWT` to ID tokens, you must update the `bound_issuer` in Vault to include `https://`: ```shell $ vault write auth/jwt/config \ oidc_discovery_url="https://gitlab.example.com" \ bound_issuer="https://gitlab.example.com" ``` After you make this change, jobs that use `CI_JOB_JWT` start to fail. You can create multiple authentication paths in Vault, which enable you to transition to IT Tokens on a project by job basis without disruption. 1. Configure a new authentication path with the name `jwt_v2`, run: ```shell vault auth enable -path jwt_v2 jwt ``` You can choose a different name, but the rest of these examples assume you used `jwt_v2`, so update the examples as needed. 1. Configure the new authentication path for your instance: ```shell $ vault write auth/jwt_v2/config \ oidc_discovery_url="https://gitlab.example.com" \ bound_issuer="https://gitlab.example.com" ``` ### Recreate roles to use the new authentication path Roles are bound to a specific authentication path so you need to add new roles for each job. 1. Recreate the role for staging named `myproject-staging`: ```shell $ vault write auth/jwt_v2/role/myproject-staging - <