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

Implementation of the NSS client in Rust #29

Merged
merged 3 commits into from
Sep 20, 2023
Merged

Conversation

denisonbarbosa
Copy link
Member

This adds the Rust code that will act as our NSS client, along with the implementation of the NSS service definition and messages in the proto files and a static implementation for the NSS server (so we could test the output on the Rust side).

UDENG-749

@denisonbarbosa denisonbarbosa requested a review from a team as a code owner September 7, 2023 14:53
@denisonbarbosa denisonbarbosa marked this pull request as draft September 7, 2023 14:53
@denisonbarbosa denisonbarbosa removed the request for review from a team September 7, 2023 14:53
Copy link
Member

@didrocks didrocks left a comment

Choose a reason for hiding this comment

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

Excellent draft! I think there are some questions to really ask ourself, in particular around keeping the client connection alive as we saw that processes makes a lot of calls. Otherwise, this is a good start :)

See my comments inline.

internal/services/nss/nss.go Outdated Show resolved Hide resolved
nss/Cargo.toml Outdated Show resolved Hide resolved
nss/build.rs Show resolved Hide resolved
generate.go Outdated Show resolved Hide resolved
nss/src/group/mod.rs Outdated Show resolved Hide resolved
Ok(r) => Response::Success(group_entries_to_groups(r.into_inner().entries)),
Err(e) => {
error!("error when listing groups: {}", e);
Response::NotFound
Copy link
Member

Choose a reason for hiding this comment

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

Are we sure this is the correct error for all error cases?

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh, I'm definitely sure it isn't 😂 This is a "temporary" thing, as we can only return a static user from the server or an error (which would be a NotFound one). I wanted to go back to this once we had a proper NSS server (after the cache implementation) so I could understand better what I should be parsing from the Error to define the return value.

Looking at aad-auth, it looks like the most common response is Unavail but, again, I need the cache implementation to understand what I should be parsing in the error message.

nss/src/client/mod.rs Outdated Show resolved Hide resolved
nss/src/main.rs Outdated

const SOCKET_PATH: &str = "/run/authd.sock";

// This main function is only used for manual testing without the need to link the NSS library and should be removed before the release
Copy link
Member

Choose a reason for hiding this comment

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

ack then :) Probably add a TODO so that it’s clearly marked as such

@denisonbarbosa denisonbarbosa force-pushed the impl-nss-client branch 2 times, most recently from ce57770 to c56896e Compare September 14, 2023 14:41
nss/src/client/mod.rs Outdated Show resolved Hide resolved
@denisonbarbosa denisonbarbosa marked this pull request as ready for review September 15, 2023 14:33
Copy link
Member

@didrocks didrocks left a comment

Choose a reason for hiding this comment

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

Rust is back to our project :)

I think this PR is the opportunity to hook it back in term of testing with our CI (I don’t think we should merge without basic quality checks). Also, see some of the comments around returned error values and so on.

nss/src/client/mod.rs Outdated Show resolved Hide resolved
nss/src/group/mod.rs Outdated Show resolved Hide resolved
nss/src/passwd/mod.rs Show resolved Hide resolved
Copy link
Member

@didrocks didrocks left a comment

Choose a reason for hiding this comment

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

One last thing I will let you change before merging them! Nice work :)

nss/src/lib.rs Outdated Show resolved Hide resolved
Copy link
Contributor

@GabrielNagy GabrielNagy left a comment

Choose a reason for hiding this comment

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

Awesome work!

@denisonbarbosa denisonbarbosa merged commit 35c9928 into main Sep 20, 2023
5 checks passed
@denisonbarbosa denisonbarbosa deleted the impl-nss-client branch September 20, 2023 11:04
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