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

Add automatic role access requests #39003

Merged
merged 2 commits into from Apr 5, 2024
Merged

Conversation

atburke
Copy link
Contributor

@atburke atburke commented Mar 6, 2024

This change adds the option to automatically make a role access request during tsh ssh instead of the current automatic resource access request. See core goals for details on expected functionality.

$ tsh ssh --request-mode role user@node.example.com
Error: access denied to user connecting to node.example.com:0

You do not currently have access to "user@node", attempting to request access.

Choose role to request [role-1, role-2, role-3]: # user enters role name
Enter request reason: # user enters request reason
# the rest is the same as for resource requests

Changelog: Added automatic role access requests

@github-actions github-actions bot added size/md tsh tsh - Teleport's command line tool for logging into nodes running Teleport. labels Mar 6, 2024
lib/client/api.go Outdated Show resolved Hide resolved
tool/tsh/common/tsh.go Outdated Show resolved Hide resolved
tool/tsh/common/tsh.go Outdated Show resolved Hide resolved
tool/tsh/common/tsh.go Outdated Show resolved Hide resolved
tool/tsh/common/tsh.go Outdated Show resolved Hide resolved
Copy link
Contributor

@fspmarshall fspmarshall left a comment

Choose a reason for hiding this comment

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

This is going to need some tweaking to get the access-control model correct. roles and search_as_roles are more different than they initially appear because search_as_roles implicitly grants read access to all resources in the list, but roles does not. We have to ensure that this API does not provide an opening for a user to test for the existence of resources for which they do not have read access. Similarly, the auth server is unable to make decisions about resources in leaf clusters, meaning that it will likely actually be common for us to be given a resource ID list where the answer to the question "what roles can I request to get access to this resource?" is undecidable, either for technical or security reasons. Given the above, I think probably this API should just fallback to returning the entire list of all roles the user has the ability to request if either A) one or more IDs is not a resource that the user already has read access to, or B) one or more IDs is for a resource in a different cluster.

Also, I think @nklaassen should be a required reviewer for this work given his expertise in this kind of thing.

@atburke
Copy link
Contributor Author

atburke commented Mar 20, 2024

Friendly ping @nklaassen

Copy link
Contributor

@nklaassen nklaassen left a comment

Choose a reason for hiding this comment

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

Is there a GH issue or anything motivating this you could link to?

If there's not a design doc anywhere, could you include in the PR description a high level description of the usecase, the design, and an example of what this looks like on the CLI when you use it?

lib/auth/auth_with_roles.go Outdated Show resolved Hide resolved
tool/tsh/common/tsh.go Outdated Show resolved Hide resolved
tool/tsh/common/tsh.go Outdated Show resolved Hide resolved
tool/tsh/common/tsh.go Outdated Show resolved Hide resolved
tool/tsh/common/tsh_test.go Show resolved Hide resolved
tool/tsh/common/tsh_test.go Outdated Show resolved Hide resolved
api/proto/teleport/legacy/types/types.proto Outdated Show resolved Hide resolved
tool/tsh/common/tsh.go Outdated Show resolved Hide resolved
@nklaassen
Copy link
Contributor

roles and search_as_roles are more different than they initially appear because search_as_roles implicitly grants read access to all resources in the list, but roles does not. We have to ensure that this API does not provide an opening for a user to test for the existence of resources for which they do not have read access

This is a great point and I'm not coming up with a good solve for it off the top of my head. The test for VerbRead in the current PR is not sufficient because we normally don't allow read access unless node_labels or node_labels_expression matches as well

@atburke
Copy link
Contributor Author

atburke commented Mar 25, 2024

Friendly ping @nklaassen @fspmarshall

Copy link
Contributor

@nklaassen nklaassen left a comment

Choose a reason for hiding this comment

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

I'd still like for the PR description to include example of what it looks like to use this in the CLI

lib/auth/auth.go Outdated Show resolved Hide resolved
tool/tsh/common/tsh_test.go Show resolved Hide resolved
tool/tsh/common/tsh_test.go Outdated Show resolved Hide resolved
lib/services/access_request.go Outdated Show resolved Hide resolved
tool/tsh/common/tsh_test.go Outdated Show resolved Hide resolved
Copy link
Contributor

@fspmarshall fspmarshall left a comment

Choose a reason for hiding this comment

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

I think the idea of just needing an overlapping search_as_roles declaration in order to view target resources is a good one. Eventually we may want to give the UX some additional polish, possibly some kind of flag that could be set to switch the roles field to imply implicit reads so that users don't need to maintain two sources of truth for requestable roles. I think the overlapping search_as_roles idea is good enough for now though, as it lets us do the right thing from an access control perspective without adding new knobs and/or doing anything too unexpected.

Some additional test coverage in lib/auth and/or lib/services would be good (tsh adds a lot of client-side behavior, so I think its good practice to verify security-related behaviors without it in the mix). As Nic mentioned, at least one or two tests should simulate a user probing with resource IDs they aren't allowed to know about.

Overall though, I think the design is in a good place!

@public-teleport-github-review-bot public-teleport-github-review-bot bot removed the request for review from jakule March 26, 2024 01:58
Copy link
Contributor

@nklaassen nklaassen left a comment

Choose a reason for hiding this comment

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

Sorry to go back and forth so many times on this, it's close! I think we've got the backend right now, I just have a couple nits, and then some comments on the tsh UX which I think can be improved a bit

lib/services/access_request.go Outdated Show resolved Hide resolved
lib/services/access_request.go Outdated Show resolved Hide resolved
lib/services/access_request.go Outdated Show resolved Hide resolved
tool/tsh/common/tsh.go Outdated Show resolved Hide resolved
tool/tsh/common/tsh.go Outdated Show resolved Hide resolved
Copy link
Contributor

@nklaassen nklaassen left a comment

Choose a reason for hiding this comment

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

Thanks for addressing all of my comments, looks good!

if err := promptUserForAccessRequestDetails(cf, req); err != nil {
return trace.Wrap(err)
}

if err := setAccessRequestReason(cf, req); err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

I would handle setAccessRequestReason from within promptUserForAccessRequestDetails, logically it's part of that

This change adds the optioin to automatically make a role access request
during tsh ssh instead of a resource access request.
@atburke
Copy link
Contributor Author

atburke commented Apr 4, 2024

@zmb3 @r0mant Can I get a flaky test skip from one of y'all? I think TestSSHAccessRequest is too slow to make it through.

@zmb3
Copy link
Collaborator

zmb3 commented Apr 5, 2024

/excludeflake *

@atburke atburke added this pull request to the merge queue Apr 5, 2024
Merged via the queue into master with commit d0a68fd Apr 5, 2024
37 checks passed
@atburke atburke deleted the atburke/auto-role-request branch April 5, 2024 19:58
@public-teleport-github-review-bot

@atburke See the table below for backport results.

Branch Result
branch/v15 Failed

atburke added a commit that referenced this pull request Apr 5, 2024
* Add automatic role requests

This change adds the optioin to automatically make a role access request
during tsh ssh instead of a resource access request.
atburke added a commit that referenced this pull request Apr 5, 2024
* Add automatic role requests

This change adds the option to automatically make a role access request
during tsh ssh instead of a resource access request.
github-merge-queue bot pushed a commit that referenced this pull request Apr 5, 2024
* Add automatic role access requests (#39003)

* Add automatic role requests

This change adds the option to automatically make a role access request
during tsh ssh instead of a resource access request.

* Fix test
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport/branch/v15 size/md 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.

None yet

6 participants