Skip to content

feat(rbac): dev-admin cannot create/delete pipelines & workflows - #7043

Merged
Shivam-nagar23 merged 21 commits into
developfrom
feat/dev-admin-pipeline-lifecycle
Oct 15, 2026
Merged

Shivam-nagar23 merged 21 commits into
developfrom
feat/dev-admin-pipeline-lifecycle

Conversation

@Shivam-nagar23

@Shivam-nagar23 Shivam-nagar23 commented Sep 21, 2026 •

Copy link
Copy Markdown
Member

Description

Fixes https://github.com/devtron-labs/sprint-tasks/issues/2976

Checklist:

  • The title of the PR states what changed and the related issues number (used for the release note).
  • Does this PR requires documentation updates?
  • I've updated documentation as required by this PR.
  • I have performed a self-review of my own code.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have tested it for all user roles.
  • I have added all the required unit/api test cases.

Does this PR introduce a user-facing change?


Summary

OSS mirror of the enterprise dev-admin pipeline-lifecycle restriction. Introduces two Casbin actions createPipeline/deletePipeline and re-points only the CI/CD pipeline + workflow lifecycle handlers to them, so a dev-admin custom role can no longer create or delete pipelines/workflows — while it still edits config and triggers CI/CD.

  • admin/manager/super-admin unaffected: they hold applications:*, and MatchKeyByPart treats * as matching any action — no migration/backfill.
  • Config/trigger handlers untouched; lifecycle gates only.
  • Jobs enforced on the jobs resource only.
  • Migration 36904600 whitelists the new actions for custom-role composition.
  • Covers CD_CREATE-via-PatchCdPipeline and the bulk CD-delete endpoint. PatchCiPipelines uses an OSS-appropriate action branch (OSS lacks the enterprise linked-CD/switch-CI refactor).

Test Plan

  • dev-admin token → 403: create/delete CI pipeline, create/delete CD pipeline (incl. partial & bulk delete), create/delete workflow
  • dev-admin token → 200: edit deployment template / ConfigMap / Secret / env overrides, update CI branch/source, non-delete CD patch, trigger CI & CD
  • Regression → 200: admin/manager/super-admin create/delete CI, CD, workflow; jobs manager create/delete jobs
  • Touched packages build clean

🤖 Generated with Claude Code

@bito-code-review

Copy link
Copy Markdown

Bito Automatic Review Skipped - Branch Excluded

Bito didn't auto-review because the source or target branch is excluded from automatic reviews. To trigger review, type /review in the comment and save. You can change the settings here, or contact the agent instance creator at [email protected].

@github-actions

Copy link
Copy Markdown

Some linked issues are invalid. Please update the issue links:\nIssue # in is not found or invalid (HTTP }404).\n

Shivam-nagar23 and others added 11 commits September 23, 2026 13:07
Avoids collision with develop's 36704600_variable_entity_mapping_index; aligns with enterprise 36904600.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
develop added 36904600_add_ci_workflow_active_status_index (packet 46); move ours to
the next free slot in the current packet (48).

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@Shivam-nagar23
Shivam-nagar23 force-pushed the feat/dev-admin-pipeline-lifecycle branch from 2f0e7d9 to 7ec202a Compare September 23, 2026 07:39
@github-actions

Copy link
Copy Markdown

Some linked issues are invalid. Please update the issue links:\nIssue # in is not found or invalid (HTTP }404).\n

Copilot AI balanced review requested due to automatic review settings October 5, 2026 06:57
@github-actions

github-actions Bot commented Oct 5, 2026

Copy link
Copy Markdown

Some linked issues are invalid. Please update the issue links:\nIssue # in is not found or invalid (HTTP }404).\n

…nt delete via switch field

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@github-actions

github-actions Bot commented Oct 5, 2026

Copy link
Copy Markdown

Some linked issues are invalid. Please update the issue links:\nIssue # in is not found or invalid (HTTP }404).\n

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Authorization gaps and permission regressions remain unresolved.

Review effort: Balanced
Findings: 3 High severity · 2 Medium severity

Open (5)
What changed in this PR

Separates pipeline and workflow lifecycle permissions from configuration permissions to restrict dev-admin access.

Changes:

  • Adds dedicated lifecycle actions and a reversible whitelist migration.
  • Updates CI/CD, workflow, batch, and bulk authorization gates.
  • Separates application and job authorization in workflow handlers.
