Skip to content

Get accessInfo based on user on access request drop#31068

Merged
ravicious merged 3 commits intomasterfrom
ravicious/drop-request-login-state
Aug 28, 2023
Merged

Get accessInfo based on user on access request drop#31068
ravicious merged 3 commits intomasterfrom
ravicious/drop-request-login-state

Conversation

@ravicious
Copy link
Copy Markdown
Member

@ravicious ravicious commented Aug 28, 2023

That's how it used to be before user login state was introduced (#29364). When dropping a resource access request, we want to restore certs back to the state before the access request was assumed, so that the user access is not limited only to select resources. In the past, this was done by calculating accessInfo from a plain user object.

This approach had the side effect of refreshing the role list of the user based on the current backend state, without the need to provide credentials again. Teleport Connect used this side effect to make the setup of Connect My Computer interaction-free.

Theoretically, it'd be beneficial for tsh request drop to use login state rather than the current backend state, as it'd make it impossible to "escalate" privileges by refreshing the list of roles without authenticating again. However, this brakes the setup of Connect My Computer as it expects GenerateUserCerts to return a role list based on a current user role list.

This commit reverts that change. Mike says this behavior change wasn't intentional and that we should revert it. It's also beneficial for Connect, as an alternative would be to change Connect My Computer setup to require a one-time relogin midway through.

See the discussion under #29364 for even more context.

That's how it used to be before user login state was introduced. When
dropping a resource access request, we want to restore certs back to the
state before the access request was assumed, so that the user access is
not limited only to select resources. In the past, this was done by
calculating accessInfo from a plan user object.

This approach had the side effect of refreshing the role list of the user
based on the current backend state without the need to provide credentials
again. Teleport Connect used this side effect to make the setup of Connect
My Computer interaction-free.

Theoretically, it'd be beneficial for `tsh request drop` to use login state
rather than the current backend state, as it'd make it impossible to "escalate"
privileges by refreshing the list of roles without authenticating again.
However, this brakes the setup of Connect My Computer as it expects
GenerateUserCerts to return a role list based on a current user role list.

This commit reverts that change. An alternative would be to change Connect
My Computer setup to require a one-time relogin midway through.
Copy link
Copy Markdown
Contributor

@Tener Tener left a comment

Choose a reason for hiding this comment

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

If we are changing an important edge case, we should probably have test coverage for that. I'm not following the thread too closely, but would you be able to add one, possibly demonstrating the use case that Connect is benefiting from?

@ravicious ravicious requested review from mdwn and removed request for gabrielcorado August 28, 2023 12:46
@ravicious
Copy link
Copy Markdown
Member Author

Yeah, sorry, I was trying to get this out ASAP before the test plan starts.

The old behavior, which this PR restores, was "get access info from the user state". The current behavior is "get access info from the login state, if the login state is missing then get it from the user state". The tests for the old behavior were passing because they themselves didn't create any login state, so they didn't catch the regression.

I suppose I could add a test which goes through a normal login procedure (and so it creates a login state), adds a role to the user and then verifies that dropping an access request gets the role list from the user and not the login state.

The only reason the existing integration test didn't catch that was because it doesn't actually perform a regular login.

@ravicious ravicious mentioned this pull request Aug 28, 2023
8 tasks
@ravicious
Copy link
Copy Markdown
Member Author

I refactored the existing integration test to use a real login flow. It fails on current master.

I also added some comments explaining when to prefer NewClientWithCreds vs actual login flow, though I'm not quite sure if I understand it properly in the first place. AFAIK we use stuff like NewClientWithCreds to limit the number of crypto operations when running integration tests and using NewClientWithCreds is faster than going through an actual login procedure?

@public-teleport-github-review-bot public-teleport-github-review-bot Bot removed the request for review from hugoShaka August 28, 2023 15:37
@ravicious ravicious enabled auto-merge August 28, 2023 15:43
@ravicious ravicious added this pull request to the merge queue Aug 28, 2023
Merged via the queue into master with commit 04aafb5 Aug 28, 2023
@ravicious ravicious deleted the ravicious/drop-request-login-state branch August 28, 2023 16:11
@public-teleport-github-review-bot
Copy link
Copy Markdown

@ravicious See the table below for backport results.

Branch Result
branch/v13 Failed

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants