Nitrokey / pynitrokey

Python client for Nitrokey devices
Apache License 2.0
98 stars 27 forks source link

nk3 secrets: Support OTP URIs #369

Open robin-nitrokey opened 1 year ago

robin-nitrokey commented 1 year ago

Many services use OTP URIs to configure OTP devices. It would be useful to be able to directly pass such a URI to pynitrokey instead of having to manually interpret it. As a second step, we could even support parsing QR codes with OTP URIs.

robin-nitrokey commented 1 year ago

Decoding a QR code should be easy to implement with pyzbar. Capturing it from the screen would probably be more complicated.

For reference, here is a Rust implementation of this feature for nitrocli: https://git.ireas.org/nitrocli-otp-qr/tree/src/main.rs

robin-nitrokey commented 1 year ago

Implementation idea: Add a class for the OTP data and add multiple constructors, e. g. from_raw_bytes, from_base32, from_otp_uri. This would have the side effects of moving base32 decoding from the CLI into the library and making the API safer because it is harder to use the wrong encoding.