Skip to content

Add commands for manage users groups and access#339

Merged
ldmonster merged 6 commits intomainfrom
add-user-group-access-managing
May 6, 2026
Merged

Add commands for manage users groups and access#339
ldmonster merged 6 commits intomainfrom
add-user-group-access-managing

Conversation

@Jabejixo
Copy link
Copy Markdown
Contributor

@Jabejixo Jabejixo commented Apr 27, 2026

Description

New d8 iam command tree for managing local users, groups, and access grants. Five top-level subcommands under internal/iam/:

  • d8 iam usercreate / delete / reset-password / reset2fa / lock / unlock.
  • d8 iam groupcreate / delete / add-member / remove-member.
  • d8 iam accessgrant / revoke.
  • d8 iam getuser, group, rule.
  • d8 iam listusers|user, groups|group, rules|rule.

Read verbs are top-level (d8 iam get user alice, d8 iam list users), not per-domain wrappers.

Subjects are positional. grant / revoke take -n/--namespace (repeatable, AR) or --scope cluster|all-namespaces|labels=K=V[,K2=V2,...] (CAR with namespaceSelector.labelSelector). Capabilities (--allow-scale, --port-forwarding) compose with any scope. d8-managed grants get a deterministic name, so grant / revoke are idempotent.

Password input is unified across user create and user reset-password: interactive (default), --password-stdin, --generate-password, or --password-hash. The CLI handles the format difference between User.spec.password (base64-bcrypt) and UserOperation.spec.resetPassword.newPasswordHash (raw bcrypt).

Shell completion covers command names, resource names, namespaces, access levels, scope values, rule refs, and output formats. Common k8s helpers (PrintObject, NewDynamicClient, AddOutputFlag, CompleteResourceNames, ...) live in internal/utilk8s/. The previously top-level d8 user was moved under d8 iam user.

Why do we need it, and what problem does it solve?

Managing users, groups, and access in Deckhouse today means hand-crafting User, Group, AuthorizationRule, and ClusterAuthorizationRule CRs and applying them via kubectl. There is no first-class CLI for inventory, "who has access to what", or safe revocation.

d8 iam provides:

  • a single discoverable command tree with consistent flag semantics;
  • effective-access inventory: iam list users|groups (aggregated table) and iam get user|group <name> (direct grants, transitive group membership, inherited grants, effective summary, warnings for cycles / orphaned members / manually maintained rules), with SuperAdmin wildcard capabilities surfaced as implicit;
  • iam list rules / iam get rule with reverse lookup of subjects to local User / Group CRs;
  • idempotent grant / revoke

Why do we need it in the patch release (if we do)?

Not necessarily.

Changelog entries

section: deckhouse-cli
type: feature
summary: Add `d8 iam` command tree for managing local users, groups, and access grants

@Jabejixo Jabejixo force-pushed the add-user-group-access-managing branch 2 times, most recently from 13a6cc9 to cabfa61 Compare April 27, 2026 07:53
@Jabejixo Jabejixo marked this pull request as ready for review April 29, 2026 07:10
@Jabejixo Jabejixo requested a review from ldmonster as a code owner April 29, 2026 07:10
Copy link
Copy Markdown

@AlwxSin AlwxSin left a comment

Choose a reason for hiding this comment

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

There are lack of some test scenarios:

  • no grant -> revoke round-trip
  • no remove-member tests
  • no tests for UserOperation creation
  • no tests for group create/delete

Comment thread internal/iam/access/cmd/naming.go Outdated
Comment thread internal/iam/group/cmd/remove_member.go Outdated
Comment thread internal/iam/group/cmd/membership.go Outdated
Comment thread internal/iam/access/cmd/grant.go Outdated
Comment thread internal/iam/access/cmd/list.go
Comment thread internal/iam/access/cmd/revoke.go
Comment thread internal/iam/user/cmd/delete.go Outdated
Comment thread internal/iam/access/cmd/rules.go Outdated
Comment thread internal/iam/access/cmd/rules.go Outdated
Comment thread internal/utilk8s/completion.go Outdated
Jabejixo added 6 commits May 5, 2026 13:30
Signed-off-by: Ivan Zvyagintsev <ivan.zvyagintsev@flant.com>
Signed-off-by: Ivan Zvyagintsev <ivan.zvyagintsev@flant.com>
Signed-off-by: Ivan Zvyagintsev <ivan.zvyagintsev@flant.com>
Signed-off-by: Ivan Zvyagintsev <ivan.zvyagintsev@flant.com>
Signed-off-by: Ivan Zvyagintsev <ivan.zvyagintsev@flant.com>
Signed-off-by: Ivan Zvyagintsev <ivan.zvyagintsev@flant.com>
@Jabejixo Jabejixo force-pushed the add-user-group-access-managing branch from 3256302 to e90a2cb Compare May 5, 2026 10:31
@Jabejixo Jabejixo requested a review from AlwxSin May 5, 2026 10:36
@ldmonster ldmonster merged commit b349fa0 into main May 6, 2026
5 checks passed
@ldmonster ldmonster deleted the add-user-group-access-managing branch May 6, 2026 16:36
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.

3 participants