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

Allow use of both linux-native and secret-service keystores. #215

Merged
merged 4 commits into from
Oct 12, 2024

Conversation

brotskydotcom
Copy link
Collaborator

Using both will make the mock keystore be the default, so clients will have to use new_with_credential to wrap their platform-specific credentials.

Fixes #214.

Using both will make the mock keystore be the default, so clients will have to use `new_with_credential` to wrap their platform-specific credentials.

Fixes hwchen#214.
src/lib.rs Outdated
feature = "sync-secret-service",
feature = "async-secret-service"
))
any(
Copy link
Contributor

Choose a reason for hiding this comment

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

This condition illustrates well what I tried to explain here: #214 (comment).

It just looks wrong and messy. Also not sustainable: how will it look like in few years, with other new keystores?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thanks for the review. I agree this is messy. Unfortunately, in my experience, dealing with edge cases is always messy, and (as I explain further in #214) having more than one keystore enabled on a given platform is a fairly rare edge case. Using features to specify a single (default) keystore per platform allows the vast majority of clients to write platform-independent code.

As to the question about what this will look like if we integrate a whole bunch of new keystores on one platform, I'm not particularly concerned that's going to happen. The only reason the keyutils platform was integrated in the first place was to allow using this crate on headless Linux boxes where the SecretStore is generally not available.

Hope this helps explain my reasoning.

Copy link
Contributor

Choose a reason for hiding this comment

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

The only reason the keyutils platform was integrated in the first place was to allow using this crate on headless Linux boxes where the SecretStore is generally not available.

Could you explain a bit more, or give an example? I am not sure to understand.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The secret service relies on the system to prompt users out of band with their current process, whenever it encounters a locked item or collection. Headless linux installs don't support this, so secret-service can only be used by unlocking the default collection when starting the service (see the docs in the secret-service module for more about this).

Because @landhb and I wanted to have a default keystore available on headless Linux boxes, he contributed and I integrated the keyutils implementation. There was never any expectation that the both would be used at the same time, because if the secret service can be used there's no reason to use the keyutils.

Copy link
Contributor

Choose a reason for hiding this comment

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

Understood, thanks for the details. From the keyutils inline doc:

Consider the keyring a secure cache and plan for your application to handle cases where the entry is no-longer available in-memory.

For this particular (and unique) case, having both the keyutils and secret service makes sense (hence #222), right?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Absolutely! See my review comments on #222, which I think would be a terrific addition to this crate (done as a separate "combo" keystore rather than as a modification of the existing keystore).

@soywod
Copy link
Contributor

soywod commented Oct 11, 2024

I propose a lighter version in #220.

1. If both secret-service and linux-native are available, prefer secret-service.
2. Document why both secret-service and keyutils are available on linux.
3. Add CI test for both feature linux-native and feature sync-secret-service.
@brotskydotcom
Copy link
Collaborator Author

Based on discussion in various issues, this PR now makes secret-service the default if both it and keyutils are enabled.

@soywod
Copy link
Contributor

soywod commented Oct 12, 2024

Looks great, I guess it can be merged!

@brotskydotcom brotskydotcom merged commit 900fd68 into hwchen:master Oct 12, 2024
13 checks passed
@brotskydotcom brotskydotcom deleted the issue-214 branch October 12, 2024 21:12
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.

Invalid compile_error condition
2 participants