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

Adding IsAvailable to the interface #27

Open
snorberhuis opened this issue Mar 6, 2018 · 3 comments
Open

Adding IsAvailable to the interface #27

snorberhuis opened this issue Mar 6, 2018 · 3 comments

Comments

@snorberhuis
Copy link

I am integrating this library in a project of mine and I am running into the issue that I want to bypass caching if it is not available locally.

A method added to the interface would be helpful. The method IsAvailable would check if the service is available. I looked at the source and saw that it might have been already tried to add a function like IsAvailable. I see a commented out function:

// func (*MacOSXKeychain) IsAvailable() bool {
// 	return exec.Command(execPathKeychain).Run() != exec.ErrNotFound
// }

Before I go into developing this more deeply, I was wondering if you tried to adding this method and have come into fundamental problems that prevent implementation.

We can also discuss if this is a good feature to be merged upstream into this library.

@mikkeloscar
Copy link
Member

Hi, I completely lost track of this issue, sorry about that!

There is already this special error: https://github.com/zalando/go-keyring/blob/master/keyring_darwin.go#L43 returned from Get() so you can just check if this error is returned and handle the is-not-available case.

@pjcdawkins
Copy link

err = ErrNotFound

ErrNotFound merely indicates that the secret was not found. You'd get that error when you just hadn't yet stored a secret.

I am (and I think the OP is) looking for a method that checks for security/dbus/libsecret/etc. being available, so external code can find a fallback to store secrets via another library or other behavior.

Alternatively a different special error should be returned in that case. Perhaps it could reuse or wrap the ErrUnsupportedPlatform error, because it's pretty much the same problem. I think that would work just as well as the method.

@erdaltsksn
Copy link
Contributor

erdaltsksn commented Jul 13, 2022

I am (and I think the OP is) looking for a method that checks for security/dbus/libsecret/etc. being available, so external code can find a fallback to store secrets via another library or other behavior.

A fallback solution can be beneficial. A hashed file can be a simple solution for this. There is already a fallback provider. We just need to implement a file solution for it. Happy to work on it if it is okay for maintainers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants