Skip to content
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

Squash issues #93

Merged
merged 4 commits into from
Dec 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions Module/Cmdlets/Fido/GetYubikeyFIDO2Credentials.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,25 @@ protected override void ProcessRecord()
{
foreach (RelyingParty RelyingParty in RelyingParties)
{
var relayCredentials = fido2Session.EnumerateCredentialsForRelyingParty(RelyingParty);

WriteDebug($"Enumerating credentials for {RelyingParty.Id}.");
IReadOnlyList<CredentialUserInfo> relayCredentials;
try
{
relayCredentials = fido2Session.EnumerateCredentialsForRelyingParty(RelyingParty);
}
catch (NotSupportedException e)
{
WriteWarning($"Failed to enumerate credentials for {RelyingParty.Id}: {e.Message}, SDK might not support algorithm.");
continue;
}
foreach (CredentialUserInfo user in relayCredentials)
{
Credentials credentials = new Credentials
{
Site = RelyingParty.Id,
Name = user.User.Name,
DisplayName = user.User.DisplayName,
coseKey = user.CredentialPublicKey,
};
WriteObject(credentials);
}
Expand Down
11 changes: 9 additions & 2 deletions Module/Cmdlets/Yubikey/ConnectYubikey.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ protected override void ProcessRecord()
if (yubikeys.Count() == 1)
{
_yubikey = (YubiKeyDevice)yubikeys.First();
WriteDebug($"Found only one device, using {_yubikey.SerialNumber}.");
WriteDebug($"Found only one device, using {_yubikey.SerialNumber.ToString() ?? "N/A"}.");
}
break;
case "Connect Yubikey with Serialnumber":
Expand All @@ -56,7 +56,14 @@ protected override void ProcessRecord()
if (_yubikey is not null)
{
YubiKeyModule._yubikey = _yubikey;
WriteInformation($"Connected to {PowershellYKText.FriendlyName(_yubikey)} with serial: {_yubikey.SerialNumber}.", new string[] { "YubiKey" });
if (_yubikey.SerialNumber is not null)
{
WriteInformation($"Connected to {PowershellYKText.FriendlyName(_yubikey)} with serial: {_yubikey.SerialNumber}.", new string[] { "YubiKey" });
}
else
{
WriteInformation($"Connected to {PowershellYKText.FriendlyName(_yubikey)} with serial: N/A.", new string[] { "YubiKey" });
}
}
else
{
Expand Down
14 changes: 13 additions & 1 deletion Module/support/PowershellYKText.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,20 @@ public static string FriendlyName(YubiKeyDevice yubiKeyDevice)
}
if (family == 5)
{
if (isSky)
{
switch (formFactor)
{
case FormFactor.UsbAKeychain:
return "Security Key A by Yubico";
case FormFactor.UsbCKeychain:
return "Security Key C by Yubico";
default:
return "Security Key by Yubico";
}
}
// YubiKey Bio
if (isBio)
else if (isBio)
{
if (isPIV) // Multi-Protocol Edition (AKA "MPE")
{
Expand Down
3 changes: 3 additions & 0 deletions Module/types/FIDO2-Credentials.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using Yubico.YubiKey.Piv;
using System.Management.Automation;
using Yubico.YubiKey.Fido2;
using Yubico.YubiKey.Fido2.Cose;

namespace powershellYK.FIDO2
{
Expand All @@ -12,6 +13,8 @@ public class Credentials
public string? Name { get; set; }
public string? DisplayName { get; set; }
// public CredentialId? CredentialID { get; set; }
[Hidden]
public CoseKey? coseKey { get; set; }

}
}
Loading