Skip to content

Check if resource request is possible before attempting#13586

Merged
nklaassen merged 7 commits intomasterfrom
nklaassen/ssh-request-fix
Jun 17, 2022
Merged

Check if resource request is possible before attempting#13586
nklaassen merged 7 commits intomasterfrom
nklaassen/ssh-request-fix

Conversation

@nklaassen
Copy link
Copy Markdown
Contributor

Currently if a user attempts tsh ssh user1@node1 where they are allowed to list node1 but not login with user1, tsh will attempt to create a resource access request for it even if the user is not allowed to create any resource requests (no configured search_as_roles). This is a regression caused by #13326.

The change here is to attempt to populate and validate the request on the server side, without actually creating the request by setting a dry_run flag. If there is any error, fail immediately with the original SSH error and do not prompt the user for a request reason or attempt to create an access request.

The server side validation is better than anything we can do client side because it actually has access to all roles, including roles the user does not currently have but could potentially request.

Another improvement with this change, tsh ssh user1@node1 will never prompt the user to create an access request if the user is not able to request access to node1 with login user1 but could with another login (the current check does not consider logins until after prompting the user and attempting to create the request).

The validation is slightly less smart if the requested node is in a leaf cluster - auth doesn't know about the leaf roles that will be mapped, but will still return an error if the user has no search_as_roles configured OR cannot list the node, so this will still be an improvement.

Before this change:

Nics-MacBook-Pro:teletest nklaassen$ tsh ssh ubuntu@one-node
ERROR: access denied to ubuntu connecting to one-node on cluster cluster-one

You do not currently have access to ubuntu@one-node, attempting to request access.

Enter request reason: pretty please
Creating request...
ERROR: user does not have any "search_as_roles" which are valid for this request

After this change:

Nics-MacBook-Pro:teletest nklaassen$ tsh ssh ubuntu@one-node
ERROR: access denied to ubuntu connecting to one-node on cluster cluster-one

@github-actions github-actions bot added the tsh tsh - Teleport's command line tool for logging into nodes running Teleport. label Jun 16, 2022
@nklaassen nklaassen force-pushed the nklaassen/ssh-request-fix branch from c580cd6 to 709a37e Compare June 17, 2022 01:30
Comment thread tool/tsh/tsh.go Outdated
@nklaassen nklaassen enabled auto-merge (squash) June 17, 2022 14:54
@nklaassen nklaassen merged commit f4eb282 into master Jun 17, 2022
@github-actions
Copy link
Copy Markdown
Contributor

@nklaassen See the table below for backport results.

Branch Result
branch/v10 Failed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

tsh tsh - Teleport's command line tool for logging into nodes running Teleport.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants