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

Fix role mapping for trusted clusters #3253

Merged
merged 1 commit into from
Jan 10, 2020
Merged

Conversation

klizhentas
Copy link
Contributor

This commit fixes #3252

Security patches 4.2 introduced a regression - leaf clusters ignore role mapping
and attempt to use role names coming from identity of the root cluster
whenever GetNodes method was used.

This commit reverts back the logic, however it ensures that the original
fix is preserved - traits and groups are updated on the user object.

Integration test has been extended to avoid the regression in the future, also manual testing with docker compose was done to verify that issue has been fixed.

This commit fixes #3252

Security patches 4.2 introduced a regression - leaf clusters ignore role mapping
and attempt to use role names coming from identity of the root cluster
whenever GetNodes method was used.

This commit reverts back the logic, however it ensures that the original
fix is preserved - traits and groups are updated on the user object.

Integration test has been extended to avoid the regression in the future.
@@ -1401,7 +1400,7 @@ func isFormatOld(cert *ssh.Certificate) bool {
_, hasRoles := cert.Extensions[teleport.CertExtensionTeleportRoles]
_, hasTraits := cert.Extensions[teleport.CertExtensionTeleportTraits]

if hasRoles && hasTraits {
if hasRoles || hasTraits {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Just making sure you intended to change the logic here, ignore if it's on purpose.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

on purpose

if err != nil {
return nil, trace.Wrap(err)
}
if len(traits) > 0 {
Copy link
Contributor

Choose a reason for hiding this comment

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

Pretty sure this is always true since traits is going to marshall to {} or null when empty.

Copy link
Contributor

Choose a reason for hiding this comment

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

What about this? Same for lib/auth/native.go.

if len(c.Traits) > 0 {
    traits, err := wrappers.MarshalTraits(&c.Traits)
    if err != nil {
      return nil, trace.Wrap(err)
    }
    cert.Permissions.Extensions[teleport.CertExtensionTeleportTraits] = string(traits)
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the traits were omitted in my tests

Copy link
Contributor

Choose a reason for hiding this comment

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

Just wrote a manual test, and MarshalTraits always returned either {} or null depending on whether the *wrappers.Traits value was empty or nil... 😕

Did your tests verify that the cert extension was actually omitted, or just that no traits were present in the decoded identity?

@klizhentas
Copy link
Contributor Author

retest this please

4 similar comments
@klizhentas
Copy link
Contributor Author

retest this please

@klizhentas
Copy link
Contributor Author

retest this please

@klizhentas
Copy link
Contributor Author

retest this please

@klizhentas
Copy link
Contributor Author

retest this please

@klizhentas klizhentas merged commit 65817bc into branch/4.0 Jan 10, 2020
@klizhentas klizhentas deleted the sasha/fix-role-mapping branch March 15, 2021 16:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants