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

Published
Length
3 min read

Luis Felipe Dias

All posts

Integrating gitlab ci and ldap lets your directory groups control who can run build jobs. When a user triggers a pipeline, the server checks their directory roles before starting work. This workflow links user records to code tasks in one place. Teams manage roles in the directory instead of updating every single code project by hand. When an engineer leaves the company, removing their directory user stops their build rights right away. How gitlab ci and ldap share user roles and data The co

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.

Integrating gitlab ci and ldap lets your directory groups control who can run build jobs. When a user triggers a pipeline, the server checks their directory roles before starting work.

This workflow links user records to code tasks in one place. Teams manage roles in the directory instead of updating every single code project by hand. When an engineer leaves the company, removing their directory user stops their build rights right away.

How gitlab ci and ldap share user roles and data

The code server talks to the directory server over a secure network link. It uses a dedicated bind account to search the directory tree for user records. When a person logs in, the server checks their password against the directory record.

Group sync runs on a set schedule to match directory groups with project teams. The server reads group member lists and updates project access levels to match them. A developer in the release group gets rights to trigger production pipelines right away.

During a build, the runner pulls code and checks the user role that started it. Protected branches and deploy targets only run if the user belongs to an allowed group. The directory holds the truth, and the code server follows those group rules.

Many teams use one shared service account with broad read and write rights for everything. If that account leaks in a build log, an attacker can read the whole directory. You should give the bind user read rights only to the user and group trees.

Another common issue happens when build jobs query the directory directly using static keys. Teams store these long-lived keys in project variables and forget to rotate them. Any script in the pipeline can read those variables and print them to the console.

GitLab CI Security + LDAP Directory Services: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Unlogged directory queries from build runners also create blind spots for security teams. When ten runners use the same bind account, logs do not show which job ran. You cannot tell if a query came from a valid build or a rogue script.

Scoping roles and network paths for safer builds

Start by locking down the network path between your code server and directory hosts. Only the main server nodes should talk to the directory port over encrypted transport. Build runners should not have direct network paths to the directory server at all.

Create a dedicated read-only bind account just for the code server group sync. Scope its search base to the exact organizational unit that holds active engineering staff. Block it from reading password hashes, phone numbers, or national IDs stored in user objects.

When a pipeline needs to check user data, use the server API instead of direct queries. Scope job tokens to the single project that runs the current build task. Rotate bind passwords on a set schedule and alert your team on failed bind attempts.

Keep audit logs for both directory binds and pipeline runs in a central log store. Match the user identity on each pipeline trigger to a real person in your directory. Clear logs and tight roles keep your automated builds safe and easy to manage.

Check database and API queries on the wire

Identity tools, roles, and network rules decide who opens a session. Setup alone cannot check what each query does or mask sensitive values in a response once a session starts. When workflows touch Postgres, MySQL, SQL Server, MongoDB, ClickHouse, Kubernetes APIs, SSH, or internal HTTP APIs, hoop.dev runs beside those services as an open-source proxy, a sidecar for your Postgres or API. It inspects requests coming in and results going back on the wire.

Your login details and client tools stay as they are while hoop.dev guardrails refuse bad deletes or drops before they run. On responses, hoop.dev data masking rewrites matched sensitive values in memory. Furthermore, hoop.dev holds SOC 2 Type II, is MIT licensed, and writes every query and decision to an audit trail that generates evidence for HIPAA, GDPR, and PCI DSS. See the source on GitHub.

Frequently asked questions

Can build runners log in to the directory directly?

Runners do not need direct directory logins for standard code builds and deployments. The main code server checks directory groups before it sends any job to a runner. Keep runners on a separate network segment away from your core directory servers.

What happens to scheduled pipelines when a user leaves the directory?

Each scheduled pipeline belongs to the user who created the schedule in the project. When group sync marks that user as blocked in the directory, their schedules stop running. Another active team member must take ownership of the schedule to start it again.

How do we protect personal data stored in directory attributes?

Limit the bind account so it only reads group membership and basic login attributes. If logs or query results contain emails or phone numbers, masking rewrites matched fields in results. This keeps sensitive staff records out of build logs and test outputs.

The query runs. The emails stay hidden.