pimalaya / himalaya

CLI to manage emails
https://pimalaya.org
MIT License
3.17k stars 95 forks source link

Support Secret Service #423

Closed ModProg closed 1 year ago

ModProg commented 2 years ago

Secret service is an API usable to access keychains as well as some password managers like KeepassXC etc. through a unified api: https://specifications.freedesktop.org/secret-service/latest/

There is a rust crate to use it: https://lib.rs/crates/secret-service

soywod commented 2 years ago

Sounds a great feature, thanks for the idea!

soywod commented 1 year ago

I gather all Himalaya issues to the same bug tracker, so I transfer your issue here.

soywod commented 1 year ago

Himalaya now supports Secret Service via the keyring crate (only on master branch). For now, it is only used for IMAP password, OAuth 2.0 client secret and OAuth 2.0 access tokens but I plan to use it for everything sensitive. Works great, thank you for the idea!

kj commented 1 year ago

I'm not sure if this is documented anywhere yet, but I had to read through the source code to get this working. So in case it helps anyone else, under Linux you need to store the secret with the attribute service set to pimalaya and the attribute username set to whatever unique name you want to identify the secret with.

To store a secret, something like:

secret-tool store --label='Himalaya (Personal)' service pimalaya username himalaya/personal

-and enter the password when prompted.

Then in your Himalaya config:

imap-auth = 'passwd'
imap-passwd = { keyring = 'himalaya/personal' }
soywod commented 1 year ago

The documentation is not so clear yet, I will work on it. You just need to himalaya account configure: it will ask for your IMAP/SMTP password then store it for you in your global keyring. You don't even need to add imap-passwd.keyring = "himalaya/personal", a default one is generated: {account]-imap-passwd.

kj commented 1 year ago

Ah yes, I just noticed that command after I posted. I still like to configure manually, but good to know the way it's intended. I was curious anyway how the keyring actually works, so it gave me a good opportunity to learn something new. Thanks!