api: fine-grained permission control for service account creation#837
Open
alvarofraguas wants to merge 1 commit into
Open
api: fine-grained permission control for service account creation#837alvarofraguas wants to merge 1 commit into
alvarofraguas wants to merge 1 commit into
Conversation
Add optional user_access, query_access, carve_access, and admin_access fields to ApiUserRequest. When provided, these override the legacy behavior where all permission levels were derived from the admin flag. Pointer types (*bool) distinguish "not provided" (nil → legacy fallback) from "explicitly false", preserving backward compatibility for existing API clients and the CLI. Closes jmpsec#774
5 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
user_access,query_access,carve_access, andadmin_accessfields to the user creation API endpointadminflagBackward compatibility
Fields use pointer types (
*bool) sonil(not provided) is distinguishable fromfalse(explicitly denied). When none of the new fields are provided, the handler falls back to the existing behavior:user_access=true, everything else =adminvalue.Existing API clients and the CLI continue working unchanged.
API usage
POST /api/v1/users/my-monitoring-bot/add { "username": "my-monitoring-bot", "password": "secure_password", "email": "monitoring@example.com", "service": true, "admin": false, "environments": ["env-uuid"], "user_access": true, "query_access": true, "carve_access": false, "admin_access": false }Security
The endpoint is already gated behind global admin permission (
AdminLevelcheck). Only admins can create users or assign permissions. This change adds granularity to what admins can already do — it does not expand the attack surface.Closes #774
Test plan
go build ./...cleango test ./cmd/api/... ./pkg/users/...passesadmin=false+query_access=truecreates user with read + query only