Commit Graph

92 Commits

Author SHA1 Message Date
Mary 49c06c746e
removing tls environment var (#1151)
* removing var

* fixing unused variable - CI failure
2025-10-30 17:46:37 -03:00
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
Mary cefc4a0c0f
48484 bug webhook error msg (#1046)
* new env variable IGNORE_TLS_HANDSHAKE_ERROR

* bump dynamiclistener v0.7.1-rc1
2025-09-09 16:48:02 -03:00
Raul Cabello Martin 97b8962de8
validate password for local users (#1015)
- hash password
- check username does not exists
- user can't delete himself
- user can't deactivate himself
2025-08-11 18:00:16 +02:00
Josh Meranda e1e25ee742
[main] register AuditPolicy webhook validation handler (#961)
* register AuditPolicy webhook validation handler

* satisfy golangci-lint

---------

Co-authored-by: joshmeranda <joshua.meranda@gmail.com>
2025-07-01 17:47:13 -04:00
Jonathan Crowther cdbe1c198c
Use backing namespace for projects (#869)
* Use backing namespace for projects

* Move to caches in project mutator

* Fix error message

* Switch client names to cache
2025-04-09 12:38:58 -04:00
Jonathan Crowther 2618ee01f1
Add new User validation webhook (#786)
* Add new User validation

* Fix linter errors
2025-03-10 12:01:31 -04:00
Peter Matseykanets c61e597ef5
Validate LDAP/AD authconfigs (#682)
https://github.com/rancher/rancher/issues/48071
2025-02-24 13:37:28 -05:00
Harrison a7fb974ea6
cluster agent pdb and pc validation (#702) 2025-02-21 10:06:14 -05:00
Jack Luo a948ce4ffe
Support for Version Management on Imported RKE2/K3s Clusters (#669) 2025-02-18 14:37:30 -07:00
Jonathan Crowther 80672e48bc
[0.6] Revert backing namespace changes (#539)
* Revert "[0.6] Make sure to update the name in the mutator (#535)"

This reverts commit 7e0627b265.

* Revert "[v0.6] Populate backing namespace field for projects (#532)"

This reverts commit b17444735b.
2024-11-05 09:54:39 -05:00
Jonathan Crowther b17444735b
[v0.6] Populate backing namespace field for projects (#532)
* Populate backing namespace field for projects

* Address comments
2024-10-30 13:41:38 -04: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
Peter Matseykanets 7faaa6262b
Validate LastUsedAt for Token and ClusterAuthToken (#520)
Ref: https://github.com/rancher/rancher/issues/45732
2024-10-09 09:36:46 -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
Eric Promislow 0ca113673c
Display error output from dynamiclistener.Server (#494) 2024-09-09 15:28:22 -07:00
Peter Matseykanets 46f1698b49
Check that {disable|delete}-inactive-user-after setting is not less than auth-user-session-ttl-minutes (#471)
Ref: https://github.com/rancher/rancher/issues/46648
2024-09-09 15:24:39 -04:00
Sakala Venkata Krishna Rohit 40e8eae329
Add validation for ClusterRepo (#470)
* Add clusterrepo validations

* Add docs

* unit tests
2024-08-12 14:03:54 -04:00
Peter Matseykanets ae4cc3b8a2
[main] Use the proper config when fetching mutating webhook configuration (#460)
Forwardport of #451
2024-08-03 17:14:30 -04:00
Max Sokolovsky 5fa648def0
Add a check for the agent-tls-mode setting (#416) 2024-07-05 13:02:42 -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
Peter Matseykanets b3bccd2707
[v0.5] s4: Fixes 227 (#404)
* Validate user retention userattribute fields and settings (#90)
* [v0.4.s4] Don't allow empty lastLogin user attribute (#97)
2024-06-18 07:26:38 -04:00
Chad Roberts 8e3d96998f
Add validator for clusterproxyconfigs to make sure only one is ever created for a given cluster (#327)
* Add validator for clusterproxyconfigs to make sure only one is ever created for a given cluster
* Add integration test for clusterProxyConfigs
2024-04-03 12:02:30 -04:00
Tom Lebreux 49160dee86
Add support for k8s 1.28 (#341) 2024-03-27 16:56:34 -04:00
Tom Lebreux 128b387a3c
Remove CAPI webhook (#338) 2024-03-19 13:24:29 -04:00
Jonathan Crowther b18c38740a
Add webhook checks for NamespacedRules (#309)
* Add role and rolebinding webhook validation. Add NamespacedRules escalation checks for GlobalRoles

* Update rancher/pkg/apis

* Fix linting issue

* Log error and add test for it
2024-01-15 17:17:15 -05:00
Jake Hyde 38fc07916e
Revert "Merge pull request #277 from thatmidwesterncoder/bugfix_nodedriver_validation"
This reverts commit 3ed3c68118, reversing
changes made to ddb05820d4.
2023-11-28 17:31:44 -05:00
Michael Bolot 75cf0e58ca Adding support for bind verb to globalRoles
Adds support for the bind verb on globalRoles, which follows upstream
behavior and allows users to create/update a binding to a globalRole
that has >= permissions than their own.
2023-10-03 09:35:14 -05:00
Michael Bolot ffba7246e8 Adding support for "escalate" for globalRoles
Adds support for the escalate verb, like upstream, when checking for
escalation in global roles. This will allow users to change a global
role even if they don't have >= permissions of the target role
2023-10-03 09:22:36 -05:00
Michael Bolot 9692e02704 Revert "Adding SA exceptions to gr escalation"
This reverts commit fc3f4d171c.
2023-10-02 10:45:44 -05:00
Michael Bolot afd79ef81f
Merge pull request #298 from MbolotSuse/gr-inherited-roles-sa-allow
Adding SA exceptions to gr escalation
2023-09-29 11:42:27 -05:00
Michael Bolot fc3f4d171c Adding SA exceptions to gr escalation
Adds an exception for the fleet/backup-restore for the
inheritedClusterRoles escalation check
2023-09-28 12:25:47 -05:00
Michael Bolot 749b8bd5fc Adding clusterName validation to crtbs
Adds a check to ensure the cluster referred to by clusterName exists
2023-09-25 13:56:35 -05:00
Michael Bolot 707f7876c7 Adding validation for cluster/projectName for prtb
Adds validation on clusterName and projectName for prtbs to make sure
they refer to existing projects/clusters and that the project refers to
the cluster in the spec
2023-09-25 13:56:30 -05:00
Michael Bolot 9d4951c711 Adding validation for clusterName to projects
Adds validation for the clusterName field for projects, and fixes and
unrelated error where error messages for globalRoleBindings indicated
their own name as the missing resource instead of the target GlobalRole
2023-09-22 16:35:31 -05:00
Kevin Joiner 8a45bf3f41 Adds startup error. 2023-09-19 10:18:56 -04:00
Jacob Lindgren 3ed3c68118
Merge pull request #277 from thatmidwesterncoder/bugfix_nodedriver_validation
Fix NodeDriver validation to ensure uniqueness + prevent race condition of CRD creation
2023-09-12 11:12:14 -05:00
Kevin Joiner 0f4e9854e8 Migrates GlobalRoles and GlobalRoleBinding.
Migrates Noramn validation done on GlobalRoles and GlobalRoleBinding
in Rancher to the webhook.
2023-09-08 12:59:35 -04: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
Michael Bolot 7766409968 Adding validation for grb owner label immutability
Adds validation on the grb owner label, allowing crtbs with this label
to use locked roleTemplates, and prventing users from changing this
value or setting it to an invalid grb
2023-09-01 09:24:07 -05:00
Jacob Lindgren 8c27e64811
Check that a CRD exists before trying to list them when disabling NodeDriver 2023-08-29 11:21:45 -05:00
Colleen Murphy c73171eed6
Merge pull request #273 from cmurphy/harden-api
Add cert-based API server authentication
2023-08-18 08:58:15 -07:00
Colleen Murphy 6c1ad78326 Refactor project quota validator
Refactor code that was largely copied from the norman store in Rancher:

- rename variables and functions for clarity
- break up functions into logical units
- rename imports according to standard conventions and for clarity
- remove the ephemeral updates to the used quota object,
  quotav1.LessThanOrEqual already does not compare resources that aren't
  present in both objects[1]
- remove project mutex. Only one goroutine (the webhook) should be
  accessing the project and its namespaces. Callers (rancher/rancher)
  should implement their own lock before counting namespaces.
- remove default namespace quota check, which is not useful since it
  does not have any impact on existing namespaces

[1] d2172f30e1/pkg/quota/v1/resources.go (L50-L62)
2023-08-17 13:48:32 -07:00
Colleen Murphy 16d548f8b9 Add validation and mutation for Projects
New validations:
- prohibit deleting the system project
- check that quota fields are consistent with one another and sufficient
  for existing quota usage

New mutations:
- adds creator-role-bindings annotation
2023-08-16 12:13:21 -07:00
Colleen Murphy c10f608e13 Add cert-based API server authentication
Add the ability to authenticate incoming requests, verifying that all
requests originate from the Kubernetes API server and no where else.

Authenticating the API server requires manual steps to configure both
the API server and the webhook. Follow the Kubernetes webhook
documentation[1] to create an admission configuration and kubeconfig for
the API server, and update the kube-apiserver flags to use them. Only
cert-based authentication is supported, basic auth and token
authentication will not be recognized. Then, set auth.clientCA in the
webhook chart's values.yaml to the base64-encoded CA for the certs, and
set auth.allowedCNs to the CN for the client cert the apiserver will
present.

[1] https://kubernetes.io/docs/reference/access-authn-authz/extensible-admission-controllers/#authenticate-apiservers
2023-08-15 09:55:59 -07:00
Kevin Joiner 851f4cbdf6 Adds the ability to set custom ports for Webhook.
This commit also adds helm unittest and updates integration-test to run
K3s without Rancher.
2023-07-19 16:24:44 -04:00
Jacob Lindgren 0a8256b1d0 Add Validation on NodeDriver update/delete to prevent machine deletion 2023-06-30 12:12:00 -05:00