Skip to content

Add a Restart specific permission for RestartStack - #1650

Open
AzScep wants to merge 1 commit into
moghtech:mainfrom
AzScep:azscep/restart-permission-upstream
Open

AzScep wants to merge 1 commit into
moghtech:mainfrom
AzScep:azscep/restart-permission-upstream

Conversation

@AzScep

@AzScep AzScep commented Sep 26, 2026

Copy link
Copy Markdown

Problem

RestartStack, StartStack, StopStack, DeployStack and DestroyStack all require the Execute level.
There is no way to let a user (or a service user driving an automation) restart a stack without also letting it stop, destroy, or redeploy that stack.
A leaked restart-only credential should not be able to take an app down.

Change

  • Add SpecificPermission::Restart.
    A user with Read and Restart on a Stack can run RestartStack, including for single services.
    Every other stack execution still requires Execute, and UpdateStack still requires Write.
    Like the other specific permissions, Restart given on a Server is inherited by that server's Stacks.
  • Add get_check_any_permissions (and setup_stack_execution_any), which pass when the user fulfils any one of several permission sets.
    get_check_permissions now delegates to it with a single set, and its error message is unchanged.
  • ExecuteCompose gains allowed_permissions(), defaulting to Execute; RestartStack returns [Execute, Read + Restart].
  • Offer Restart for Stacks in the UI's specific permission selector, regenerate the TS types, and document it in permissioning.md.

Users without Restart see no behaviour change.
The UI still shows stack executions only with Execute, so a restart-only user restarts through the API; happy to follow up with a UI change if you want one.

Verification

  • 4 unit tests in permission::tests in Core and 2 in the client's entities::permission (serde round trip and unchanged variant names).
    Removing Read + Restart from RestartStack::allowed_permissions makes 2 of the Core tests fail.
  • cargo fmt --check and clippy clean for the changed files.
  • End to end on a local Mongo + Core + Periphery (outbound) setup with this Core build:
    • a service user with Read + [Logs, Restart] on a stack restarts it and reads its logs;
    • the same user is refused DeployStack, StopStack, DestroyStack, StartStack, PauseStack, PullStack (the Update completes unsuccessfully with the permission error) and UpdateStack;
    • a user with Read + [Logs] is still refused RestartStack, a user with Execute still restarts, and Restart without Read is refused.
      On upstream 2.3.3 the same script fails at granting Restart (unknown variant).

馃 Generated with Claude Code

RestartStack, StopStack, DeployStack and DestroyStack all required the
Execute level, so a user who should only restart a stack could also stop,
destroy, or redeploy it.

- Add `SpecificPermission::Restart`. A user with Read and Restart on a
  Stack can run RestartStack; every other execution still requires
  Execute, and UpdateStack still requires Write. Like other specific
  permissions, Restart on a Server is inherited by its Stacks.
- Add `get_check_any_permissions` (and `setup_stack_execution_any`), which
  pass when the user fulfils any one of several permission sets.
  `get_check_permissions` delegates to it and keeps its error message.
- Compose executions declare their allowed permissions through
  `ExecuteCompose::allowed_permissions`, defaulting to Execute.
- Offer Restart for Stacks in the UI permission selector and document it.

Users without Restart see no change.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant