-
Notifications
You must be signed in to change notification settings - Fork 110
docs: add GitLab OAuth setup and provider enrollment guide #6477
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
c6ccdc5
42e1874
24b1186
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,88 @@ | ||
| --- | ||
| title: Create a GitLab OAuth application | ||
| sidebar_position: 75 | ||
| --- | ||
|
|
||
| ## Prerequisites | ||
|
|
||
| - [GitLab](https://gitlab.com) account | ||
| - A [local Minder server](run_the_server) running with the `gitlab_provider` | ||
| feature flag enabled (see [Using feature flags](../developer_guide/feature_flags)) | ||
|
|
||
| ## Steps | ||
|
|
||
| 1. Create a GitLab OAuth application. GitLab supports three ownership levels — | ||
| choose the one that fits your setup: | ||
|
|
||
| - **User-owned:** Go to [User Settings > Applications](https://gitlab.com/-/user_settings/applications) | ||
| - **Group-owned:** Go to your GitLab group → **Settings** → **Applications** | ||
| - **Instance-wide:** Go to **Admin Area** → **Applications** (self-managed only) | ||
|
|
||
| 2. Click **Add new application** and enter the following details: | ||
| - **Name:** `Minder` (or any name you prefer) | ||
| - **Redirect URI** (add both URIs, one per line): | ||
| ``` | ||
| http://localhost:8080/api/v1/auth/callback/gitlab/cli | ||
| http://localhost:8080/api/v1/auth/callback/gitlab/web | ||
| ``` | ||
| - **Confidential:** Yes (checked) | ||
| - **Scopes:** Check `api`, `read_user`, and `read_repository` | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ("profile") worked for me for registering a repository using the OAuth flow. As mentioned, the service account flow seems to be broken for GitLab, so we'll need a separate PR for that (which may also want to add user documentation for registering a GitLab repository, with best practices).
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good catch — updating to profile as you confirmed it works. read_user gives broader access than needed. |
||
|
|
||
| 3. Click **Save application**. Copy the **Application ID** and **Secret** — the | ||
| secret is only shown once. | ||
|
|
||
| 4. Add the following to your `server-config.yaml` under the `provider:` section: | ||
|
|
||
| ```yaml | ||
| provider: | ||
| gitlab: | ||
| client_id: "YOUR_APPLICATION_ID" | ||
| client_secret: "YOUR_SECRET" | ||
| redirect_uri: "http://localhost:8080/api/v1/auth/callback/gitlab" | ||
| webhook_secret: "a-random-secret-string" | ||
| scopes: | ||
| - "api" | ||
| - "read_user" | ||
| - "read_repository" | ||
| ``` | ||
|
|
||
| The `redirect_uri` should be the base path without `/cli` or `/web` — Minder | ||
| appends the correct suffix automatically. | ||
|
|
||
| 5. Enable the `gitlab_provider` feature flag by creating `flags-config.yaml` in | ||
| the root of your Minder directory: | ||
|
|
||
| ```yaml | ||
| gitlab_provider: | ||
| variations: | ||
| enabled: true | ||
| disabled: false | ||
| defaultRule: | ||
| variation: enabled | ||
| ``` | ||
|
|
||
| 6. (Re)start the Minder server: | ||
|
|
||
| ```bash | ||
| make run-docker | ||
| ``` | ||
|
|
||
| 7. Enroll the GitLab provider using the CLI: | ||
|
|
||
| ```bash | ||
| minder provider enroll --class gitlab | ||
| ``` | ||
|
|
||
| A browser window will open to GitLab's OAuth authorization page. After | ||
| authorizing, the browser will show **Minder enrollment complete** and the CLI | ||
| will print `Provider enrolled successfully`. | ||
|
|
||
| ## Known limitations | ||
|
|
||
| - GitLab support is currently only available on self-hosted Minder instances. | ||
| The hosted instance at `api.custcodian.dev` does not yet support GitLab | ||
| enrollment. | ||
| - Webhook-based event delivery requires an externally reachable URL. For local | ||
| development, tools like [ngrok](https://ngrok.com) can expose your local | ||
| server. | ||
| - Token identity verification after enrollment is not yet implemented. | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need
write_repositoryto be able to create branches for PR remediations?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about
read_registryfor artifacts? I'm guessing the GitLab provider doesn't yet support the container / artifact provider facet...There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not needed currently — the GitLab provider doesn't yet implement PR remediation or branch creation. I'll leave it out for now and it can be added when that's implemented.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct — artifact/container registry support isn't implemented in the GitLab provider yet. Leaving it out of the minimum required scopes