Chapter 21Lesson 05~180 minutes

Checkpoint Lab — Users, Groups, Permissions, Tokens, Authentication, and Authorization

Produce a two-team least-privilege RBAC matrix, prove permitted and denied actions with scoped identities, revoke credentials, and package independent audit evidence.

IdentityRBACPermissionsTokensAuthorization

Learning objectives — Checkpoint objectives

  • Build and document a two-team least-privilege RBAC matrix on disposable Community Build.
  • Predict the effective authorization results before executing them.
  • Prove positive and negative scanner/API outcomes with bounded identities.
  • Demonstrate the impact of the default global Execute Analysis grant and repair it safely in the lab.
  • Revoke credentials, verify access failure, and restore the original global state.
  • Produce an evidence packet that a reviewer can replay without seeing any token values.

1. Checkpoint scenario

You administer a disposable local SonarQube instance used by two synthetic teams, Alpha and Beta. Each team should browse/source-view/analyze only its own private project. Neither routine user is an administrator. CI uses project-analysis tokens; read-only API verification uses limited user tokens.

Your task is to prove the matrix, intentionally expose one broader inherited permission, repair it, prove revocation, and restore the initial server state.

2. Exact assumptions and prerequisites

Assumption Checkpoint value
SonarQube Community Build 26.9.0.129388
Scanner SonarScanner CLI 8.1.0.6389
Authentication Built-in local users for mandatory path; forced authentication remains enabled
Database/plugins/CI/IdP No change required; external identity is intentionally deferred to Chapter 22
Projects sq-ch21-alpha-app, sq-ch21-beta-app, private
Groups sq-ch21-alpha-devs, sq-ch21-beta-devs
Tokens Short-lived project-analysis + limited user tokens; values never enter evidence

3. Write the intended RBAC matrix before configuration

Identity Alpha project Beta project Global admin
sq21-alpha / alpha-devs Browse, Source, Execute Analysis None None
sq21-beta / beta-devs None Browse, Source, Execute Analysis None
Lab administrator Administrative setup only Administrative setup only Administer System

Also record the actual initial global Execute Analysis state for sonar-users. The desired final rollback state is whatever you observed initially—not what you remember the default to be.

4. Predictions before mutation

  • Prediction A: while sonar-users still has global Execute Analysis, both authenticated users may be able to analyze either project despite narrow project templates.
  • Prediction B: after removing that global grant in the disposable lab, Alpha will analyze Alpha but not Beta; Beta will analyze Beta but not Alpha.
  • Prediction C: Alpha’s limited user token will read Alpha’s private measures but will not gain Beta Browse permission.
  • Prediction D: revoking Alpha’s project-analysis token will make the same Alpha scan fail without changing source, project key, gate, profile, or template.
  • Prediction E: restoring the original global grant during cleanup changes authorization state but does not rewrite earlier analysis/task evidence.

5. Setup and preflight evidence

  1. Capture server/scanner versions.
  2. Capture Global Permissions, Users, Groups, Permission Templates, and default visibility.
  3. Create the two local users/groups and record memberships.
  4. Create Alpha/Beta permission templates with key regexes and project grants.
  5. Create the two private projects and verify template assignment.
  6. Create source fixtures and record Git SHAs.
  7. Create short-lived project-analysis and user tokens under the limited users.
mkdir -p evidence/ch21/{preflight,alpha,beta,deny,revocation,rollback}
curl -fsS "$SONAR_HOST_URL/api/system/status" > evidence/ch21/preflight/system-status.json
sonar-scanner --version 2>&1 | tee evidence/ch21/preflight/scanner-version.txt
printf 'alpha_sha=%s\n' "$(git -C sq-ch21-rbac/alpha rev-parse HEAD)" > evidence/ch21/preflight/revisions.txt
printf 'beta_sha=%s\n' "$(git -C sq-ch21-rbac/beta rev-parse HEAD)" >> evidence/ch21/preflight/revisions.txt

6. Execute the allow/deny proof

Run these evidence cases without changing the source revisions:

Case Expected after global grant is removed Evidence
Alpha token → Alpha scan Allowed scanner log, report-task, ceTaskId, CE terminal status
Alpha token → Beta scan Denied first scanner error + nonzero exit
Beta token → Beta scan Allowed scanner log, report-task, ceTaskId, CE terminal status
Beta token → Alpha scan Denied first scanner error + nonzero exit
Alpha user token → Alpha private measures Allowed HTTP status/body + expiration header if returned
Alpha user token → Beta private measures Denied/hidden according to endpoint semantics Actual status/body, plus admin-side proof Beta exists

7. Deliberate mistake: prove the default global grant can defeat isolation

If the initial state had global Execute Analysis on sonar-users, preserve one cross-team scan result before removing it. That is the deliberate broken state. Record:

  • Alpha’s membership in sonar-users;
  • the global Execute Analysis grant;
  • absence of Alpha’s Beta project-level grant;
  • the surprising successful cross-team scan.

Then remove only that global grant, rerun the same revision/project/token pair, and preserve the denial. This is a causal authorization experiment.

8. Revoke and independently verify

Revoke Alpha’s project-analysis token. Repeat Alpha→Alpha scan and require nonzero exit. Revoke Alpha’s user token. Repeat the read-only Alpha API request and preserve the authentication failure/validation result.

revocation record:
  owner: sq21-alpha
  token type: project analysis / user
  associated project (if applicable): sq-ch21-alpha-app
  expiration originally selected:
  revoke timestamp:
  known consumers updated/removed:
  post-revoke verification command:
  post-revoke result:
  token value: NEVER RECORDED

9. Required evidence packet

Minimum contents
  • assumptions.md: release, scanner, auth source, edition limits, no external IdP/CI requirement.
  • Before/after global-permission records.
  • User/group membership matrix and permission-template definitions.
  • Private project visibility and project-permission records.
  • Token metadata: owner/type/expiration/consumer/revocation—never token values.
  • Alpha/Beta Git SHAs and effective scanner project keys.
  • Allowed scanner logs + report-task.txt + ceTaskId + CE results.
  • Denied cross-team scanner/API evidence.
  • Revoked-token failure evidence.
  • Rollback proof showing original global permission state restored.
  • Limitations note: Community Build lab uses built-in identities; externally synchronized identity is covered next chapter.

10. Verification checklist

  • ☐ Neither sample user is in sonar-administrators.
  • ☐ Alpha and Beta permissions originate from intended groups/templates, not undocumented direct grants.
  • ☐ Private visibility is independently verified.
  • ☐ Global Execute Analysis initial and modified states are preserved.
  • ☐ Positive and negative analysis tests were executed at exact recorded SHAs.
  • ☐ ceTaskId is preserved for successful analyses.
  • ☐ API evidence distinguishes authentication from authorization/resource visibility.
  • ☐ Token values never appear in source, logs, screenshots, or evidence notes.
  • ☐ Revoked credentials are proven unusable.
  • ☐ Cleanup restores the original global permission.

11. Cleanup and rollback

  1. Export the evidence packet.
  2. Revoke remaining Chapter 21 credentials.
  3. Restore the original sonar-users Execute Analysis state exactly.
  4. Remove only the Chapter 21 disposable projects/templates/groups/users.
  5. Unset environment variables and remove the local synthetic source tree if no longer needed.
  6. Do not touch database/search state, global quality policy, external IdP configuration, or unrelated projects.

12. What Chapter 21 adds to the production operating model

The SonarQube control plane now includes a replayable identity chain: who authenticated, which groups/direct grants produced the effective permission, which project/global boundary applied, which token represented that identity, which analysis task resulted, and when access was revoked. Routine analysis no longer depends on administrator credentials.

Chapter 22 continues with SAML, LDAP, OIDC/SSO, Proxies, TLS, and Network Security, moving identity ownership from local accounts/groups toward enterprise authentication and network trust boundaries.

Knowledge check

What makes the cross-team denial causal rather than anecdotal?

Why should token values be absent from the evidence packet?

If Beta’s project-analysis token remains unexpired but its owner loses Execute Analysis, what should happen?

Why restore the original global permission even if the narrower configuration seems better?

What layer owns a synchronized enterprise group next chapter?

Does scanner success prove the user can administer the project?

Next lesson — Next chapter

SAML, LDAP, OIDC/SSO, Proxies, TLS, and Network Security

Chapter 22 moves from local RBAC into external identity, SSO, proxy, TLS, and network trust boundaries.

Official references and version notes

Version and edition note

Rechecked 2026-09-08. Mandatory exercises target Community Build 26.9.0.129388 and SonarScanner CLI 8.1.0.6389. Current Community Build documentation says permissions are additive across direct grants and group membership; sonar-users receives global Execute Analysis by default on a fresh installation, so the disposable RBAC lab temporarily removes that grant only after preserving it and restores it during cleanup. Project-analysis tokens are encouraged for one-project scanning. User tokens inherit all permissions of their owner and are the recommended bearer credential for Web API operations; project/global analysis token validity depends on the owner retaining the corresponding Execute Analysis permission. Token expiration can be selected by users; enforcing an instance-wide maximum token lifetime for newly generated tokens is Enterprise edition and above. New projects are public by default in current documentation; the lab uses private projects to make Browse/See Source Code boundaries observable. If an external authentication/provisioning method synchronizes users/groups/permissions, manual changes may be unavailable and the external source of truth owns the change. Web API V2 is gradually replacing older endpoints, so write automation must be checked against the current in-instance API documentation.

Version and compatibility note

SonarQube product names, editions, release trains, scanner runtimes, APIs, authentication options, and platform prerequisites can change independently. Re-check the linked SonarSource primary documentation for the exact target release before applying version-sensitive commands or operational guidance outside the disposable course environment.

Identity evidence boundary. Preserve token metadata, owner/type/expiration, permission matrices, Git revision, scanner logs, report-task.txt/ceTaskId, CE result, gate result, and revocation test separately. Never place token values in the evidence packet.

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.