Jenkins Authentication and Authorization: Security Realms, Matrix and Role-Based Access, LDAP, SSO and OIDC

CI CD Pipelines with Jenkins 40 min min read Updated: Nov 17, 2026 Intermediate
Jenkins Authentication and Authorization: Security Realms, Matrix and Role-Based Access, LDAP, SSO and OIDC
Intermediate Topic 1 of 3

Two Separate Questions

QuestionJenkins settingExamples
Who are you? (authentication)Security RealmJenkins database, LDAP, Active Directory, OIDC, SAML, GitHub OAuth
What may you do? (authorization)Authorization StrategyMatrix, Project-based matrix, Role-based, Logged-in users can do anything

Both are in Manage Jenkins → Security. Change them carefully and keep a second browser window logged in as admin until you confirm the new setup works.

Never use these in production: Anyone can do anything and Logged-in users can do anything give every user full control, including running scripts on the controller. Use matrix or role-based security.

Security Realm Options

RealmWhen to use
Jenkins' own user databaseSmall labs. Users are created and kept inside Jenkins
LDAP / Active DirectoryCompany directory. Users and groups come from the directory
OpenID Connect (OIDC) pluginSingle sign-on with Keycloak, Okta, Azure AD / Entra ID, Google
SAML pluginEnterprise SSO using SAML identity providers
GitHub Authentication pluginDevelopers sign in with GitHub, teams map to groups

LDAP Example With JCasC

yaml jenkins: securityRealm: ldap: configurations: - server: "ldaps://ldap.example.com:636" rootDN: "dc=example,dc=com" userSearchBase: "ou=people" userSearch: "uid={0}" groupSearchBase: "ou=groups" managerDN: "cn=jenkins,ou=service,dc=example,dc=com" managerPasswordSecret: "${LDAP_PASSWORD}" disableMailAddressResolver: false groupIdStrategy: "caseInsensitive" userIdStrategy: "caseInsensitive"
  • Always use LDAPS (TLS) or StartTLS
  • Use a read-only service account to search the directory
  • Use group names, not individual users, in permissions

OIDC Single Sign-On

yaml jenkins: securityRealm: oic: clientId: "jenkins" clientSecret: "${OIDC_CLIENT_SECRET}" wellKnownOpenIDConfigurationUrl: "https://sso.example.com/realms/corp/.well-known/openid-configuration" userNameField: "preferred_username" groupsFieldName: "groups" scopes: "openid email profile" logoutFromOpenidProvider: true escapeHatchEnabled: true # a local admin can still log in if SSO is down escapeHatchUsername: "breakglass" escapeHatchSecret: "${BREAKGLASS_PASSWORD}"
Keep a break-glass account: If the SSO provider is down you can still log in. Protect that account with a long random password stored in a vault.

Matrix Authorization

The matrix lists permissions as columns and users or groups as rows. Tick what each may do.

Permission groupExamplesTypical holder
OverallAdminister, Read, SystemReadAdmin group (Administer), everyone (Read)
AgentConfigure, Connect, Create, DeletePlatform team
JobRead, Build, Configure, Create, Delete, Cancel, WorkspaceRead/Build for developers; Configure for owners
RunDelete, UpdateOwners
CredentialsView, Create, Update, Delete, ManageDomainsProject owners, security team
SCM, ViewTag, Configure/Create viewsTeams
yaml jenkins: authorizationStrategy: globalMatrix: entries: - group: name: "jenkins-admins" permissions: ["Overall/Administer"] - group: name: "authenticated" permissions: ["Overall/Read", "Job/Read"] - group: name: "developers" permissions: ["Job/Build", "Job/Cancel", "Job/Workspace", "Run/Replay"]

Project-Based Matrix: Per-Job Permissions

  • The Project-based Matrix Authorization Strategy lets each job or folder add its own matrix
  • Permissions inherit from parents, you can add more but not remove inherited ones (unless you stop inheritance)
  • Good for a few teams sharing one controller

Role-Based Strategy

The Role-based Authorization Strategy plugin works like role-based access in other tools: define roles, then assign users or groups to roles.

Role typeApplies toPattern example
Global rolesWhole Jenkinsadmin, readonly, developer
Item (project) rolesJobs whose full name matches a regular expressionteam-a/.* gives Team A rights only in its jobs
Agent rolesNodes matching a patternlinux-prod-.*
yaml jenkins: authorizationStrategy: roleBased: roles: global: - name: "admin" permissions: ["Overall/Administer"] entries: [{group: "jenkins-admins"}] - name: "readonly" permissions: ["Overall/Read"] entries: [{group: "authenticated"}] items: - name: "team-a" pattern: "team-a/.*" permissions: ["Job/Build", "Job/Configure", "Job/Read", "Job/Cancel", "Credentials/View"] entries: [{group: "team-a"}]

Folders for Multi-Team Jenkins

  • Create one folder per team (Folders plugin). Put jobs and folder-level credentials inside
  • Give each team item roles or folder permissions only for its folder
  • Use folder-level shared libraries for team-specific code in the sandbox

API Tokens and Service Accounts

  • For scripts and tools, create an API token: user menu → Security → API Token. Use user:token with Basic authentication
  • Tokens act with the user's permissions, so use a dedicated service account with minimal rights, not a person's account
  • Revoke tokens when the integration is retired. Rotate regularly
bash # Trigger a build with an API token (CSRF crumb not needed for token auth) curl -sS -X POST -u ci-bot:$JENKINS_TOKEN "https://jenkins.example.com/job/team-a/job/shop/buildWithParameters?BRANCH=main"

Least-Privilege Model

GroupPermissions
Admins (2 to 4 people)Administer; used rarely, with MFA through SSO
Platform teamManage agents, plugins (through change control), view all jobs
Team developersRead, Build, Cancel, Workspace in their folder; Configure for team leads
Release managersApprove production input steps (see submitter in input)
AuditorsRead-only, plus audit logs
Service accountsExactly the jobs and actions the integration needs

Practice Tasks

  1. Switch a lab Jenkins to project-based matrix security, keeping an admin session open
  2. Create two folders and give two groups access only to their own folder
  3. Configure LDAP or OIDC against a lab Keycloak
  4. Create a service account with only Job/Build in one folder and trigger it with an API token
  5. Verify that a developer cannot see another team's credentials

Conclusion

Authentication (security realm) proves who a user is; authorization (strategy) decides what they can do. Use LDAP or OIDC single sign-on, matrix or role-based permissions on groups, folders per team, a break-glass admin and service accounts with tokens and minimal rights.

Quick Summary: realm vs strategy; LDAP/OIDC YAML; matrix permissions; role-based global/item/agent; folders; API tokens + service accounts; least-privilege groups.

Get Newsletter

Subscibe to our newsletter and we will notify you about the newest updates on Edugators