The Simplest Way to Make GitLab CI and SAML Work Like They Should

Published
Length
3 min read

Luis Felipe Dias

All posts

Using gitlab ci and saml lets teams link build jobs to real user identities. Your identity provider checks the user, and GitLab runs the build with set rules. This workflow stops teams from sharing static keys across build runners. Instead, a person logs in through single sign-on and triggers a pipeline. Every job then carries clear proof of who started the work. Security teams can see which user ran a deploy and when it happened. How gitlab ci and saml share identity and permissions First,

Your coding agents run with your access.

Claude Code reaches prod with a developer's credentials, and approval prompts get clicked through. hoop.dev checks every query, masks sensitive data, and holds risky changes for a human.

Using gitlab ci and saml lets teams link build jobs to real user identities. Your identity provider checks the user, and GitLab runs the build with set rules.

This workflow stops teams from sharing static keys across build runners. Instead, a person logs in through single sign-on and triggers a pipeline. Every job then carries clear proof of who started the work. Security teams can see which user ran a deploy and when it happened.

How gitlab ci and saml share identity and permissions

First, a user signs in to GitLab through the company identity provider. The SAML assertion sends the user identity and group list to GitLab. GitLab reads these group claims and maps them to project roles. This step controls who can view code, merge changes, or start a pipeline.

When a user triggers a build, GitLab CI records that user identity. The runner picks up the job and gets a temporary job token. This token carries the scope of the user and the project. If the job needs cloud resources, it can trade an identity token for cloud access.

Data flows in a clear path between both systems during this process. The identity provider holds the source of truth for team groups. GitLab enforces those group rules on protected branches and deploy targets. Runners execute the tasks and send job logs back to the main server.

Group sync keeps project roles fresh when people change teams or leave. When an admin removes a user from a SAML group, GitLab drops their role. That user can no longer trigger deploys to protected targets.

Common failure modes and how to scope runner roles

Many teams still put shared service account keys inside project variables. Any developer with merge rights can edit the build file and read those keys. Broad tokens also create risk when a single runner serves many projects. If one job leaks a token, an attacker can reach every linked system.

Unlogged queries are another common blind spot in automated pipelines. A runner might connect to a database using a shared admin password. The database log shows the shared account name instead of the user who triggered the job. When a bad query runs, nobody knows which build or person caused it.

GitLab CI Security + Protocol Translation (SAML to OIDC): architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

You can fix this by scoping roles and network paths for each runner. Give protected branches their own dedicated runners in an isolated network segment. Never allow a public merge request to run on a production runner. Map SAML groups to protected deploy targets so only approved leaders can trigger them.

Replace stored static passwords with short identity tokens wherever your tools allow it. Scope each job role to the exact database tables or cloud buckets it needs. Keep your SAML group claims small and tied to clear job duties.

Auditing pipeline actions across databases and cloud targets

Auditors ask for clear logs that link every database change to a person. SAML logs show when a user logged into the source code tool. Build logs show which script ran on the build machine. Still, target systems often miss the link between the script and the human.

Teams should pass job metadata down to the target system logs. Every deploy script should log the pipeline ID and the user email. Data masking is also vital when build logs print output from live systems. Masking rewrites matched fields like emails, phone numbers, card numbers, and national IDs in results.

Good network rules also keep build runners from reaching sensitive data stores by mistake. Lock down runner egress so jobs only talk to approved internal hosts. Review your SAML group mappings every quarter to remove old deploy permissions.

Govern statements and responses across databases and APIs

Good config and scoped roles are needed setup. They do not check single queries in flight or mask sensitive fields in returned rows. Across Postgres, MySQL, SQL Server, MongoDB, ClickHouse, Kubernetes APIs, SSH, and internal HTTP endpoints, hoop.dev runs beside each supported service as an open-source proxy, a sidecar for your database or API.

First, hoop.dev guardrails block banned queries before they run. Then hoop.dev data masking rewrites matched sensitive values in responses in memory. The audit trail records every statement and verdict per resource. Furthermore, hoop.dev holds SOC 2 Type II and is open source on GitHub.

Frequently asked questions

Can SAML users trigger GitLab CI pipelines without a separate password?

Yes, users sign in through their identity provider and start pipelines in the web app. For git push actions, they use personal tokens or SSH keys tied to their account.

How do SAML group claims control production deploy jobs?

SAML group sync maps identity provider groups to specific GitLab groups and roles. Admins then lock protected deploy targets so only members of those synced groups can run them.

What happens to running jobs when a user loses SAML access?

Active jobs finish their current run, but the user cannot start any new pipelines. Once SAML sync removes their role, GitLab blocks them from all protected branches and targets.

The query runs. The emails stay hidden.