-
Notifications
You must be signed in to change notification settings - Fork 10
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
Add otp-cache extension #146
Conversation
To avoid reimplementing the device selection logic in extensions, we introduce a new environment variable NITROCLI_RESOLVED_USB_PATH that is set to the USB path of the single matching Nitrokey device. If no device matches, or if there are multiple matching devices, the variable is not set.
This patch adds the extension support crate nitrocli-ext as a workspace member. This crate contains useful methods for extensions written in Rust, providing access to the nitrocli binary and to the nitrokey-rs library.
This patch adds the nitrocli-otp-cache extension that caches OTP data. The per-device cache stores the names, OTP algorithms and IDs of the slots It can be used to access the slots by name instead of slot index.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it looks great! Thanks for splitting and reworking the earlier pull request! I may only get to take a final look and be able to merge it later this week (around Thursday or later).
Thanks for the review! I’ll fix the issues and update the PR later today. |
I think I’ve addressed all issues. |
Hi Robin, why do you think we should have a dedicated |
Good point! The cache lookup logic became pretty convoluted so I decided to separate reading and writing the cache. (For example we have to make sure that the |
Sounds good. I vote for integration.
If a computer can tell me precisely what to do most of the time I just want it to do it for me. It was definitely the case for me here. |
I’ve removed the |
Do we want separate man pages for extensions? |
Awesome, thank you!
It's definitely not a priority right now for me. I'd hope we could cover most of it with a some decent help text. I'd rather we think about tests first on the extension front. |
Fantastic work, Robin! Merged into |
This PR is an iteration of PR #144: Add cache extension. It introduces the
NITROCLI_RESOLVED_USB_PATH
environment variable to avoid having to duplicatethe device selection logic, it moves the
ext.rs
module into a new extensionsupport crate,
nitrokey-ext
, and adds the nitrocli-otp-cache extension.