Rotation Type: Dual-PhaseThis rotation maintains two active credential sets with overlapping validity, ensuring zero-downtime during rotation cycles.
This rotation needs a GitLab app connection. This guide walks you through creating a project-scoped app connection.
Prerequisites
- A project with secrets configured
- A GitLab service account that belongs to a group or subgroup (it can be newly created, with no tokens)
- A GitLab user with the Owner role on that group, to create the token the connection uses
- To create the service account on GitLab Self-Managed or GitLab Dedicated, a user that is an administrator, or a group Owner that is allowed to create service accounts
Step 1: Create a personal access token for Infisical
Infisical needs a GitLab connection whose user has the Owner role on the group that owns the service account, so that Infisical can create and revoke the service account’s tokens.1
Create a personal access token with the
api scope for a user that has the Owner role on the group. This token is for the connection, not for the service account you rotate.2
When you create the GitLab connection in Step 2, use this token with Personal Access Token as the access token type.
GitLab doesn’t let group or project access tokens create other tokens, so the rotation fails with a connection that uses one. A connection that uses OAuth works if its user has the Owner role on the group.
Step 2: Set up the rotation in Infisical
1
In your Secrets Management project, open the dashboard, select Add New, then select Add Secret Rotation.
Then, select the GitLab Service Account Token option.
Then, select the GitLab Service Account Token option.2
Under Configuration, choose the app connection and when the rotation runs:Then select Continue.
- Environment: The project environment the rotated secrets are stored in
- GitLab Connection: The app connection the rotation uses
- Rotation Interval (In Days): The number of days between rotations, up to 180
- Rotate At (Local Time): The time of day the rotation runs
- Auto-Rotation Enabled: When enabled, the token rotates on the schedule; turn it off to rotate manually only
- Create a new app connection
- Use an existing connection
Under GitLab Connection, select Create GitLab Connection in the dropdown, then fill in:
- Name: A name for the connection
- Description (optional): What the connection is for
- Self-hosted URL (optional): The URL of your GitLab Self-Managed or GitLab Dedicated instance; leave empty for GitLab.com
- Method: Access Token
- Access Token Type: Personal Access Token
- Access Token: The token from Step 1
This creates a connection scoped to the current project. To share the connection across other projects, create it at the organization level first, then select it here.
3
Under Parameters, choose the service account and the token Infisical creates for it:
- Group: The group that owns the service account; the list shows groups where the connection’s user has the Owner role (you can’t change it after you create the rotation)
- Service Account: The service account whose tokens Infisical rotates (you can’t change it after you create the rotation); the list leaves out the account the connection authenticates as
- Token Name: The name of each generated token; Infisical appends a timestamp so each rotated token has a distinct name
- Token Description (optional): A description shown on each generated token in GitLab
- Scopes: The scopes granted to each generated token
4
Under Mappings, choose the names of the Infisical secrets that hold the rotated values:
- Token ID: The name of the secret that holds the ID of the token in GitLab
- Token: The name of the secret that holds the token
5
Give the rotation a Name and an optional Description. The name must be slug-friendly.Then select Continue.
6
Under Alerts, choose who Infisical notifies if a scheduled rotation fails. Rotation failure alerts are on by default.Then select Continue.
7
Review your GitLab Service Account Token Rotation configuration, then select Create secret rotation.
The token is now available through the mapped secrets. If auto-rotation is enabled, the token rotates on your configured schedule.
Frequently asked questions
When do the generated tokens expire?
When do the generated tokens expire?
Each token expires two rotation intervals plus three days after Infisical creates it, so the token is still valid when the next rotation revokes it. GitLab limits token lifetimes to 365 days by default, so the rotation interval can be at most 180 days.A token’s expiry is fixed when Infisical creates it. When you change the rotation interval, Infisical rotates the token right away so the new token’s expiry matches the new interval, and later rotations follow the new schedule.If an administrator set a shorter maximum token lifetime on your instance, choose a rotation interval where twice the interval plus three days fits within that limit. Otherwise GitLab rejects the new token and the rotation fails with GitLab’s error.
Does Infisical change tokens it didn't create?
Does Infisical change tokens it didn't create?
No. Infisical only revokes the tokens it created for the rotation, so it never revokes the connection’s own token. A rotation can’t target the service account the connection authenticates as, because the generated token would carry the connection’s own access.If the service account already had tokens you created by hand, revoke them after your applications read the token from Infisical, so only the rotated tokens stay active.
Which permissions does the generated token have?
Which permissions does the generated token have?
The token has the scopes you select, limited by the service account’s own role in each group or project. To change what the token can reach, change the service account’s role, or edit the rotation’s scopes; from the next rotation, Infisical replaces each token with a new one that has the new scopes.
Next steps
GitLab
Set up the GitLab connection that Infisical uses to manage service account tokens.
Overview
Learn how dual-phase and single-phase rotations work.