Conversation
65356ab to
8f2ae19
Compare
8f2ae19 to
43bca0f
Compare
| RoleTrustedCluster, LegacyClusterTokenType, | ||
| RoleSignup, RoleProxy, RoleNop, RoleKube, RoleWindowsDesktop: | ||
| RoleSignup, RoleProxy, RoleRemoteProxy, | ||
| RoleNop, RoleKube, RoleWindowsDesktop: |
There was a problem hiding this comment.
nit: This approach have one main drawback the roleMappings map needs to be updated each time when a new Role is added also with the Check() case
What would you say about something like:
func (r *SystemRole) Check() error {
m := make(map[string]struct{})
for _, v := range roleMappings {
if v == r {
return nil
}
}
return trace.BadParameter("role %v is not registered", *r)
} so only we care about roleMappings
There was a problem hiding this comment.
Good call, take a look at the latest commit. I like this much better.
| "node": RoleNode, | ||
| "proxy": RoleProxy, | ||
| "admin": RoleAdmin, | ||
| "provisiontoken": RoleProvisionToken, |
There was a problem hiding this comment.
is provision_token a valid input?
There was a problem hiding this comment.
No, it never has been.
We're a little more tolerant and allow _ separators for things that are commonly typed on the command line, like when generating tokens to allow a kube service or windows desktop service to join the cluster.
Since no one ever needs to generate provision tokens via the CLI, I didn't see a need to make provision_token valid.
In fact, after a quick search, it seems RoleProvisionToken is never used. Maybe we should delete it.
1ea4618 to
017b986
Compare
Our original attempt at canonicalizing roles didn't work for system roles using camelcase, resulting in an awkward user experience. Here we maintain a mapping of allowed inputs to their corresponding system roles, and perform a case-insensitive lookup. This allows us to support camelcase roles, and has the advantage of permitting _ word separators as well. Fixes #9752
Rather than having to list each role here, we rely on the new roleMappings set to validate the role. Additionally, remove the LegacyClusterTokenType role. This change is guaranteed to be backwards compatible because we check for RoleTrustedCluster everywhere we were checking for LegacyClusterTokenType, and our roleMappings will convert the old string that represented LegacyClusterTokenType to RoleTrustedCluster.
017b986 to
7c87c26
Compare
* Add tests for ParseTeleportRoles Updates #9752 * Be more tolerant when parsing system roles. Our original attempt at canonicalizing roles didn't work for system roles using camelcase, resulting in an awkward user experience. Here we maintain a mapping of allowed inputs to their corresponding system roles, and perform a case-insensitive lookup. This allows us to support camelcase roles, and has the advantage of permitting _ word separators as well. Fixes #9752 * Refactor *SystemRole.Check() Rather than having to list each role here, we rely on the new roleMappings set to validate the role. Additionally, remove the LegacyClusterTokenType role. This change is guaranteed to be backwards compatible because we check for RoleTrustedCluster everywhere we were checking for LegacyClusterTokenType, and our roleMappings will convert the old string that represented LegacyClusterTokenType to RoleTrustedCluster.
* Add tests for ParseTeleportRoles Updates #9752 * Be more tolerant when parsing system roles. Our original attempt at canonicalizing roles didn't work for system roles using camelcase, resulting in an awkward user experience. Here we maintain a mapping of allowed inputs to their corresponding system roles, and perform a case-insensitive lookup. This allows us to support camelcase roles, and has the advantage of permitting _ word separators as well. Fixes #9752 * Refactor *SystemRole.Check() Rather than having to list each role here, we rely on the new roleMappings set to validate the role. Additionally, remove the LegacyClusterTokenType role. This change is guaranteed to be backwards compatible because we check for RoleTrustedCluster everywhere we were checking for LegacyClusterTokenType, and our roleMappings will convert the old string that represented LegacyClusterTokenType to RoleTrustedCluster.
* Add tests for ParseTeleportRoles Updates #9752 * Be more tolerant when parsing system roles. Our original attempt at canonicalizing roles didn't work for system roles using camelcase, resulting in an awkward user experience. Here we maintain a mapping of allowed inputs to their corresponding system roles, and perform a case-insensitive lookup. This allows us to support camelcase roles, and has the advantage of permitting _ word separators as well. Fixes #9752 * Refactor *SystemRole.Check() Rather than having to list each role here, we rely on the new roleMappings set to validate the role. Additionally, remove the LegacyClusterTokenType role. This change is guaranteed to be backwards compatible because we check for RoleTrustedCluster everywhere we were checking for LegacyClusterTokenType, and our roleMappings will convert the old string that represented LegacyClusterTokenType to RoleTrustedCluster.
Be more consistent in what inputs we accept when referring to system roles, such as in the
tctl tokens addcall.Also add missing test coverage for this parser.
Fixes #9752