Chapter 21Lesson 04~130 minutes

Users, Groups, Permissions, Tokens, Authentication, and Authorization: Diagnostics, Failure Modes, and Production Practices

Diagnose authentication and authorization failures without using administrator tokens, deleting evidence, weakening permissions, or rotating credentials without consumer inventory.

IdentityRBACPermissionsTokensAuthorization

Learning objectives

  • Diagnose authentication, authorization, token, group, and permission-template failures from preserved evidence.
  • Separate 401-class credential failure from 403-class authorization failure while respecting privacy-hiding responses.
  • Detect administrator-token misuse, committed credentials, direct-grant sprawl, and orphaned tokens.
  • Rotate credentials without breaking unknown consumers or leaving the old token active.
  • Repair a deliberately broken cross-team permission case without changing project keys or broadening to admin.

1. Evidence-first diagnostic sequence

  1. Preserve the first scanner/API/CI response and exact timestamp.
  2. Record SonarQube Community Build/Server version, edition, instance mode, scanner/runtime, and relevant integration version.
  3. Confirm the exact identity/token owner and token type without logging the token value.
  4. Confirm source revision, project key, effective scanner parameters, and report-task.txt/ceTaskId if upload occurred.
  5. Inspect group memberships, direct grants, global permissions, project permissions, template/visibility, and authentication source.
  6. Distinguish authentication failure from authorization failure.
  7. Inspect dependent CI/IDE/API consumers before any rotation/revocation.
  8. Apply the least-destructive correction and repeat the smallest equivalent request at the same revision.

2. Failure: using an administrator token for routine scanners

An admin user token can perform any API/UI action the administrator can perform. Using it as a scanner secret turns a routine build compromise into potential instance administration compromise. Replace it with a project-analysis token owned by an identity that has only project Execute Analysis.

Do not “validate” the repair by merely seeing the scan pass. Prove the narrow credential fails to perform an unrelated administrative action.

3. Failure: committing tokens

If a SonarQube token appears in Git history, treat it as compromised: preserve the incident evidence, revoke it, inventory affected consumers, issue the narrow replacement, and remove/redact the secret from active configuration according to your repository incident process. Do not assume deleting the current file removes the secret from history.

Never use a real token to teach this failure. Labs use synthetic placeholders only.

4. Failure: confusing authentication with authorization

Symptom Likely question Evidence
Invalid/revoked credential Was the identity authenticated? Authentication validation/API response, token revocation record
Authenticated but denied operation Does this identity have the required permission? Group/direct/global/project grant matrix
Private project appears absent Is resource existence intentionally hidden? Admin-side project existence + user-side Browse grants
Scanner rejected target Does token owner retain Execute Analysis on this project? Token owner + project/global permission + scanner error

Do not “solve” an authorization failure by switching to an administrator token. That masks the layer being diagnosed.

5. Failure: direct-user permission sprawl

A project accumulates direct grants over months. Team membership changes, but old grants remain. The correction is not a mass delete without evidence. Export the current matrix, map each direct grant to an owner/business reason, migrate normal access to groups/templates, preserve approved exceptions, then remove only grants that have been explicitly superseded.

6. Failure: orphaned long-lived tokens

A token with no known consumer or owner is an access path that cannot be governed. Current Community Build allows token expiration selection; use short/appropriate lifetimes and a consumer registry. Monitor the token-expiration HTTP response header for API automation where available.

When a user is deactivated or loses Execute Analysis, analysis tokens tied to that user’s permission can stop working. Preserve the permission-change evidence before rotating tokens blindly.

7. Failure: testing only as admin

Administrator testing proves that the instance works under maximal privilege; it does not prove that team RBAC works. Every access design should include at least one positive test and one negative test using the actual bounded identities.

positive: alpha can analyze alpha
negative: alpha cannot analyze beta
positive: beta can browse beta
negative: beta cannot administer alpha
revocation: revoked alpha token cannot authenticate/analyze

8. Failure: rotating without dependent-job inventory

A safe rotation sequence is inventory → create narrow replacement → update consumers → verify new credential → revoke old credential → verify old credential fails. If you revoke first, you may break unknown jobs. If you never revoke old, you create a second valid attack path.

9. Intentionally broken example: Alpha can analyze Beta

Symptom: You carefully created Alpha/Beta groups and project templates, yet Alpha’s scanner succeeds against Beta.

First evidence: do not change the project key, template, or token. Capture Alpha’s group membership, Beta project permissions, and global permissions. On a fresh Community Build instance you may discover that sonar-users still holds global Execute Analysis.

Alpha authenticated → Alpha ∈ sonar-users → sonar-users has global Execute Analysis → Beta scan allowed

Least-destructive repair in the disposable lab: preserve the original global grant, remove only global Execute Analysis from sonar-users, repeat the same Alpha→Beta scan at the same Git revision/project key, and confirm denial. Then confirm Alpha→Alpha still succeeds from the project template.

This failure is valuable because the local project permissions were not wrong—the broader global permission was the causal layer.

10. Production anti-patterns to reject

  • Do not distribute administrator tokens to scanners, IDEs, or scripts.
  • Do not print token values in logs or screenshots.
  • Do not disable authentication on production merely to fix access.
  • Do not change private projects to public as a troubleshooting shortcut.
  • Do not directly edit the SonarQube database/search index to repair authorization.
  • Do not delete/recreate a project under another key to escape a permission problem.
  • Do not remove logs before preserving first failure.
  • Do not mass-remove permissions without mapping effective group/direct grants first.

Knowledge check

Alpha can analyze Beta despite no Beta project grant. What hidden grant should you inspect first on a fresh instance?

A revoked token fails. Should you create a new project key?

Why can a private project appear missing to a valid user?

What is wrong with testing RBAC only as admin?

When is rotation complete?

Next lesson

Prove the full RBAC and revocation checkpoint

Lesson 5 packages the complete two-team matrix, task evidence, denial evidence, revocation proof, and rollback.

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.