Chapter 04Lesson 02~105 minutes

Users, Authentication Realms, Authorization Strategies, Matrix Permissions, Folders, and Least Privilege: Guided Hands-On Workflow and Core Operations

Build a disposable Jenkins least-privilege matrix with synthetic users and folders, then prove allowed and denied actions without exposing secrets.

Hands-onSynthetic usersProject matrixFoldersAllow / deny evidence

Learning objectives

  • Create disposable synthetic identities without exposing real credentials or production accounts.
  • Verify a pinned Matrix Authorization + Folders plugin baseline on Jenkins 2.568.3 LTS.
  • Configure a least-privilege project matrix while preserving a dedicated administrative recovery path.
  • Prove one allowed and one denied action for each test identity using separate sessions.
  • Record effective access evidence without logging passwords or token values.

1. Scenario and safety boundary

Use a disposable Jenkins controller bound only to 127.0.0.1. Create three synthetic personas: recovery-admin retains administration; dev-builder may read/build jobs under training/dev; auditor may read the training jobs but not build or configure them.

Recovery rule: verify recovery-admin in a separate browser session before changing authorization. Never modify the only administrator and press Save without a tested recovery identity.

2. Preflight: pin the disposable controller and plugins

Continue the Chapter 02–03 baseline. Build a local image with explicit access-control plugin versions, then record the resolved image identity locally.

FROM jenkins/jenkins:2.568.3-jdk21
USER root
RUN jenkins-plugin-cli --plugins \
    matrix-auth:3.3 \
    cloudbees-folder:6.1106.v3a_d9a_6d2465e \
    credentials:1511.v2e3cb_0008ef0
USER jenkins
docker build -t jenkins-ch04:2.568.3 .
docker volume create jenkins_ch04_home
docker run -d --name jenkins-ch04 \
  -p 127.0.0.1:8080:8080 \
  -v jenkins_ch04_home:/var/jenkins_home \
  jenkins-ch04:2.568.3

docker image inspect jenkins-ch04:2.568.3 --format '{{json .RepoDigests}}'

Complete the setup wizard locally and create recovery-admin as the initial administrator. Keep port 8080 on loopback only.

3. Create synthetic users and isolate sessions

Under Manage Jenkins → Users, create dev-builder and auditor. Use unique disposable passwords. Record usernames and intended roles only; never copy password values into notes or screenshots.

Open three browser profiles/private windows. Keeping identities separate prevents an administrator cookie from contaminating a permission test.

Do not use the special authenticated group as a shortcut role. A grant to authenticated applies to every logged-in account, including future accounts.

4. Create a folder boundary and harmless jobs

Create training/dev, then Freestyle jobs hello and status. Their steps print only synthetic data. The full names are training/dev/hello and training/dev/status; use full names in evidence.

printf 'job=%s
' "$JOB_NAME"
printf 'build=%s
' "$BUILD_NUMBER"
printf 'node=%s
' "$NODE_NAME"
printf 'workspace=%s
' "$WORKSPACE"
printf 'message=synthetic access-control lab
'

If agents are already available, run these jobs there. Do not make the built-in node a long-term execution target merely to simplify the lab.

5. Configure the least-privilege matrix

In Manage Jenkins → Security, select Project-based Matrix Authorization Strategy. Preserve recovery-admin with Overall/Administer. Give anonymous users no training access. Use only the grants required by the role contract.

Identity Global baseline training/dev scope Must remain absent
recovery-admin Overall/Administer Inherited administrative access —
dev-builder Overall/Read Job/Read, Job/Build Job/Configure, Administer, credential management
auditor Overall/Read Job/Read Build, Configure, Administer, credential management
anonymous None None All training access

Matrix grants are additive; parent/global grants can flow into children. Start narrow, save, then test before adding anything else.

6. Prove allowed and denied actions

Principal Action Expected Evidence
dev-builder Read hello Allowed Job page loads under dev-builder.
dev-builder Build hello Allowed New build number and initiating cause.
dev-builder Configure hello Denied Protected request rejected and config unchanged.
auditor Read hello Allowed Job page loads.
auditor Build hello Denied No new build created.
auditor Manage Jenkins Denied Administrative action unavailable/rejected.

If you automate a read-only check with disposable API tokens, store tokens in environment variables and never echo them.

export JENKINS_URL='http://127.0.0.1:8080'
export DEV_USER='dev-builder'
export DEV_TOKEN='<disposable-token-not-logged>'
curl -fsS -u "$DEV_USER:$DEV_TOKEN"   "$JENKINS_URL/job/training/job/dev/job/hello/api/json?tree=fullName,url,buildable"
unset DEV_TOKEN

7. Prove that item visibility is not credential administration

As dev-builder, the user may read/build the training job but should not gain credential-management operations merely because the job is in a visible folder. No real secret is needed. If you create a credential object later, use a fake value and keep it out of logs and screenshots.

Triggering a preconfigured job and modifying the credential store are different capabilities. Grant them separately.

8. Mini challenge

Create training/release/dry-run. Let auditor read both dev and release, let dev-builder build only in dev, and keep release builds denied to dev-builder. Before changing the matrix, write which scope owns each grant and which inherited grant could defeat the design.

9. Summary

You now have an evidence-driven access model: synthetic identities, a preserved recovery administrator, explicit folder scope, project-matrix grants, and both positive and negative tests. The proof is behavior, not a screenshot of checkboxes.

Next lesson

Choose the identity and authorization architecture

Compare internal versus external identity, matrix versus role-oriented strategies, global versus folder-scoped rights, and human versus automation identities.

Knowledge check

Why test a second administrator session before saving?

Why use separate browser profiles?

A user can read but not build. What permission is likely missing?

What proves auditor cannot build?

Official references and version notes

Version and compatibility note

Rechecked against Jenkins primary documentation on 2026-09-15. The disposable examples assume Jenkins 2.568.3 LTS on Java 21, matrix-auth:3.3, cloudbees-folder:6.1106.v3a_d9a_6d2465e, and credentials:1511.v2e3cb_0008ef0. These plugin releases declare minimum Jenkins baselines below 2.568.3. Future readers must re-check plugin health, advisories, dependencies, and minimum core requirements before installation or upgrade.

Keep the academy open

Support free, practical DevOps education.

Every lesson is designed to remain readable in a browser, downloadable from GitHub, and usable without a paid learning platform. Contributions help expand and maintain the curriculum.

Ethereum / ERC-20
0x716c4Ab160C4B66F31a28AE2448BfF68fc3a2ef0Send only Ethereum/ERC-20 compatible assets to this address.