File Description
scripts/​sql/​37004800_dev_admin_pipeline_lifecycle.up.sql Whitelists lifecycle actions.
scripts/​sql/​37004800_dev_admin_pipeline_lifecycle.down.sql Removes lifecycle actions on rollback.
pkg/​auth/​authorisation/​casbin/​rbacpolicy.go Defines lifecycle action constants.
api/​restHandler/​CoreAppRestHandler.go Updates workflow creation authorization.
api/​restHandler/​BulkUpdateRestHandler.go Gates bulk CD deletion.
api/​restHandler/​BatchOperationRestHandler.go Updates batch workflow authorization.
api/​restHandler/​app/​workflow/​AppWorkflowRestHandler.go Adds type-specific workflow authorization.
api/​restHandler/​app/​pipeline/​configure/​DeploymentPipelineRestHandler.go Selects CD lifecycle permissions by operation.
api/​restHandler/​app/​pipeline/​configure/​BuildPipelineRestHandler.go Adds CI lifecycle authorization branches.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread api/restHandler/app/pipeline/configure/BuildPipelineRestHandler.go Outdated
Comment thread api/restHandler/app/pipeline/configure/BuildPipelineRestHandler.go Outdated
Comment thread api/restHandler/app/pipeline/configure/BuildPipelineRestHandler.go
Comment thread api/restHandler/CoreAppRestHandler.go Outdated
Comment thread pkg/auth/authorisation/casbin/rbacpolicy.go Outdated
Copilot AI balanced review requested due to automatic review settings October 5, 2026 07:08
@github-actions

github-actions Bot commented Oct 5, 2026

Copy link
Copy Markdown

Some linked issues are invalid. Please update the issue links:\nIssue # in is not found or invalid (HTTP }404).\n

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment thread api/restHandler/CoreAppRestHandler.go Outdated
Comment thread api/restHandler/app/pipeline/configure/BuildPipelineRestHandler.go
… a workflow is created (keep config-only on create)

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Copilot AI balanced review requested due to automatic review settings October 6, 2026 10:41

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Job authorization gaps and action-casing mismatches remain unresolved.

Review effort: Balanced
Findings: 8 High severity · 1 Medium severity

Open (9)
Resolved since last review (1)
Previously missed (1)

In code that hasn't changed since last review

Medium severity Normalized actions do not match mixed-case requests

pkg/​auth/​authorisation/​casbin/​rbacpolicy.go:71

Explicit custom-role grants cannot match these action values. AddPolicy lowercases stored actions (Adapter.go:166), but enforcement passes request actions unchanged and MatchKeyByPart compares them case-sensitively. A createPipeline grant becomes createpipeline, so the corresponding request is denied; the same applies to deletion. Wildcard policies mask the mismatch. Use lowercase constant values so requests match the normalized policies.

Comment thread api/restHandler/BatchOperationRestHandler.go
Comment thread api/restHandler/CoreAppRestHandler.go
Copilot AI balanced review requested due to automatic review settings October 6, 2026 10:50

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

…sbin store

Casbin normalizes policy actions to lowercase on store (AddPolicy -> strings.ToLower) while enforcement passes the action unchanged. The mixed-case createApp/deleteApp/createPipeline/deletePipeline constants therefore never matched an explicit custom-role grant. Lowercase the constant values and the whitelist labels; the Release-1 createApp/deleteApp labels are normalized inside this PR's 37004800 migration via array_replace so the already-shipped 36504600 migration is left untouched.

admin (*) and dev-admin (omission) are unaffected; this only fixes future explicit custom-role grants of these four actions.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Copilot AI balanced review requested due to automatic review settings October 6, 2026 11:20

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

vivek-devtron
vivek-devtron previously approved these changes Oct 8, 2026
Copilot AI balanced review requested due to automatic review settings October 15, 2026 05:05

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing. Review the Copilot code review billing settings.

…bove develop max

develop added migrations up to 37504600; the runner only applies versions above the current schema version, so a 37004800 migration would be skipped on envs already at 37504600. Bumped to 37704800 (packet 48) to stay above develop's max and keep both repos aligned.

Co-Authored-By: Claude Opus 4.8 <[email protected]>

Claude-Session: https://claude.ai/code/session_01Se9N8bnyDEitxXB69Pt55V
Copilot AI balanced review requested due to automatic review settings October 15, 2026 05:15

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing. Review the Copilot code review billing settings.

@sonarqubecloud

Copy link
Copy Markdown

@Shivam-nagar23
Shivam-nagar23 merged commit c6bc65c into develop Oct 15, 2026
6 checks passed
@Shivam-nagar23
Shivam-nagar23 deleted the feat/dev-admin-pipeline-lifecycle branch October 15, 2026 05:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants