Commit Graph

25 Commits

Author SHA1 Message Date
Francesco Giudici 97db17d73b
make linter happy - update copyright dates (#899)
Signed-off-by: Francesco Giudici <francesco.giudici@suse.com>
2025-01-31 15:33:47 +01:00
Andrea Mazzotti 0839780db8
Sanitize elemental-operator dependencies (#690)
* Update system-upgrade-controller API

Signed-off-by: Andrea Mazzotti <andrea.mazzotti@suse.com>

* Update Fleet API

Signed-off-by: Andrea Mazzotti <andrea.mazzotti@suse.com>

* Sanitize dependencies

Signed-off-by: Andrea Mazzotti <andrea.mazzotti@suse.com>

---------

Signed-off-by: Andrea Mazzotti <andrea.mazzotti@suse.com>
2024-03-20 15:46:51 +01:00
Fredrik Lönnegren da0776b710 Update copyright year (2024)
Signed-off-by: Fredrik Lönnegren <fredrik.lonnegren@suse.com>
2024-01-05 13:14:27 +01:00
Andrea Mazzotti 25abcdc57b
Improve re-registration (#479)
- Added full registration config and statefile path parameters on elemental-register
- Remove support for multiple configuration files
- Added (hardcoded) timer to skip registration updates for 24 hours
- Store emulated TPM seed for future registration updates
- Exit with error code in case of failures (systemd will manage restarts)
- Use virtual filesystem where possible
2023-07-18 15:09:21 +02:00
Francesco Giudici e436a41b36 operator: add plain auth
Signed-off-by: Francesco Giudici <francesco.giudici@suse.com>
2023-05-22 17:40:19 +02:00
Francesco Giudici 1dbb8cd5a5 elemental api: add fields to support plain authentication
Add MachineRegistration Elemental Registration Auth to allow
selection of the authentication method.
Add MachineInventory MachineHash key for authentication types different than
TPM (which has its own TPMHash key).

make generate
make build-manifests
2023-05-22 17:40:19 +02:00
Fredrik Lönnegren fe8f53f2d2 Unify logging
Use klog for all logging and remove logrus.

Signed-off-by: Fredrik Lönnegren <fredrik.lonnegren@suse.com>
2023-02-22 18:43:48 +01:00
Francesco Giudici 46512dffc7
register client: isolate TPM auth code (#346)
* register client: aggregate args to the Register function

Since we basically pass almost all the Registration struct parameters
one by one, let's pass a reference to the structure directly.

* register client: introduce authClient interface

The register client code is tightly coupled with TPM attestation.
While this is not a problem right now as we just support authentication
through TPM, it may be good to better separate TPM attestation from the
registration process itself for two reasons:
- better code readibility
- support of alternative authentication methods

Note that on the operator side (register "server") the code is already
structured to allow alternative authentication methods.
This commit introduces an interface with the required authentication
methods: the TPM related code in now completely isolated in the interface
implementation.

Signed-off-by: Francesco Giudici <francesco.giudici@suse.com>
2023-02-07 17:46:32 +01:00
Francesco Giudici b489184ae5
operator: fix MachineInventory search during registration (#342)
Signed-off-by: Francesco Giudici <francesco.giudici@suse.com>
2023-01-24 18:44:26 +01:00
Fredrik Lönnegren b9d1c82976
Copyright date-range 2022 - 2023 (#327)
Signed-off-by: Fredrik Lönnegren <fredrik.lonnegren@suse.com>

Signed-off-by: Fredrik Lönnegren <fredrik.lonnegren@suse.com>
2023-01-13 10:30:48 +01:00
Francesco Giudici e60da05e35 [controller_runtime] operator/registration: switch to Kubebuilder client (#256)
* operator/registration: switch to Kubebuilder client

Fixes #239

Signed-off-by: Francesco Giudici <francesco.giudici@suse.com>

* operator/registration: adapt tests to Kubebuilder client

Signed-off-by: Francesco Giudici <francesco.giudici@suse.com>

* unit-tests: vendor controller-runtime fake client

Signed-off-by: Francesco Giudici <francesco.giudici@suse.com>

* operator: add yaml annotations for correct marshalling

Signed-off-by: Francesco Giudici <francesco.giudici@suse.com>

* operator/RBAC: add "get" verb to ServiceAccount resources

Signed-off-by: Francesco Giudici <francesco.giudici@suse.com>

* operator: generate rbac

make generate-manifests
make build-rbac

Signed-off-by: Francesco Giudici <francesco.giudici@suse.com>

* Add elementalcli package

Create a separate package to deal with elemental-cli installation.
This brings the elemental-cli functions declared in the config package
to a new package that just parses a map[string]interface argument.

This is a step to enable usage of the elemental-cli functions with the
new elementalv1.Config.Elemental.Install type.

Signed-off-by: Francesco Giudici <francesco.giudici@suse.com>

* register: switch to Kubebuilder api

Signed-off-by: Francesco Giudici <francesco.giudici@suse.com>

* register: add mapstructure annotations for correct marshalling

Signed-off-by: Francesco Giudici <francesco.giudici@suse.com>

* register: reduce complexity of the run function

Make linter happy:
"cyclomatic complexity 16 of func `run` is high (> 15) (gocyclo)"

Signed-off-by: Francesco Giudici <francesco.giudici@suse.com>

* register: drop io/ioutil in favor of os package

io/ioutil is deprecated

Signed-off-by: Francesco Giudici <francesco.giudici@suse.com>

Signed-off-by: Francesco Giudici <francesco.giudici@suse.com>
2022-12-12 12:15:22 +01:00
Itxaka 4fab515a30
Rework client to accept a ClientInterface (#166) 2022-09-07 10:39:26 +02:00
Francesco Giudici 4ce5d77900 register: take control of the registration process
Till now, the attestation and communication with the elemental operator
were all demanded to the github.com/rancher-sandbox/go-tpm package.
Split TPM attestation from the communication with the elemental operator
demanding TPM authentication to the external library while taking full
control of the communication with the operator.

This doesn't introduce functional changes (so it will keep retrocompatibility
with the current elemental operator) and is a preparatory step to address
rancher/elemental-operator#5

Signed-off-by: Francesco Giudici <francesco.giudici@suse.com>
2022-08-31 16:09:20 +02:00
Francesco Giudici 2b646ff145 operator: move websocket management logic out of the tpm package
Till now the TPM package was in charge to upgrade the HTTP connection
and manage the websocket one.
Move the connection management to the server package to split connection
management from TPM authentication.
This will allow us later to pass the smbios data and the labels through
the channel instead of abusing HTTP headers.

Signed-off-by: Francesco Giudici <francesco.giudici@suse.com>
2022-08-31 15:31:03 +02:00
Francesco Giudici a99c6c38a9 operator/http: check websocket upgrade header in HTTP connections
If the websocket upgrade header is missing, the client is likely a plain
HTTP one, so let's return immediately the unauthenticated reply.

Add a couple of debug logs to semplify debugging when needed.

Signed-off-by: Francesco Giudici <francesco.giudici@suse.com>
2022-08-31 15:31:03 +02:00
Itxaka f170a1aa62
Split header into 7Kb of data (#133)
This generates several X-Cattle-Smbios-NUMER headers when sending the
data to the operator in order to limit the max size of each individual
header to 7Kb. By default nginx is configured with a max of 8Kb header
and will return a 400 error if the headers excess that size.

As we currently use a GET+Websocket to go trougth the challenge/response
of TPM, this is the easiest implementation to workaround the issue.

Signed-off-by: Itxaka <igarcia@suse.com>

Signed-off-by: Itxaka <igarcia@suse.com>
2022-08-11 14:46:04 +02:00
Francesco Giudici ea618ea36c elemental-operator register: keep system CAs when passing a custom CA
When we pass a CACert we enfore the certificate we get from the Register.URL
to be signed by the passed CACert: let's keep also the System CAs in the pool
of allowed CAs in order to accept also imported certificates signed by public
trusted CAs.

Signed-off-by: Francesco Giudici <francesco.giudici@suse.com>
2022-07-22 18:25:10 +02:00
Itxaka adfff7c91a
Some register fixes (#40)
* Some register fixes

 - Add debug flag for debug loggin
 - Add docs to command
 - Add docs to flags
 - Pass the cacert via a file, NOT via string
 - Rename var config so it doesnt clash with imported package name

Signed-off-by: Itxaka <igarcia@suse.com>
2022-07-13 17:05:19 +00:00
Itxaka 5c5f1150cb Fix all the test, remove leftovers from transition
Remove all the mentions to rancheros-operator in tests, imports and
dependencies.

Restore e2e scripts and test targets on makefile

Fix all lint issues

Signed-off-by: Itxaka <igarcia@suse.com>
2022-07-11 15:12:19 +02:00
Jacob Payne c5a5dbd77f renamed to elemental-operator and switched to system agent 2022-06-30 16:01:13 +00:00
Itxaka 26684d1888 Drop everything not needed for ros-operator
- Drops everything not needed for ros-operator
 - New simple Dockerfile
 - New jobs based on ros-operator only
 - Remove uneeded tests
 - Remove dependency on os2 images for integration tests
 - Use gorelease to release ros-operator binaries
 - Use docker to push ci images to ros-operator-ci registry on PR
 - Use docker to push master/tag images to ros-operator registry
 - Build chart indepently
 - Have a null test CI job for future integration tests

Signed-off-by: Itxaka <igarcia@suse.com>
2022-03-24 09:47:18 +01:00
Itxaka 9fed2edefc
Rework golangci-lint config and github CI (#34) 2022-03-03 09:16:03 +01:00
Ettore Di Giacinto 6d9449824a
Consume go-tpm in place of tpm in rancherd/os2
Part of #20. Will allow later on to set an emulated device.

Signed-off-by: Ettore Di Giacinto <edigiacinto@suse.com>
2022-02-17 14:41:32 +01:00
Ettore Di Giacinto 97d58074ee
Refactor import paths
See: https://github.com/rancher-sandbox/cOS-toolkit/issues/1105

Signed-off-by: Ettore Di Giacinto <edigiacinto@suse.com>
2022-01-28 14:00:29 +01:00
Darren Shepherd 901973e5f6 Add TPM and MachineRegister support 2021-10-29 23:08:26 -07:00