Users, Groups, Permissions, Tokens, Authentication, and Authorization: Core Concepts and Mental Model
Build an identity-to-action mental model for SonarQube users, groups, global/project permissions, permission templates, project visibility, and scoped token use.
Learning objectives
- Separate identity, authentication, group membership, authorization, project visibility, and token state.
- Distinguish global permissions from project permissions and explain why permissions are additive across direct grants and group membership.
- Explain how permission templates seed project permissions and why a template is a governance object rather than a runtime scanner setting.
- Choose between user, project-analysis, and global-analysis tokens without treating every token as an administrator credential.
- Explain why a valid credential can still be denied and why a revoked/invalid credential is a different failure class.
-
Preserve revision, scanner,
ceTaskId, permission, token, and revocation evidence as separate facts.
1. The practical problem: identity is not authorization
Earlier chapters used project-analysis tokens, user tokens for IDE/API scenarios, provider identities, and CI secrets. Chapter 21 turns those examples into a governed identity model. The central mistake to avoid is assuming that “this user can log in” means “this user should be able to administer, browse, analyze, or change every project.”
SonarQube authorization is layered. A person or automation first has an identity. Authentication proves that identity. Group membership and direct grants then determine global and project permissions. Finally, the requested UI, API, or scanner operation checks those permissions. A token does not create new authority; it acts within the authority attached to its owner/type and may be further bounded by token type.
identity → authentication → group memberships + direct grants →
global/project permission → project visibility → allowed
UI/API/scanner action
2. Mental model: who are you, what can you do, and where?
flowchart TD
I[Identity] --> A[Authentication]
A --> G[Group memberships]
A --> D[Direct user grants]
G --> P[Effective permissions]
D --> P
P --> V{Global or project scope?}
V -->|Global| X[Instance-wide action]
V -->|Project| Y[Project action]
T[Token type / owner] --> A
Y --> Z[UI / Web API / scanner result]
X --> Z
The arrows matter. Authentication happens before authorization. Group membership and direct grants are additive: a deny is normally represented by the absence of a grant, not by a separate “negative permission” that cancels another group. Therefore, a user who belongs to one overly broad group can retain more authority than an administrator expects even after a narrower direct grant is removed.
3. State map to capture before making changes
Identity state
User login, active/deactivated state, authentication source, built-in/delegated provisioning ownership, and group memberships.
Authorization state
Global permissions, project permissions, template source, direct grants, inherited group grants, and visibility.
Credential state
Token owner, type, creation/expiration, consumer, secret-storage location, last expected use, and revocation status.
Analysis state
Project key, Git SHA, scanner version/runtime, effective
parameters, report upload, ceTaskId, CE status, and
gate result.
Governance state
Who approved a permission/template exception, why it exists, when it expires, and how rollback/revocation will be proven.
4. Users and groups: permissions accumulate
Current Community Build uses groups to make permission management scalable. A user can belong to several groups, and the user’s effective permissions are the union of permissions granted directly plus permissions granted through every group. Two built-in groups deserve special attention:
-
sonar-userscontains authenticated users. Current documentation notes that global Execute Analysis is granted to this group by default on a fresh installation; review this default against your organization’s policy. -
sonar-administratorscontains the default administrator and should remain tightly controlled.
sonar-users still has global Execute Analysis, adding a
narrow project-level Execute Analysis grant does not prove
isolation. The broader inherited global grant still wins because
permissions are additive.
5. Global permissions: instance-wide authority
Global permissions are not tied to one project. Current Community Build documentation includes:
| Global permission | What it controls | Routine scanner needs it? |
|---|---|---|
| Administer System | Full instance administration | No |
| Administer Quality Gates | Create/update shared gates | No |
| Administer Quality Profiles | Create/update profiles and rule tags | No |
| Execute Analysis | Analyze every project and obtain analysis settings required for scanning | Usually too broad |
| Create Projects | Create projects | No, if projects are provisioned separately |
Use project-level Execute Analysis and project-analysis tokens where a job only needs to analyze one project. A global permission is not a convenience flag; it changes the blast radius of a compromised identity.
6. Project permissions and visibility
Project permissions apply to a specific project. Current Community Build documentation includes Browse Project, See Source Code, Administer Issues, Administer Security Hotspots, Administer project, and Execute Analysis on project. Chapter 15 already covered the 2026 Security Hotspot migration; the permission label may remain visible while finding semantics evolve, so record the actual release/UI rather than freezing automation to one object name.
| Project permission | Typical consumer | Risk if overgranted |
|---|---|---|
| Browse Project | Developers/reviewers on a private project | Disclosure of measures/issues |
| See Source Code | Authorized reviewers | Source disclosure; requires Browse on private projects |
| Administer Issues | Governed triage role | Can accept/false-positive findings |
| Administer project | Project owner/admin | Can alter settings/permissions and delete project |
| Execute Analysis on project | Project CI/scanner identity | Can push analyses for that project |
New projects are public by default in current documentation. For a least-privilege enterprise-style model, private visibility makes authorization visible and testable: Browse and See Source Code must then be granted intentionally.
7. Permission templates: policy at project creation
A permission template defines default project-related grants for users/groups. A template can be the default or match project keys using a regular expression. When multiple templates match the same new project key, SonarQube reports an error rather than choosing ambiguously.
Template: SQ Chapter 21 Alpha
Project key pattern: ^sq-ch21-alpha-.*
Group: sq-ch21-alpha-devs
Browse Project: yes
See Source Code: yes
Execute Analysis on project: yes
Administer project: sq-ch21-alpha-admins only
A template is SonarQube authorization policy. It is not a scanner property, not Git metadata, and not a Quality Gate. Changing it does not retroactively prove that a previous analysis ran under the new permission set.
8. Token types: narrow by purpose
| Token type | Authority | Preferred use |
|---|---|---|
| User token | All Web API/UI-equivalent permissions of the issuing user | Human/API automation that truly needs those user permissions; Connected Mode requires this type |
| Project analysis token | Analysis for one associated project; tied to owner’s Execute Analysis permission | Preferred scanner/CI credential for one project |
| Global analysis token | Analysis across every project | Rare centralized scanner service with justified global scope |
Current documentation encourages project-analysis tokens because leakage is bounded to one project. Token values are shown only at creation. Users can choose an expiration; Enterprise edition and above can enforce a maximum lifetime for newly generated tokens. In Community Build, explicitly choosing an expiration and maintaining a consumer inventory is a governance control even when the server cannot enforce an organization-wide maximum.
9. Web API authentication and expiration evidence
Current Web API guidance recommends bearer authentication with a
user token for API operations. API responses
authenticated by a token can include
SonarQube-Authentication-Token-Expiration, which
automation can monitor to rotate credentials before expiry.
# Read-only example. SQ_USER_TOKEN is a limited user's token, not an admin token.
curl -fsS -D evidence/api-headers.txt \
-H "Authorization: Bearer $SQ_USER_TOKEN" \
"$SONAR_HOST_URL/api/measures/component?component=sq-ch21-alpha-app&metricKeys=ncloc" \
-o evidence/measures.json
grep -i '^SonarQube-Authentication-Token-Expiration:' evidence/api-headers.txt || true
Web API V2 is gradually replacing older endpoints. Always use the in-instance API documentation for write operations and avoid hard-coding deprecated administrative endpoints into long-lived automation.
10. Authentication failure is not authorization failure
| Observation | Layer | Interpretation |
|---|---|---|
| Missing/invalid/revoked token; request is not authenticated | Authentication | Conceptually a 401-class failure (some endpoints may expose validation differently) |
| Identity is authenticated but lacks required permission | Authorization | Conceptually a 403-class failure; privacy-preserving endpoints may instead hide resource existence |
| Scanner can authenticate but lacks Execute Analysis on target project | Project authorization | Scanner must fail; changing the project key is not a repair |
Preserve the actual HTTP status/body or scanner error from the current release. The diagnostic principle is the important part: first prove whether the identity was accepted, then prove whether that accepted identity was authorized for the requested operation.
Knowledge check
Why can removing a direct permission fail to reduce a user’s authority?
The same permission may still be inherited from one of the user’s groups. Effective permissions are additive.
Which token is normally best for one project’s CI scanner?
A project-analysis token, because its analysis scope is bounded to the associated project.
Why can a fresh sonar-users default undermine a
project-level isolation test?
Current defaults grant global Execute Analysis to sonar-users. That inherited global grant allows analysis everywhere until it is deliberately reviewed/removed.
Does a user token have a separate API scope independent of its owner?
No. A user token inherits the user’s permissions, which is why a limited service user is safer than an administrator’s user token.
What is the first question when an API call fails?
Was the identity authenticated at all? Only after that should you diagnose authorization and resource-level permissions.
Official references and version notes
-
Managing permissions — Community Build
— current global/project permissions, default
sonar-usersExecute Analysis grant, visibility, and permission templates. - Managing groups — additive direct/group permission model and built-in groups.
- Managing your tokens — user/project/global analysis token types, expiration, revocation, and owner-permission dependency.
- Administering tokens — administrator generation/revocation responsibilities.
- User accounts — built-in/delegated authentication and forced-authentication guidance.
- Web API — bearer authentication, token-expiration response header, form-data guidance, and Web API V2 transition.
- Current SonarQube downloads — Community Build 26.9.0.129388 baseline.
- SonarScanner CLI 8.1.0.6389 — scanner baseline used by the local analysis proofs.
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.
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.
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.
0x716c4Ab160C4B66F31a28AE2448BfF68fc3a2ef0Send only Ethereum/ERC-20 compatible assets to this
address.