# GitLab Configuration

## Create an Access Token for GitLab

**Supported GitLab Authentication**

For secure authentication, we recommend using Personal Access Tokens. For more information on creating these, refer to the official [GitLab Docs on Personal Access Tokens](https://docs.gitlab.com/user/profile/personal_access_tokens/).

While username and password authentication may still be available, it is less secure and not recommended for integrations. GitLab suggests using tokens as the preferred method for enhanced security.

### Required Token Permissions

| Feature | GitLab |
| --- | --- |
| [Automated Commit Feedback](https://help.sonatype.com/en/automated-commit-feedback.html "Automated Commit Feedback") | **api** |
| [Automated Pull Requests](https://help.sonatype.com/en/automated-pull-requests.html "Automated remediation") | **api + write_repository** |
| [Pull Request Commenting](https://help.sonatype.com/en/pull-request-commenting.html "Pull Request Commenting") | **api** |
| [Pull Request Line Commenting](https://help.sonatype.com/en/pull-request-commenting.html "Pull Request Commenting") | **api** |
| [Bitbucket Code Insights](https://help.sonatype.com/en/bitbucket-code-insights.html "Bitbucket Code Insights") | N/A |

### Create an access token:

To create a personal access token:

1. Log in to GitLab.
2. Click your profile image and select **Settings**.
3. Select **Access Tokens** from the **User Settings** menu.
4. Enter a name and optional expiration date for the token.
5. Select the **api** and **write_repository** scopes.
6. Click the **Create personal access token** button.
7. Save the personal access token. You will not be able to view this token again.

|     |
| --- |
|  |

## Protecting the Target Branch in GitLab

You can prevent merge requests from being merged if their pipeline did not succeed. A failing IQ policy evaluation will cause the pipeline to fail and block the merge request. You can enable this feature (now called auto-merge) via the project settings as shown below.

[See GitLab docs for more information](https://docs.gitlab.com/ee/user/project/merge_requests/auto_merge.html).
