cli: manage users, policies, and service accounts - #49
Merged
Conversation
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.
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
Adds CLI management for users, policies, and service accounts, and renames the service token resource to service account.
myc apply/get/deletefor users and policiesmyc enable/disable user(cannot disable or delete the logged-in user)myc add service-account(aliascreate) plus apply/get/deleteservice_account, HTTP API/api/serviceaccount, policy kindserviceaccount2.2.0-2migratesservice_tokenrows and policy resource kindsPairs 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-botprints a token once;myc get salists itmyc applyadd/merge/delete user, policy, and service-accountmyc disable user <alias> <self>andmyc delete user <alias> <self>fail