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

Version 0.2 #232

Merged
merged 13 commits into from
Mar 6, 2024
Merged

Version 0.2 #232

merged 13 commits into from
Mar 6, 2024

Conversation

cdecker
Copy link
Collaborator

@cdecker cdecker commented Aug 15, 2023

This is the preparatory branch for the next version of the client bindings. Adding it as a PR to make it more visible here.

@nepet
Copy link
Collaborator

nepet commented Sep 14, 2023

Rebased

@nepet
Copy link
Collaborator

nepet commented Sep 30, 2023

Rebased

@nepet nepet marked this pull request as ready for review September 30, 2023 11:12
@nepet nepet force-pushed the main-0.2 branch 2 times, most recently from 92251ee to 981db7e Compare October 9, 2023 15:55
@nepet nepet force-pushed the main-0.2 branch 2 times, most recently from 8b5a797 to 40c5809 Compare November 5, 2023 19:52
@nepet nepet mentioned this pull request Nov 8, 2023
@cdecker
Copy link
Collaborator Author

cdecker commented Nov 23, 2023

I just pushed all crates and the python package, so we should soon be able to merge this, hopefully without breaking any users due to API changes.

@nepet
Copy link
Collaborator

nepet commented Nov 26, 2023

Rebased

@cdecker
Copy link
Collaborator Author

cdecker commented Jan 8, 2024

Rebased on top of main, prepping all things for the switch to the
new API with the AuthBlob.

@nepet nepet force-pushed the main-0.2 branch 3 times, most recently from 64fd6e1 to 6d16a7d Compare January 11, 2024 16:08
@nepet
Copy link
Collaborator

nepet commented Feb 7, 2024

A commit I added on top of this PR that changed the version numbers from 0.1.x to 0.2.0 resulted in a CI failure withcargo dist plan so I removed it again.

While we could also add this later, it would still be nice to have a version update commit in here that we can point the backend to.

@@ -88,13 +89,13 @@ def export_node(self) -> schedpb.ExportNodeResponse:
res = schedpb.ExportNodeResponse
return res.FromString(bytes(self.inner.export_node()))

def node(self) -> "Node":
def node(self, creds: Credentials) -> "Node":
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We probably want to have Scheduler have a copy of the Credentials, since we will eventually enforce that only an authenticated client can schedule. That would mean that the schedule() call also needs the Credentials, and we could just inherit from Scheduler to Node when creating the Node here.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Let's talk about this during our meeting.

@nepet
Copy link
Collaborator

nepet commented Feb 23, 2024

Added credentials and upgradecreds command to the command line tool.

@cdecker cdecker force-pushed the main-0.2 branch 3 times, most recently from 6f05c18 to 737acd9 Compare March 1, 2024 17:42
nepet added 13 commits March 6, 2024 17:33
Adds a master rune and a credentials byte array to the proto messages
for `register` and `response`.
Sets dummy values for this values in the scheduler. This dummy values
will be replaced by something meaningful in a future commit.

Signed-off-by: Peter Neuroth <[email protected]>
Clippy was complaning about:
- an unnecessary `return` keyword
- a self conversion.

Signed-off-by: Peter Neuroth <[email protected]>
This streamlines the rust and the python api. The python api uses method
called `node` to schedule and return a node from the `Scheduler` class.

BREAKING CHANGES: The `schedule` method (rs) does not return a node
anymore but does insted return the schedule response. A new method
`node` is introduced that returns a node instead.

Signed-off-by: Peter Neuroth <[email protected]>
Adds `Credentials` that store the necessary information for authentication
and authorization. There are two types of credentials: unauthenticated
(also known as 'nobody') and device-specific. The device-specific
credentials can be encoded to be stored on the device. The encoding
allows for future extensions.
Credentials offer flexible ways to be created and restored.

BREAKING CHANGES:
 - Credentials replace the TlsConfig on the `Node`,
 - `Scheduler`(rs and py) method `node` got a `Credentials` parameter.

Signed-off-by: Peter Neuroth <[email protected]>
We need to pass a rune down to the signer for propper authorization in
our e2e security schema.

Signed-off-by: Peter Neuroth <[email protected]>
Introduces runes to the greenlight client. Adds a `create_rune` method
to the signer and adds the rune to the registration and recovery
responses.

Signed-off-by: Peter Neuroth <[email protected]>
Adds the rune to the credentials. This way all the node client can
extract the rune from the credentials for future use.

Signed-off-by: Peter Neuroth <[email protected]>
Add the rune to the request context. The signer extracts the rune from
the PendingRequest and checks the validity as well as the restrictions.

Signed-off-by: Peter Neuroth <[email protected]>
Copy link
Collaborator Author

@cdecker cdecker left a comment

Choose a reason for hiding this comment

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

Excellent changes, I just bikeshedded the Scheduler and TlsConfig builder API a bit, but will merge this now, and we can iterate or leave things are as they are.

from glclient import Scheduler, Credentials, TlsConfig

CRED_RUNE = bytes(
'"\xec\x01q3gAOP3JVkuen3qOh2G3LMU9TbHpXQS2VXfecJmlZY89MC1nbDAmcHVia2V5PTA0OGI0ZWZhNDZkNTZmMmUxM2RmOTdjOGFmNzJiZjYzZWEwNDgzODFlMTdkMTRhOGVkMThlNDVhMzFkNDIzMmNlMzE3OWE4NjE2ZTU2ODUxOTc5MjcxOTZlMTI2YjU0YjhhMmU5NzAwNWJiNzY2YTYzM2M1ODc0M2RjMGU3ZDZhZGY=',
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I got a bit sidetracked by those 2 leading hex-escaped bytes. Why not use base64-encoding here as well?

// Builds the default nobody identity.
let creds = Builder::as_nobody()
.with_default()
.expect("Failed to create default Nobody credentials")
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We can likely determine at compile-time if this call can fail or not (whether or not the nobody credentials were compiled in), so we should make with_default() infallible.


// Access the tls config.
let tls_config = creds.tls_config()
.expect("Failed to create TlsConfig");
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Can we have a Credentials instance that does not have valid TLS certs? And shouldn't that be check during .build()? We could make this infallible here too.

from glclient import Credentials, TlsConfig

# Builds the default nobody identity.
creds = Credentials.as_nobody().with_default().build();
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Why doesn't .as_nobody() load the default TLS certs? It sounds like that ought to be the default behavior.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Unless Credentials.as_nobody() returns a usable Credentials instance on its own, in which case what is the with_default() for?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ah I see, it fails on .build() if we call just as_nobody(), gotcha.

@cdecker cdecker merged commit a148699 into main Mar 6, 2024
18 checks passed
@cdecker cdecker deleted the main-0.2 branch March 6, 2024 17:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants