Skip to content

cli: manage users, policies, and service accounts - #49

Merged
jkandasa merged 4 commits into
mycontroller-org:mainfrom
jkandasa:cli_users_policies
Sep 14, 2026
Merged

cli: manage users, policies, and service accounts#49
jkandasa merged 4 commits into
mycontroller-org:mainfrom
jkandasa:cli_users_policies

Conversation

@jkandasa

Copy link
Copy Markdown
Member

Summary

Adds CLI management for users, policies, and service accounts, and renames the service token resource to service account.

  • myc apply / get / delete for users and policies
  • myc enable / disable user (cannot disable or delete the logged-in user)
  • myc add service-account (alias create) plus apply/get/delete
  • Create prints the secret token once; it cannot be retrieved later
  • Storage entity service_account, HTTP API /api/serviceaccount, policy kind serviceaccount
  • Admins can create accounts for any user; statements can only narrow the owner’s access
  • Upgrade 2.2.0-2 migrates service_token rows and policy resource kinds

Pairs with the web-console PR that updates the UI to Service Accounts.

Test plan

  • go test ./cmd/client/... ./pkg/api/policy/ ./pkg/utils/filter_sort/
  • myc add sa <alias> ci-bot prints a token once; myc get sa lists it
  • myc apply add/merge/delete user, policy, and service-account
  • myc disable user <alias> <self> and myc delete user <alias> <self> fail
  • Admin can create a service account for another user; a non-admin cannot
  • Existing service_token data migrates on upgrade

Add myc apply/get/delete/enable/disable for users and policies, and
myc add/get/delete for service accounts. Rename the service token
resource to service account (entity service_account, API
/api/serviceaccount). Create prints the token once.

Admins can create service accounts for any user. Empty statements
mean the same access as the owner; statements can only narrow it.
Block disabling or deleting the logged-in user. Upgrade 2.2.0-2
migrates stored service_token rows and policy resource kinds.
Require --action and --resource together so a half statement cannot
deny all access. myc add now exits 1 on failure. Resolve service
accounts by name+user when the name is not unique (--user).

Add myc add user. Support --effect Allow|Deny on service-account add.
Print statement rules in get user/policy/service-account instead of a count.
myc update user changes only the flags you pass (email, name,
password, username, policies). myc update sa updates name,
description, expiry, and statements without rotating the token.
Statement parsing is shared with add.
Check print errors in add/apply token output and remove unused
resourcesCoverKindWide after statement-based token limits.
@jkandasa
jkandasa merged commit f29cc30 into mycontroller-org:main Sep 14, 2026
1 check passed
@jkandasa
jkandasa deleted the cli_users_policies branch September 14, 2026 03:37
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