Commit Graph

31 Commits

Author SHA1 Message Date
renovate-rancher[bot] 7ac219ffda
Update dependency golangci/golangci-lint to v2 (main) (#841)
* Update dependency golangci/golangci-lint to v2

* Migrate the golangci config file.

* Fix golangci-lint-flagged problems

Most of them fall in these categories:

* stop ignoring returned errors from function calls

* Apply deMorgan's law to complex negative boolean expressions

* Delete unused local variables and struct fields

* Successfully get the linter to stop complaining about
  uncommented global names

* If one import in a block has an import prefix, all must

* Deal with deprecated code

* Prefer switch-blocks to if/else if/...

* Remove unnecessary intermediate struct fields.

* Orphans are now deleted only via propagation-policy

* Stop checking goimports on generated files.

* Remove unused field comment

---------

Co-authored-by: renovate-rancher[bot] <119870437+renovate-rancher[bot]@users.noreply.github.com>
Co-authored-by: Eric Promislow <epromislow@suse.com>
2025-09-18 11:39:45 -07:00
Vatsal Parekh f449e4babc
Update dependencies for k8s 1.32 (#672)
Signed-off-by: Vatsal Parekh <vatsalparekh@outlook.com>
2025-02-18 21:13:46 +05:30
Jonathan Crowther 12879d9718
[0.7] Remove references to Restricted Admin (#549)
* Remove references to Restricted Admin

* Forgot to save one of the changes
2024-11-26 11:06:59 -05:00
Eric Promislow d09d706d1d
Bump to k8s 1.31 (#528)
* Merge pull request #316 from thatmidwesterncoder/toleration_validation (#459)

Add validation to Toleration and Affinitys Keys

* Bump to k8s 1.31

* Bump the maximum supported k8s version to 1.31

* Bump other k8s modules to be consistent with k8s 1.31

* Bump to versions of lasso and wrangler that support k8s 1.31

* Move go the go-uber gomock module.

* Update the wrangler module.

* Correct the mockgen install command.

* And re-correct the 'go install ... mockgen' command.

---------

Co-authored-by: Jacob Lindgren <jacob.lindgren@suse.com>
2024-10-28 17:18:11 -07:00
Jonathan Crowther be481b7632
Add checks for annotation to opt out of cluster owner RBAC (#511)
* Move common annotations to resources/common

* Add new annotation to opt out of creatorID

* Add comments and unit tests

* Fix integration test

* Update annotation name

* Add annotation check to project and cluster

* Move annotation check to create

* Fix unit tests
2024-10-04 10:18:01 -04:00
Peter Matseykanets 6b74a9a900
Validate creatorId and creator-principal-name annotations for cluster/project (#501)
Ref: https://github.com/rancher/rancher/issues/46828
2024-09-19 15:40:04 -04:00
Tom Lebreux 97679b88dd
Add k8s 1.30 support (#412) 2024-06-28 09:23:25 -04:00
Raul Cabello Martin bb709831c2
Remove external-rules feature flag (#414) 2024-06-25 16:10:16 +02:00
Raul Cabello Martin f5cfd9821f
[v0.5] s4: Fixes 374 (#409)
* Verify ExternalRules in RoleTemplates

If the feature flag external-rules is enabled, the validation for RT follows this sequence:
- 1) Reject if externalRules are provided and the user doesn’t have escalate permissions on RoleTemplates.
- 2) Validate the policy rules defined in externalRules the same way as the already existing rules field. This validation leverages Kubernetes’ upstream validation. Webhook will validate this only if external is set to true.
- 3) Use externalRules for resolving rules if provided.
- 4) Use backing ClusterRole in the local cluster if externalRules are not provided.
- 5) Reject if externalRules are not provided and there is no backing ClusterRole in the local cluster.

For PRTB or CRTB:
- 1) Use externalRules for resolving rules if provided.
- 2) Use backing ClusterRole in the local cluster if externalRules are not provided.

The previous verification process applies if the external-rules feature flag is disabled.

* Allow Restricted Admin to update external-rules feature flag (#102)

---------
Co-authored-by: Raul Cabello Martin <raulcabm@gmail.com>
Co-authored-by: Jonathan Crowther <jonathan.crowther@suse.com>

* bump rancher to be able to use ExternalRules

* fix test conflict

---------

Co-authored-by: Peter Matseykanets <peter.matseykanets@suse.com>
2024-06-25 10:34:38 +02:00
Raul Cabello Martin af2d8bd5d2
Fleet RBAC - InheritedFleetWorkspacePermissions validation (#348)
- Validate the user have enough permission to create/update the rules defined in InheritedFleetWorkspacePermissions.ResourceRules
- Validate the user have enough permission to create/update the rules that are generated based on the InheritedFleetWorkspacePermissions.WorkspaceVerbs

---------

Co-authored-by: Michael Bolot <michael.bolot@suse.com>
2024-06-24 09:49:31 +02:00
Tom Lebreux c446d76682
Revert "Grant inherited permissions to other users" (#347) 2024-04-03 11:34:54 -04:00
Tom Lebreux 49160dee86
Add support for k8s 1.28 (#341) 2024-03-27 16:56:34 -04:00
Tom Lebreux 9392f57ca1 Evaluate Rules from external RT with project context
This fixes a bug where a project owner is not able to give some
privileges that they have because those aren't accounted for in the
webhook.
2024-01-16 13:05:39 -05:00
Tom Lebreux 23408dae65 Fix inherted -> inherited typo 2024-01-16 13:05:19 -05:00
Michael Bolot 3a12b29402 Updating EscalationAuthorized function
Updates the EscalationAuthorized function to accept a resource name and
verb, allowing usage for specific resources and verbs like bind
2023-10-03 09:06:03 -05:00
Michael Bolot b9ea614b30 Removing admin exception to gr cluster rules
Removes an exception given to allow admin users to have * on
inheritedClusterRoles. This will no longer be necessary due us honoring
the escalate and bind verbs
2023-10-03 09:05:59 -05:00
Michael Bolot f99acfa075 Tests for escalation on inheritedClusterRoles 2023-09-01 09:24:07 -05:00
Michael Bolot 608b159615 Adding validations for inheritedClusterRoles
Adds validations for inheritedClusterRoles, including checks
to validate bound roleTemplates are not locked and have a cluster
context, a check to make sure roleTemplates in use by global roles
can't be deleted, an escalation check for the inheritedClusterRoles field,
and a new GlobalRoleResolver to assist with escalation checks.
2023-09-01 09:24:07 -05:00
Kevin Joiner e2609754c4 Migrate RoleTemplates from Norman. 2023-07-19 12:11:29 -04:00
Kevin Joiner 3aa7a6a436 Update tests to use generics fakes. 2023-07-17 13:47:59 -04:00
Kevin Joiner 5f4f390a87 Restructered webhook registration.
Webhook request routing is now handled by K8s.
2022-12-15 12:05:58 -05:00
Kevin Joiner 64b53feb05 Adds test for auth, CRTB, and PRTB validation.
EscalationChecker struct has been replaced with static functions.
All function changes have associated unit tests.
The Wrangler version was bumped to add testing capabilities to the
validators. Which required a k8 version bump to 1.24.2.
2022-09-15 13:45:55 -04:00
Kevin Joiner 06fac5f2af Adds verb checks for PRTBs and CRTBs 2022-08-11 08:02:12 -04:00
Kevin Joiner aaccab8407 Applies RT escalate check. 2022-06-21 10:00:48 -04:00
Michael Bolot b9dc2209f1 Adding GR check 2022-03-08 16:24:40 -06:00
Dan Ramich e25132add2 Add mutation and validation for provisioning clusters 2021-07-01 16:28:18 -06:00
Ryan Sanna 87a2133f12 roletemplate rule validation, disallow empty verbs to avoid issues in rbac controllers 2021-06-18 13:08:30 -07:00
Darren Shepherd 0e8491720f Restructure code 2020-11-09 22:03:39 -07:00
Dan Ramich 44bf156c63 Refactor to match current auth 2020-09-29 20:50:00 -06:00
Dan Ramich 9c9a15aa80 Use caches and disable throttling 2020-09-25 20:10:48 -06:00
Dan Ramich 3d719a033a Add validation for rancher rbac objects
Problem:
Adding the role restricted-admin in rancher requires validation of
objects through diferent means to validate the user doing the action

Solution:
Add webhook validation to GRBs PRTBs and CRTBs.
GRBs: Validation is done to ensure the GRB being created by the user will
not cause escalated privileges so the user creating the GRB must have at
minimum the permissions they are attempting to grant through the GRB

PRTBs and CRTBs: The same check is done for both. First validation is
only done on the local cluster. Then a subject access review is done for
the requester checking that they have '**' access in the local cluster.
2020-09-25 11:31:29 -06:00