-
Notifications
You must be signed in to change notification settings - Fork 8
Support multiple YubiKeys via PIVIT_YK_SERIAL environment variable #61
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
Conversation
Also tweak the contributing guide make command. Yubikey discovery behavior below. Errors when: - no cards are found - multiple cards are found and the serial is not specified - one or more cards are found and the serial does not match any Successfully returns a card when: - only one card is found and the serial is not specified - one or more cards are found and the serial matches Note that this also applies if there are other potential PIV sources attached, such as a smart card reader.
yoavamit
left a comment
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.
Simple and clean!
Please update the README as well
pkg/pivit/pivit.go
Outdated
| continue | ||
| } | ||
|
|
||
| // Get serial number |
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.
supernit: please remove these comments. This code is simple enough that it doesn't need them.
From a readability perspective - I think it only hurts.
pkg/pivit/pivit.go
Outdated
| return nil, fmt.Errorf("invalid serial number format: %v", err) | ||
| } | ||
|
|
||
| // Serial specified - try to find matching card |
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.
same
yoavamit
left a comment
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.
Looks good!
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #61 +/- ##
==========================================
- Coverage 59.15% 57.72% -1.44%
==========================================
Files 10 10
Lines 928 951 +23
==========================================
Hits 549 549
- Misses 312 335 +23
Partials 67 67 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Overview
This change allows users to use
pivitwhile multiple YubiKeys are attached, or just want specificity when interacting with a YubiKey. This also tweaks the contributing guide make command.Errors when:
Successfully returns a card when:
Note that this also applies if there are other potential PIV sources attached, such as a smart card reader.
Changes
YubikeyHandleWithSerial()function.YubikeyHandle()call the new function with backward-compatible behavior.runCommand()to read the serial from the environment and use the new function.Testing
Behavior when one YubiKey is attached:
No YubiKeys:
Multiple yubikeys: