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

Fall back to keyutils if secret-service not available in Linux #12

Merged
merged 4 commits into from
Jul 11, 2023

Conversation

Nevon
Copy link
Contributor

@Nevon Nevon commented Jul 7, 2023

When using this library from the context of WSL, where gnome-keyring etc is not available, it fails with a generic error along the lines of:

Platform secure storage failure: zbus error: org.freedesktop.DBus.Error.ServiceUnknown: The name org.freedesktop.secrets was not provided by any .service files

Even after installing gnome-keyring, you still get an error like:

Couldn't access platform secure storage: SS error: result not returned from SS API

Reading the keyring-rs source, it pretty much sounds like using Secret Service from a headless environment is not going to work. Since I'm using this library from the context of a cross-platform CLI, where some of my users are using WSL2, I need a way to use keyutils instead. So I've implemented a custom CredentialBuilder for Linux, that tries to use Secret Service but falls back to keyutils if Secret Service doesn't work, based on this comment

I haven't implemented this same support for the find_credentials functions, as I can't really figure out what it's trying to do or why it isn't using keyring-rs. In my case I'm not using find_credentials, so having at least partial support for headless Linux is enough for me. The tests are passing in WSL2 if I remove the calls to find_credentials and instead test get_password, set_password and delete_password etc.

I'm definitely no rust developer, so let me know if something about this is wonky.

@Nevon
Copy link
Contributor Author

Nevon commented Jul 10, 2023

The lint issue should be fixed, and hopefully the broken freebsd build as well. Could you please approve the workflow run?

@Nevon
Copy link
Contributor Author

Nevon commented Jul 10, 2023

Haha, geez, okay. This time I have faith :D

@Nevon
Copy link
Contributor Author

Nevon commented Jul 11, 2023

All green! I can't press the merge button, so if you would go ahead and merge and release when you have the chance, I would appreciate it. 😃

@Brooooooklyn Brooooooklyn merged commit 4eca987 into Brooooooklyn:main Jul 11, 2023
shantanuraj added a commit to watercooler-labs/toggl-cli that referenced this pull request Sep 6, 2024
- Update keyring package.
- Fallsback to keyutils if secure storage cannot be accessed.
  Usually happens on headless environments or WSL on windows

  Context: Brooooooklyn/keyring-node#12

  Closes #72
shantanuraj added a commit to watercooler-labs/toggl-cli that referenced this pull request Sep 6, 2024
- Update keyring package.
- Fallsback to keyutils if secure storage cannot be accessed.
  Usually happens on headless environments or WSL on windows

  Context: Brooooooklyn/keyring-node#12

  Closes #72
shantanuraj added a commit to watercooler-labs/toggl-cli that referenced this pull request Sep 6, 2024
- Update keyring package.
- Fallsback to keyutils if secure storage cannot be accessed.
  Usually happens on headless environments or WSL on windows

  Context: Brooooooklyn/keyring-node#12

  Closes #72
shantanuraj added a commit to watercooler-labs/toggl-cli that referenced this pull request Sep 6, 2024
* 🎩 Report underlying error when credential write or delete fails

* 🔑 Enable `linux-default-keyutils` feature for keyring

  - Update keyring package.
  - Falls back to keyutils if secure storage cannot be accessed.
    Usually happens on headless environments or WSL on windows

* 🏚️ Fix lint, drop usage of legacy numeric constant

  Context: Brooooooklyn/keyring-node#12

  Closes #72
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.

2 participants