Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow setting additional traits in tctl users add command #12102

Merged
merged 2 commits into from
Apr 20, 2022
Merged

Conversation

r0mant
Copy link
Collaborator

@r0mant r0mant commented Apr 20, 2022

This PR updates tctl users add command to support providing additional internal user traits which can then be used in role templating.

It already had flags for logins and windows_logins, this PR also adds support for kubernetes_users, kubernetes_groups, database_users, database_names and aws_role_arns, and their respective {{internal.xxx}} role template variables.

With this change admins would be able to create local users and set all traits in a single command without having to edit the user after the fact, e.g.

$ tctl users add --roles=access,editor \
  --logins=root \
  --database-users=postgres,test \
  --database-names=\* \
  --kubernetes-groups=system:masters \
  alice

This will significantly simplify parts of database access getting started guides which currently ask to create the Teleport user and then update the resource to set the traits (I'll update the docs after this merges).

Closes #10529.

@github-actions github-actions bot requested review from jakule and smallinsky April 20, 2022 01:11
@github-actions github-actions bot added the tctl tctl - Teleport admin tool label Apr 20, 2022
tool/tctl/common/user_command.go Outdated Show resolved Hide resolved
@@ -116,6 +116,7 @@ func NewPresetAccessRole() types.Role {
role.SetWindowsLogins(types.Allow, []string{teleport.TraitInternalWindowsLoginsVariable})
role.SetKubeUsers(types.Allow, []string{teleport.TraitInternalKubeUsersVariable})
role.SetKubeGroups(types.Allow, []string{teleport.TraitInternalKubeGroupsVariable})
role.SetAWSRoleARNs(types.Allow, []string{teleport.TraitInternalAWSRoleARNs})
Copy link
Contributor

Choose a reason for hiding this comment

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

Wonder is we should bother about migration to cover the case where an access role was already created without aws role arn trait placeholder but a user follows the doc and tries to leverage aws-role-arns tctl flag.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We generally don't migrate existing roles (even presets) because users may have their own roles with the same names and we don't want to modify them.

@r0mant r0mant enabled auto-merge (squash) April 20, 2022 20:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tctl tctl - Teleport admin tool
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add --kubernetes-users and other to tctl users add
3 participants