Skip to content

Commit

Permalink
nk3 test/fido2: early exit if pin not set - fixes #411
Browse files Browse the repository at this point in the history
  • Loading branch information
daringer committed Sep 20, 2023
1 parent dc48ea4 commit 98f0c85
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions pynitrokey/cli/nk3/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

from pynitrokey.cli.exceptions import CliException
from pynitrokey.fido2 import device_path_to_str
from pynitrokey.fido2.client import NKFido2Client
from pynitrokey.helpers import local_print
from pynitrokey.nk3.admin_app import AdminApp
from pynitrokey.nk3.base import Nitrokey3Base
Expand Down Expand Up @@ -238,6 +239,13 @@ def test_fido2(ctx: TestContext, device: Nitrokey3Base) -> TestResult:
if not isinstance(device, Nitrokey3Device):
return TestResult(TestStatus.SKIPPED)

# drop out early, if pin is needed, but not provided
nk_client = NKFido2Client()
nk_client.find_device(device.device)

if nk_client.has_pin() and not ctx.pin:
return TestResult(TestStatus.FAILURE, "FIDO2 pin is set, but not provided")

# Based on https://github.com/Yubico/python-fido2/blob/142587b3e698ca0e253c78d75758fda635cac51a/examples/credential.py

from fido2.client import Fido2Client, PinRequiredError, UserInteraction
Expand Down

0 comments on commit 98f0c85

Please sign in to comment.