Require Job Token Allowlist + GitLab Collector
Enforce Require Job Token Allowlist using data collected by GitLab Collector. Automatically check repository and ownership standards on every PR.
How GitLab Collector Powers This Guardrail
The GitLab Collector gathers metadata from your vcs systems. This data flows into Lunar's Component JSON, where the Require Job Token Allowlist guardrail evaluates it against your standards.
When enabled, this check runs automatically on every PR and in AI coding workflows, providing real-time enforcement with actionable feedback.
Quick Start Configuration
Add both the collector and policy to your lunar-config.yml to enable this guardrail.
# Step 1: Enable the GitLab Collector
collectors:
- uses: github://earthly/lunar-lib/collectors/gitlab@v1.0.5
# with: ...
# Step 2: Enable the VCS Guardrails
policies:
- uses: github://earthly/lunar-lib/policies/vcs@v1.0.5
include: [require-job-token-allowlist]
# with: ...
What GitLab Collector Collects
This collector gathers the following data that the Require Job Token Allowlist guardrail evaluates.
merge-request
Fetches merge-request metadata from the GitLab API for the MR being evaluated and writes it under .vcs.pr — title, description, source and target branch, author, labels, draft flag, state, URL, and number. This is the GitLab source of .vcs.pr.* that the ticket collectors (jira, linear) and change-management / change-to-ticket checks read. Runs only in merge-request context.
repository
Fetches basic project settings from the GitLab API including visibility (public/internal/private), default branch, topics, and the configured merge method (merge commit, rebase, fast-forward) plus squash options. Writes to .vcs.provider, .vcs.visibility, .vcs.default_branch, .vcs.topics, and .vcs.merge_strategies.
branch-protection
Fetches protected-branch config, MR approval rules, external status checks, and push rules for the default branch from the GitLab API, normalizing them into the shared .vcs.branch_protection shape with a .source field of "gitlab". Collects required approvals (from approval rules), code-owner approval, reset-on-push (dismiss stale reviews), required status checks (pipeline-success and/or external status checks, with their names in required_checks), signed-commit and linear-history enforcement, allowed force push, and push/merge access levels. Licensed- only signals degrade gracefully to their safe defaults on CE/unlicensed.
access-permissions
Fetches project access permissions from the GitLab API with pagination. Collects direct project members (username, access level, type) and shared groups (path, name, access level). Does not expand group memberships. Writes to .vcs.access.collaborators and .vcs.access.teams.
Example Data Flow
Here's an example of the data that GitLab Collector writes to the Component JSON, which Require Job Token Allowlist then evaluates.
{
"vcs": {
"provider": "gitlab",
"default_branch": "main",
"visibility": "private",
"topics": ["backend", "api", "microservice"],
"merge_strategies": {
"allow_merge_commit": false,
"allow_squash_merge": true,
"allow_rebase_merge": true
},
"pr": {
"number": 42,
"title": "[ENG-123] Add rate limiting to the auth service",
"description": "Implements a token-bucket limiter. Closes ENG-123.",
"url": "https://gitlab.com/acme/auth-service/-/merge_requests/42",
"source_branch": "eng-123-rate-limiting",
"target_branch": "main",
"author": "alice",
"labels": ["backend", "security"],
"draft": false,
"state": "open"
},
"branch_protection": {
"enabled": true,
"source": "gitlab",
"branch": "main",
"require_pr": true,
"required_approvals": 2,
"require_codeowner_review": true,
"dismiss_stale_reviews": true,
"require_status_checks": true,
"required_checks": ["security-gate"],
"require_signed_commits": false,
"require_linear_history": false,
"allow_force_push": false,
"allow_deletions": false,
"restrictions": {
"push_access_level": "maintainer",
"merge_access_level": "developer"
}
},
"access": {
"collaborators": [
{"username": "alice", "permission": "owner", "type": "User"},
{"username": "deploy-bot", "permission": "developer", "type": "Bot"}
],
"teams": [
{"slug": "platform", "name": "Platform Team", "permission": "maintainer"}
]
},
"job_token_allowlist": {
"status": "ok",
"enabled": true,
"projects": 2,
"groups": 1,
"checked_at": "2026-11-23T14:02:11Z"
}
}
}
Configuration Options
GitLab Collector Inputs
| Input | Required | Default | Description |
|---|---|---|---|
gitlab_host |
Optional |
gitlab.com
|
GitLab host for self-managed instances (e.g. gitlab.example.com) |
cron_schedule |
Optional |
0 8 * * *
|
When the `-cron` sub-collectors run, as a cron expression in UTC, at least 10 minutes apart |
VCS Guardrails Inputs
| Input | Required | Default | Description |
|---|---|---|---|
min_approvals |
Optional |
1
|
Minimum number of required approvals (integer, or omit to skip check) |
required_default_branch |
Optional |
main
|
Required default branch name for the require-default-branch policy. Defaults to 'main' |
allowed_merge_strategies |
Required | — | Comma-separated list of allowed merge strategies for the allowed-merge-strategies policy (merge, squash, rebase). Only listed strategies will be allowed |
require_job_token_allowlist |
Optional |
false
|
Set to `"true"` to run `require-job-token-allowlist`. Off by default, so importing the whole policy, at any enforcement level, doesn't start failing GitLab projects whose job token allowlist is off. |
allowed_bypass_actors |
Required | — | Bypass actors the disallow-bypass-actors check accepts, one per line or comma-separated. An entry is an actor type (`OrganizationAdmin`, `DeployKey`) or `<type>:<id>`: a ruleset bypass actor's `actor_id` (`Integration:98765`, `RepositoryRole:5`), or a classic bypass allowance's login or slug (`User:jdoe`, `Team:release-managers`, `Integration:release-bot`). `#` comments out the rest of a line: ```yaml with: allowed_bypass_actors: | Integration:98765 # release app, tags after CI passes ``` |
rerun_collectors |
Optional |
auto
|
Collectors a failing branch-protection or repository-settings check tells the PR author to rerun with a `/lunar rerun` comment once a repository admin changes the setting, named as your configuration imports them. The default, auto, picks the provider collector's sub-collector that records the setting (e.g. github.branch-protection, gitlab.repository); set it for a renamed import, or to "" to leave the hint out where the Hub doesn't accept the comment: Lunar accepts it from 4.15.0 when comment reruns are enabled, which they are by default from 5.2.0. |
Ready to Automate Your Standards?
See how Lunar can turn your AGENTS.md, engineering wiki, compliance docs, or postmortem action items into automated guardrails with our 300+ built-in guardrails.