Skip to content

Commit

Permalink
fix: Yubikey functionality with empty password
Browse files Browse the repository at this point in the history
Fixes #25
  • Loading branch information
aripalo committed May 12, 2022
1 parent 6ba4b7c commit ef09ffb
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions internal/yubikey/setup/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ func Setup(options Options, store PasswordStore) error {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()

msg.Debug("🔧", fmt.Sprintf("Yubikey: Device Serial: %s", options.Device))
msg.Debug("🔧", fmt.Sprintf("Yubikey: OATH Account: %s", options.Account))

oathAccounts, err := ykmangoath.New(ctx, options.Device)
if err != nil {
return fmt.Errorf("ykmangoat init: %w", err)
Expand Down Expand Up @@ -135,6 +138,16 @@ func stateMachine(state State, op Operation) State {
}
}
msg.Debug("🔓", "Yubikey: OATH application not password protected")

err := op.SetPassword("")
if err != nil {
msg.Warn("⚠️", fmt.Sprintf("Yubikey: Could not configure empty password: %s", err))
return State{
Name: ERROR,
Error: errors.New("yubikey: could not configure empty password"),
}
}

return State{
Name: CHECK_DEVICE_HAS_ACCOUNT,
}
Expand Down Expand Up @@ -258,6 +271,7 @@ func stateMachine(state State, op Operation) State {
case CHECK_DEVICE_HAS_ACCOUNT:
has, err := op.HasAccount()
if err != nil {
msg.Debug("ℹ️", fmt.Sprintf("Yubikey: Failed to acquire account: %s", err))
return State{
Name: ERROR,
Error: errors.New("yubikey: could not read accounts"),
Expand All @@ -270,6 +284,7 @@ func stateMachine(state State, op Operation) State {
Error: errors.New("yubikey: account not found"),
}
}
msg.Debug("ℹ️", "Yubikey: Account found")
return State{
Name: DONE,
}
Expand Down

0 comments on commit ef09ffb

Please sign in to comment.