RBAC & Ownership

This page describes Role-Based Access Control (RBAC) for environments.

Role Who

Creator

The Jenkins user who ran Create-Environment. This value never changes.

Co-owner

A user in the owners list. Manage owners changes this list. A co-owner has the same rights as the creator.

Administrator

A user in the QA_ADMIN_USERS Jenkins variable. This list is separate from the Jenkins administrators (JENKINS_ADMINS).

Permissions

Role create update deploy start / stop / restart delete manage-owners cleanup

Creator (meta.created_by, immutable)

n/a

✓

✓

✓

✓

✓

own env only

Co-owner (meta.owners[])

n/a

✓

✓

✓

✓

✓

own env only

Admin (listed in QA_ADMIN_USERS)

✓ (bypasses MAX_ENVS_PER_USER)

✓

✓

✓

✓

✓

all envs

Anyone else

✓ (subject to MAX_ENVS_PER_USER)

✗

✗

✗

✗

✗

no effect on other users' envs

RBAC is enabled by default (QA_RBAC_ENABLED=true). Set QA_RBAC_ENABLED=false in Manage Jenkins → System → Global properties to fall back to the legacy "everyone can touch anything" mode.

For Developers: Where It Is Enforced

  • utils.checkOwnership is called by updateEnvStep, manageEnvStep and deployEnvStep. The form dropdowns have no ownership check.

  • createEnvStep — quota check (QAConfig.Limits.MAX_ENVS_PER_USER) happens before any filesystem work. Admins bypass it.

  • cleanupEnvsStep — filters the env list by ownership before the TTL check, so a non-admin can never delete someone else’s env. Cron-triggered runs have no currentUser and bypass the check so unattended cleanup still works.

  • listEnvsStep has no ownership filter. All users see all environments.

Disabling RBAC (QA_RBAC_ENABLED=false) short-circuits checkOwnership to true and canModify to true.

manage-owners — the ownership editor

Triggered via QA-Environments/Manage-Environment with ACTION=manage-owners.

Parameters (shown only when ACTION=manage-owners)
  • OWNERS_LIST — CascadeChoiceParameter + PT_CHECKBOX of Jenkins logins. Currently saved co-owners appear pre-checked. The creator is not in the list.

  • OWNERS_PREVIEW — live HTML diff of pending change (added vs removed). Display-only.

Effect on meta.json
{
  "created_by": "alice",         // unchanged
  "owners":     ["bob", "carol"] // rewritten from OWNERS_LIST submission
  // all other fields untouched — no lifecycle transition
}

Why manage-owners is special:

  • It is the only ACTION that does not go through the duplicate-audit code path the lifecycle actions share. The audit is skipped because the action does not touch containers or volumes and the ownership diff has its own audit line.

  • manage-owners is offered for envs in any state. You can reassign ownership on a stopped or failed env without first starting it.

Validation rules

utils.validateOwners(newOwners, meta, currentUser, adminUsers, knownJenkinsLogins):

  • Rejects an empty list (there must be at least one co-owner or the creator; the creator is always implicit).

  • Requires the submitting user to appear in the result unless they are an admin — non-admins cannot remove themselves without granting access to someone else first.

  • Enforces MAX_OWNERS_PER_ENV (default 5, override via QA_MAX_OWNERS_PER_ENV).

  • Drops unknown logins — a login is "known" if it already appears in the Jenkins user database. Users without a Full Name still count.

Result is a List that manageEnvStep writes verbatim back into meta.owners[] via utils.atomicWriteMeta.

Limits

Limit Default Override

MAX_ENVS_PER_USER

5

QA_MAX_ENVS_PER_USER — admins bypass this.

MAX_OWNERS_PER_ENV

5

QA_MAX_OWNERS_PER_ENV.

Transfer of ownership

There is no user-facing "transfer" action. created_by is immutable. To move an env to a new owner:

  1. Admin (or current creator) adds the target user to owners[] via manage-owners.

  2. Target user now has every mutating right the creator has.

  3. The audit trail (meta.created_by + the manage-owners audit line) records who did what.

If the business really requires a new created_by, an admin has to edit meta.json directly on the master under /var/jenkins_home/qa-data/envs/<env>/meta.json.

Audit trail

  • MASTER_AUDIT_LOG (${MASTER_ENVS_DIR}/.audit-log.ndjson) — one line per privileged action.

  • MASTER_OPERATION_LOG (${MASTER_ENVS_DIR}/.operation-log.ndjson) — one line per step invocation.

Both are append-only NDJSON files written by utils.logOperation. Rotate them externally — the library does not rotate them.

RBAC off

If you set QA_RBAC_ENABLED=false, the library falls back to the legacy "any logged-in Jenkins user can act on any env" behaviour. Quotas and MAX_OWNERS_PER_ENV still apply.