Skip to content

Commit

Permalink
Merge pull request #165 from openlawlibrary/renatav/check-pin
Browse files Browse the repository at this point in the history
Added a command for checking validity of  inserted Yubikey's pin
  • Loading branch information
Vlasterx authored Mar 31, 2021
2 parents 599cd72 + 8277423 commit c68939a
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@ and this project adheres to [Semantic Versioning][semver].

### Added

- Added a command for checking validity of the inserted YubiKey's pin ([165])
- Raise an error if there are additional commits newer than the last authenticated commit if the updater is called with the check-authenticated flag ([161])
- Added initial worktrees support to the updater ([161])
- Added support for specifying location of the conf directory ([161])
- Added a function for disabling fie logging ([161])

### Changed

- Replaced authenticate-test-repo flag with an enum ([161])
Expand All @@ -22,6 +24,7 @@ and this project adheres to [Semantic Versioning][semver].
- Minor validation command fix ([161])


[165]: https://github.com/openlawlibrary/taf/pull/165
[161]: https://github.com/openlawlibrary/taf/pull/161


Expand Down
20 changes: 20 additions & 0 deletions taf/tools/yubikey/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import click
import json
import taf.developer_tool as developer_tool
from taf.yubikey import is_valid_pin
from taf.exceptions import YubikeyError


def attach_to_group(group):
Expand All @@ -8,6 +11,23 @@ def attach_to_group(group):
def yubikey():
pass

@yubikey.command()
@click.argument("pin")
def check_pin(pin):
"""Checks if the specified pin is valid"""
try:
valid, retries = is_valid_pin(pin)
inserted = True
except YubikeyError:
valid = False
inserted = False
retries = None
print(json.dumps({
"pin": valid,
"retries": retries,
"inserted": inserted
}))

@yubikey.command()
@click.option("--output", help="File to which the exported public key will be written. "
"The result will be written to the console if path is not specified")
Expand Down

0 comments on commit c68939a

Please sign in to comment.