Improve performance of MFA ceremony#24250
Merged
rosstimothy merged 1 commit intomasterfrom Apr 14, 2023
Merged
Conversation
fde04fc to
1861e33
Compare
Joerger
approved these changes
Apr 12, 2023
Joerger
requested changes
Apr 12, 2023
Contributor
Joerger
left a comment
There was a problem hiding this comment.
Sorry, I didn't mean to approve yet ^
codingllama
reviewed
Apr 12, 2023
Contributor
|
Looks good, nice to see this one out for review. |
Joerger
approved these changes
Apr 13, 2023
e4f7e44 to
fc178b6
Compare
ryanclark
approved these changes
Apr 14, 2023
codingllama
approved these changes
Apr 14, 2023
02f586e to
1e80da5
Compare
1e80da5 to
60445b5
Compare
To date clients attempting to access a resource first have to call `proto.AuthService/IsMFARequired` to determine if an mfa ceremony is needed for access to a resource. In an effort to reduce an extra round trip to the Auth server this can can be bundled into `proto.AuthService/GenerateUserSingleUseCerts`. In order for RBAC to determine if mfa is required for SSH sessions the OS login of the session must be known. To accomodate this a new `SSHLogin` field was added to `proto.UserCertsRequest`. The response to the initial request of the stream now contains a `proto.MFARequired` enum which indicates whether mfa is required, not required, or it's unknown if mfa is required. The last variant should only be returned when the `SSHLogin` field is unset in the initial request. The `(auth.Server) isMFARequired` check was also modified for nodes to make use of `ListResources`. Instead of retrieving **all** nodes into memory and finding the matching ones, a request is made to `ListResources` with the `SearchKeywords` populated with the target from `proto.IsMFARequiredRequest_Node.Node.Node`. Care was taken to filter out any matches from labels to preserve the original matching behavior.
60445b5 to
0ccbb5f
Compare
This was referenced Apr 19, 2023
This was referenced May 1, 2023
rosstimothy
added a commit
that referenced
this pull request
May 5, 2023
The MFA required check added to the Auth server in #24250 is now only performed if the `RouteToCluster` indicates that the request is for the local cluster and not a remote cluster. When the root cluster checks if mfa is required to a resource in another cluster it would always return a not found error since the resource didn't exist in the root backend. This results in the behavior described in #25619. This step is now skipped for any resources in another cluster to allow certificates for remote cluster resources to be generated by the root. `tsh` detects that a resource is a leaf cluster and will first call `proto.AuthService/IsMFARequired` on the leaf cluster before requesting certificates from the root cluster to prevent a user from being prompted to complete an MFA ceremony if one is not required. Closes #25619
rosstimothy
added a commit
that referenced
this pull request
May 8, 2023
The MFA required check added to the Auth server in #24250 is now only performed if the `RouteToCluster` indicates that the request is for the local cluster and not a remote cluster. When the root cluster checks if mfa is required to a resource in another cluster it would always return a not found error since the resource didn't exist in the root backend. This results in the behavior described in #25619. This step is now skipped for any resources in another cluster to allow certificates for remote cluster resources to be generated by the root. `tsh` detects that a resource is a leaf cluster and will first call `proto.AuthService/IsMFARequired` on the leaf cluster before requesting certificates from the root cluster to prevent a user from being prompted to complete an MFA ceremony if one is not required. Closes #25619
rosstimothy
added a commit
that referenced
this pull request
May 8, 2023
* Add leaf resource test cases to TestGenerateUserSingleUseCert Updates TestGenerateUserSingleUseCert to test certificate generation for kube and db resources in a leaf cluster. * Fix access to leaf resources The MFA required check added to the Auth server in #24250 is now only performed if the `RouteToCluster` indicates that the request is for the local cluster and not a remote cluster. When the root cluster checks if mfa is required to a resource in another cluster it would always return a not found error since the resource didn't exist in the root backend. This results in the behavior described in #25619. This step is now skipped for any resources in another cluster to allow certificates for remote cluster resources to be generated by the root. `tsh` detects that a resource is a leaf cluster and will first call `proto.AuthService/IsMFARequired` on the leaf cluster before requesting certificates from the root cluster to prevent a user from being prompted to complete an MFA ceremony if one is not required. Closes #25619 * Add desktop and app test case to TestGenerateUserSingleUseCert
github-actions Bot
pushed a commit
that referenced
this pull request
May 8, 2023
The MFA required check added to the Auth server in #24250 is now only performed if the `RouteToCluster` indicates that the request is for the local cluster and not a remote cluster. When the root cluster checks if mfa is required to a resource in another cluster it would always return a not found error since the resource didn't exist in the root backend. This results in the behavior described in #25619. This step is now skipped for any resources in another cluster to allow certificates for remote cluster resources to be generated by the root. `tsh` detects that a resource is a leaf cluster and will first call `proto.AuthService/IsMFARequired` on the leaf cluster before requesting certificates from the root cluster to prevent a user from being prompted to complete an MFA ceremony if one is not required. Closes #25619
rosstimothy
added a commit
that referenced
this pull request
May 8, 2023
* Add leaf resource test cases to TestGenerateUserSingleUseCert Updates TestGenerateUserSingleUseCert to test certificate generation for kube and db resources in a leaf cluster. * Fix access to leaf resources The MFA required check added to the Auth server in #24250 is now only performed if the `RouteToCluster` indicates that the request is for the local cluster and not a remote cluster. When the root cluster checks if mfa is required to a resource in another cluster it would always return a not found error since the resource didn't exist in the root backend. This results in the behavior described in #25619. This step is now skipped for any resources in another cluster to allow certificates for remote cluster resources to be generated by the root. `tsh` detects that a resource is a leaf cluster and will first call `proto.AuthService/IsMFARequired` on the leaf cluster before requesting certificates from the root cluster to prevent a user from being prompted to complete an MFA ceremony if one is not required. Closes #25619 * Add desktop and app test case to TestGenerateUserSingleUseCert
rosstimothy
added a commit
that referenced
this pull request
May 8, 2023
* Add leaf resource test cases to TestGenerateUserSingleUseCert Updates TestGenerateUserSingleUseCert to test certificate generation for kube and db resources in a leaf cluster. * Fix access to leaf resources The MFA required check added to the Auth server in #24250 is now only performed if the `RouteToCluster` indicates that the request is for the local cluster and not a remote cluster. When the root cluster checks if mfa is required to a resource in another cluster it would always return a not found error since the resource didn't exist in the root backend. This results in the behavior described in #25619. This step is now skipped for any resources in another cluster to allow certificates for remote cluster resources to be generated by the root. `tsh` detects that a resource is a leaf cluster and will first call `proto.AuthService/IsMFARequired` on the leaf cluster before requesting certificates from the root cluster to prevent a user from being prompted to complete an MFA ceremony if one is not required. Closes #25619 * Add desktop and app test case to TestGenerateUserSingleUseCert
rosstimothy
added a commit
that referenced
this pull request
May 8, 2023
* Add leaf resource test cases to TestGenerateUserSingleUseCert Updates TestGenerateUserSingleUseCert to test certificate generation for kube and db resources in a leaf cluster. * Fix access to leaf resources The MFA required check added to the Auth server in #24250 is now only performed if the `RouteToCluster` indicates that the request is for the local cluster and not a remote cluster. When the root cluster checks if mfa is required to a resource in another cluster it would always return a not found error since the resource didn't exist in the root backend. This results in the behavior described in #25619. This step is now skipped for any resources in another cluster to allow certificates for remote cluster resources to be generated by the root. `tsh` detects that a resource is a leaf cluster and will first call `proto.AuthService/IsMFARequired` on the leaf cluster before requesting certificates from the root cluster to prevent a user from being prompted to complete an MFA ceremony if one is not required. Closes #25619 * Add desktop and app test case to TestGenerateUserSingleUseCert
rosstimothy
added a commit
that referenced
this pull request
May 9, 2023
* Add leaf resource test cases to TestGenerateUserSingleUseCert Updates TestGenerateUserSingleUseCert to test certificate generation for kube and db resources in a leaf cluster. * Fix access to leaf resources The MFA required check added to the Auth server in #24250 is now only performed if the `RouteToCluster` indicates that the request is for the local cluster and not a remote cluster. When the root cluster checks if mfa is required to a resource in another cluster it would always return a not found error since the resource didn't exist in the root backend. This results in the behavior described in #25619. This step is now skipped for any resources in another cluster to allow certificates for remote cluster resources to be generated by the root. `tsh` detects that a resource is a leaf cluster and will first call `proto.AuthService/IsMFARequired` on the leaf cluster before requesting certificates from the root cluster to prevent a user from being prompted to complete an MFA ceremony if one is not required. Closes #25619 * Add desktop and app test case to TestGenerateUserSingleUseCert
rosstimothy
added a commit
that referenced
this pull request
May 12, 2023
* Add leaf resource test cases to TestGenerateUserSingleUseCert Updates TestGenerateUserSingleUseCert to test certificate generation for kube and db resources in a leaf cluster. * Fix access to leaf resources The MFA required check added to the Auth server in #24250 is now only performed if the `RouteToCluster` indicates that the request is for the local cluster and not a remote cluster. When the root cluster checks if mfa is required to a resource in another cluster it would always return a not found error since the resource didn't exist in the root backend. This results in the behavior described in #25619. This step is now skipped for any resources in another cluster to allow certificates for remote cluster resources to be generated by the root. `tsh` detects that a resource is a leaf cluster and will first call `proto.AuthService/IsMFARequired` on the leaf cluster before requesting certificates from the root cluster to prevent a user from being prompted to complete an MFA ceremony if one is not required. Closes #25619 * Add desktop and app test case to TestGenerateUserSingleUseCert
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
To date clients attempting to access a resource first have to call
proto.AuthService/IsMFARequiredto determine if an mfa ceremony is needed for access to a resource. In an effort to reduce an extra round trip to the Auth server this can can be bundled intoproto.AuthService/GenerateUserSingleUseCerts.In order for RBAC to determine if mfa is required for SSH sessions the OS login of the session must be known. To accomodate this a new
SSHLoginfield was added toproto.UserCertsRequest.The response to the initial request of the stream now contains a
proto.MFARequiredenum which indicates whether mfa is required, not required, or it's unknown if mfa is required. The last variant should only be returned when theSSHLoginfield is unset in the initial request.The
(auth.Server) isMFARequiredcheck was also modified for nodes to make use ofListResources. Instead of retrieving all nodes into memory and finding the matching ones, a request is made toListResourceswith theSearchKeywordspopulated with the target fromproto.IsMFARequiredRequest_Node.Node.Node. Care was taken to filter out any matches from labels to preserve the original matching behavior.