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

Dont allow cloud tenants to update certain cluster networking config fields #28634

Merged
merged 3 commits into from Jul 11, 2023

Conversation

lxea
Copy link
Contributor

@lxea lxea commented Jul 4, 2023

Fix for #18829

This change allows cloud tenants to editing all fields of the cluster networking config except for those specified in #18829 --

  • ProxyListenerMode
  • TunnelStrategy
  • KeepAliveInterval
  • KeepAliveCountMax

The fields can be changed if the user editing them has the Admin role type

@github-actions github-actions bot requested review from jakule and tcsc July 4, 2023 11:30
lib/auth/auth_with_roles.go Outdated Show resolved Hide resolved
lib/auth/auth_with_roles.go Outdated Show resolved Hide resolved
lib/auth/auth_with_roles_test.go Show resolved Hide resolved

func (a *ServerWithRoles) validateCloudNetworkConfigUpdate(newConfig, oldConfig types.ClusterNetworkingConfig) error {
if a.hasBuiltinRole(types.RoleAdmin) {
return 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'd argue that not having permission should return an error rather than nil. How can I know if the config is updated if this function returns nil and do nothing?

}

if !modules.GetModules().Features().Cloud {
return nil
Copy link
Contributor

Choose a reason for hiding this comment

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

The same as above. IMO this should be an error

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure I understand, for non cloud instances, its okay for non admin users to to update the config. This is the same way ValidateResource in modules.go works

Copy link
Contributor

Choose a reason for hiding this comment

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

My bad, this is validate not set 🤦
But in this case, if you're an admin then we don't need to validate the values? Shouldn't this and if a.hasBuiltinRole(types.RoleAdmin) { check be done last not first?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As far as I understand from the issue (#18829 (comment)) cluster_networking_config is going to be a dynamic resource and so we'll want admin users to be able to update it without checking the rules, I think

Copy link
Contributor

Choose a reason for hiding this comment

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

This looks correct to me too

lib/auth/auth_with_roles.go Outdated Show resolved Hide resolved
lib/auth/auth_with_roles_test.go Show resolved Hide resolved
@lxea lxea force-pushed the lxea/cluster_networking_config-cloud branch from bf576e6 to 0b81a64 Compare July 10, 2023 11:09
lib/auth/auth_with_roles_test.go Outdated Show resolved Hide resolved
}

if !modules.GetModules().Features().Cloud {
return nil
Copy link
Contributor

Choose a reason for hiding this comment

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

This looks correct to me too

@rosstimothy rosstimothy self-requested a review July 11, 2023 12:45
@public-teleport-github-review-bot public-teleport-github-review-bot bot removed the request for review from tcsc July 11, 2023 14:29
@lxea lxea force-pushed the lxea/cluster_networking_config-cloud branch from f4b95d8 to 4040404 Compare July 11, 2023 14:36
@lxea lxea enabled auto-merge July 11, 2023 16:11
@lxea lxea added this pull request to the merge queue Jul 11, 2023
Merged via the queue into master with commit 3fff0bd Jul 11, 2023
22 checks passed
@lxea lxea deleted the lxea/cluster_networking_config-cloud branch July 11, 2023 16:29
@public-teleport-github-review-bot

@lxea See the table below for backport results.

Branch Result
branch/v13 Create PR

nklaassen pushed a commit that referenced this pull request May 3, 2024
…fields

I'm bringing #28634 back from the dead, looks like it got nuked from
orbit in a bad merge conflict resolution in #27873

Dont allow cloud tenants to update certain cluster networking fields
github-merge-queue bot pushed a commit that referenced this pull request May 7, 2024
…fields (#41197)

* Dont allow cloud tenants to update certain cluster networking config fields

I'm bringing #28634 back from the dead, looks like it got nuked from
orbit in a bad merge conflict resolution in #27873

Dont allow cloud tenants to update certain cluster networking fields

* share validate impl

* add godoc comment

---------

Co-authored-by: Alex McGrath <alex.mcgrath@goteleport.com>
github-actions bot pushed a commit that referenced this pull request May 7, 2024
…fields

I'm bringing #28634 back from the dead, looks like it got nuked from
orbit in a bad merge conflict resolution in #27873

Dont allow cloud tenants to update certain cluster networking fields
github-merge-queue bot pushed a commit that referenced this pull request May 8, 2024
…onfig fields (#41247)

* Dont allow cloud tenants to update certain cluster networking config fields

I'm bringing #28634 back from the dead, looks like it got nuked from
orbit in a bad merge conflict resolution in #27873

Dont allow cloud tenants to update certain cluster networking fields

* share validate impl

* add godoc comment

---------

Co-authored-by: Alex McGrath <alex.mcgrath@goteleport.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants