Skip to content

Commit b94a1ee

Browse files
authored
DEV-828 - Update GitLab guidance for project/group access tokens (#2484)
* DEV-828 - Update GitLab guidance for project/group access tokens * add roles
1 parent 280f338 commit b94a1ee

File tree

1 file changed

+20
-18
lines changed

1 file changed

+20
-18
lines changed

docs/2.0/docs/pipelines/installation/viamachineusers.md

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -85,14 +85,18 @@ GitLab uses access tokens for authentication. There are several types of access
8585
2. Project Access Tokens
8686
3. Group Access Tokens
8787

88-
For Pipelines, we recommend using Personal Access Tokens with carefully scoped permissions.
88+
For Pipelines, we recommend using Project or Group Access Tokens.
8989

90-
#### Personal Access Tokens
90+
Note that Project and Group access tokens are only available in certain GitLab licenses. Specifically:
9191

92-
- Personal Access Tokens provide user-level access and can be scoped to specific APIs and resources.
92+
[Project Access Tokens](https://docs.gitlab.com/user/project/settings/project_access_tokens/#token-availability)
93+
* On GitLab SaaS: If you have the Premium or Ultimate license tier, only one project access token is available with a [trial license](https://about.gitlab.com/free-trial/).
94+
* On GitLab Self-Managed instances: With any license tier. If you have the Free tier, consider [restricting the creation of project access tokens](https://docs.gitlab.com/user/project/settings/project_access_tokens/#restrict-the-creation-of-project-access-tokens) to lower potential abuse.
9395

94-
- They can be created with varying expiration periods or set to never expire.
96+
[Group Access Tokens](https://docs.gitlab.com/user/group/settings/group_access_tokens/)
9597

98+
* On GitLab.com, you can use group access tokens if you have the Premium or Ultimate license tier. Group access tokens are not available with a [trial license](https://about.gitlab.com/free-trial/).
99+
* On GitLab Dedicated and self-managed instances, you can use group access tokens with any license tier.
96100

97101
</TabItem>
98102
</Tabs>
@@ -388,28 +392,26 @@ For more information on creating and using GitHub Actions Repository secrets, re
388392
<TabItem value="gitlab" label="GitLab">
389393

390394

391-
For GitLab, Pipelines requires a single machine user with `api` and `read_repository` access. This user will be used to authenticate API calls and access repositories within your GitLab group.
395+
For GitLab, Gruntwork Pipelines two CI variables. The first, the `PIPELINES_GITLAB_TOKEN` requires the `Developer`, `Maintainer` or `Owner` role and the scopes listed below. This token will be used to authenticate API calls and access repositories within your GitLab group. The second, the `PIPELINES_GITLAB_READ_TOKEN` will be used to access your own code within GitLab. If not set, Pipelines will default to the `CI_JOB_TOKEN` when accessing internal GitLab hosted code.
392396

393-
### Creating the CI User
394-
395-
1. Create a dedicated GitLab user account to serve as your CI user
396-
2. Add this user to your GitLab group with appropriate permissions:
397-
- Developer access to your infrastructure repositories
398-
399-
**Checklist:**
400-
<PersistentCheckbox id="via-machine-users-gitlab-1" label="GitLab CI user created" />
401-
<PersistentCheckbox id="via-machine-users-gitlab-2" label="CI user added to GitLab group" />
402397

403398
### Creating the Access Token
404399

405-
Gruntwork recommends [creating](https://docs.gitlab.com/user/profile/personal_access_tokens/#create-a-personal-access-token) two Personal Access Tokens for the CI user as best practice:
406-
- **PIPELINES_GITLAB_TOKEN** token with `api` scope for making API calls to e.g. create comments on merge requests
407-
- **PIPELINES_GITLAB_READ_TOKEN** token with `read_repository` scope for accessing GitLab repositories e.g your catalog or infrastructure modules
400+
Gruntwork recommends [creating](https://docs.gitlab.com/user/project/settings/project_access_tokens/#create-a-project-access-token) two Project or Group Access Tokens as best practice:
401+
| Token Name | Required Scopes | Required Role | Purpose |
402+
| ------------------------------- | -------------------------------------------- | ------------------------------- | ---------------------------------------------------------------------------- |
403+
| **PIPELINES_GITLAB_TOKEN** | `api` (and `ai_features` if using GitLab AI) | Developer, Maintainer, or Owner | Making API calls (e.g., creating comments on merge requests) |
404+
| **PIPELINES_GITLAB_READ_TOKEN** | `read_repository` | Any | Accessing GitLab repositories (e.g., your catalog or infrastructure modules) |
408405

409-
You may however generate a single token with both `api` and `read_repository` scopes if you prefer and use it for both purposes.
406+
You may however generate a single token all scopes scopes if you prefer and use it for both purposes.
410407

411408
These tokens will be stored in your CI/CD variables.
412409

410+
:::note
411+
412+
If you have GitLab AI installed then you will also need the `ai_features` scope on `PIPELINES_GITLAB_TOKEN`. This requirement to add `ai_features` is driven by the mechanics of how GitLab operates and not because Pipelines itself behaves differently in the presence of GitLab AI.
413+
:::
414+
413415
:::tip
414416
Set an expiration date according to your organization's security policies. We recommend 90 days as a balance between security and maintenance.
415417
:::

0 commit comments

Comments
 (0)