Skip to content

Conversation

@JMarkstrom
Copy link
Collaborator

Added cmlet for setting, changing and removing a slot (ShortPress, LongPress) access code.
Added access code logic to existing OTP cmdlets.
Please review carefully ;)

Copy link
Collaborator Author

@JMarkstrom JMarkstrom left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@virot I think this is more or less gtg now.

{
WriteError(new ErrorRecord(ex, "RemoveYubiKeyOTPError", ErrorCategory.InvalidOperation, null));
}
// if (ex.Message.Contains("YubiKey Operation Failed") && ex.Message.Contains("state of non-volatile memory is unchanged"))
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was commented out because the error is indistinguishable from the error on successful operation (issue #182). I have asked Yubico to prioritize that defect.

// Create a basic HOTP configuration with access code support
var configureHOTP = otpSession.ConfigureHotp(Slot);
var hmacKey = new byte[20];
configureHOTP.UseKey(hmacKey);
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should not be necessary (from testing with Yubico apps) but not sure how to work around it.

// TODO: Implement Upload to YubiCloud
// @virot: upload is no longer supported. Need to output a CSV file for manual upload.
WriteWarning("Upload to YubiCloud is not implemented yet!");
WriteWarning("Upload to YubiCloud functionality has been deprecated by Yubico.");
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Functionality has been removed. Must be done manually via browser now.

///
/// .NOTES
/// Setting or changing the access code will overwrite the selected slot's configuration.
/// This operation cannot be undone and will erase any existing secret or configuration in the slot.
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed this since my latest commit addresses this issue.

@virot
Copy link
Owner

virot commented Jun 30, 2025

Should it be Set-YubiKeySlotAccessCode or Set-YubiKeyOTPSlotAccessCode to align with the other Cmdlets?
Is it possible to read the lockstate? Then we could change the code to be a dynamic parameter, so it will require the code if it is set, otherwise not?

@JMarkstrom
Copy link
Collaborator Author

JMarkstrom commented Jun 30, 2025 via email

Rename Cmdlet YubiKeySlotAccessCode -> YubiKeyOTPSlotAccessCode
@virot virot merged commit 4b1d261 into master Jul 8, 2025
8 of 12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants