Certified Jenkins Engineer
Automation and Security
Demo Jenkins Authentication
In this guide, we’ll dive into configuring authentication and authorization in Jenkins. By default, Jenkins creates a single admin user and doesn’t allow team members to self-register. You can integrate with external identity systems (LDAP or Active Directory) or use the built-in database. Follow these steps to secure your Jenkins instance.
1. Built-in User Database
- Log in as the initial admin user.
- Navigate to Manage Jenkins → Configure Global Security.
- Under Security Realm, you’ll see the default option:
By default, Jenkins uses its own user database:
To view or manage these users, go to Manage Jenkins → Manage Users:
Enabling Self-Registration
- Under Configure Global Security, disable Keep me signed in.
- Enable Allow users to sign up and click Apply.
Note
Allowing public sign-up can lead to unwanted accounts. Review registrations regularly or integrate with an external directory for tighter control.
Log out. On the login screen, you’ll now see Sign up. Create a new user (e.g., John). Jenkins may warn you about weak passwords:
Returning to Manage Users shows both admin and John:
2. Authorization Strategies
Authorization controls who can view, build, or configure jobs. In Configure Global Security, scroll to Authorization. The default is Logged-in users can do anything—only authenticated users have full access. Another setting is Anyone can do anything:
Authorization Strategy | Description |
---|---|
Logged-in users can do anything | Only authenticated users have full access. |
Anyone can do anything | Public access to all actions without login. |
Select Anyone can do anything, click Save, then log out. Now you can view and trigger builds anonymously:
Started by user unknown or anonymous
Running as SYSTEM
Building in workspace /var/lib/jenkins/workspace/ascii-deploy-job
Copied 1 artifact from "ascii-test-job" build number 5
[ascii-deploy-job] $ /bin/sh -xe /tmp/jenkins37422262028379197254.sh
+ exit 1
Build step 'Execute shell' marked build as failure
Finished: FAILURE
Warning
Allowing anonymous users to trigger builds is a serious security risk. Unauthenticated users should never run jobs on a production Jenkins master.
Log back in as admin, set Authorization to Logged-in users can do anything, and enable Anonymous users read access. Click Save and log out. Visitors can now view jobs but cannot create or manage them.
3. Mock Security Realm (Simulating LDAP)
To simulate external authentication without a real directory server, install the Mock Security Realm plugin:
- Go to Manage Jenkins → Manage Plugins → Available.
- Search for mock-security-realm and install.
After installing, return to Configure Global Security. Under Security Realm, select Mock Security Realm:
In the User/Group Definitions box, enter one user or group per line (passwords default to the username):
ali manager
bob qa
emma developer
tina developer qa
alice admins
charlie qa
darlene qa admins
Disable Allow anonymous read access if desired, then click Save. The Manage Users page will disappear:
Logging In with Mock Users
Log out, then log in as one of the mock users:
- siddharth (password:
siddharth
)
- tina (password:
tina
)
The Mock Security Realm handles authentication and group assignments only; it doesn’t enforce permissions. Next, explore role-based authorization to grant the admin group exclusive rights to delete or configure jobs.
Links and References
Watch Video
Watch video content