Skip to content

Commit

Permalink
Merge branch 'master' into 2025-8
Browse files Browse the repository at this point in the history
  • Loading branch information
virot authored Jan 24, 2025
2 parents fa92b6a + fc5c0bf commit f61f4df
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
7 changes: 3 additions & 4 deletions Docs/Examples/Enroll YubiKey FIDO2 against demo.yubico.com.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
```pwsh
$username = "powershellYK$($(new-guid).tostring().Replace('-',''))"
$password = (get-date -Format 'yyyy-MM-dd')
$site = "demo.yubico.com"
```

### Create the user in the Yubico playground
Expand All @@ -15,13 +14,13 @@ $createUser = @{
'username'=$username;
'password'=$password
} | ConvertTo-JSON
$userCreation = Invoke-RestMethod -Method Post -SessionVariable session -Uri "https://$site/api/v1/user" -Body $createUser -ContentType 'application/json'
$userCreation = Invoke-RestMethod -Method Post -SessionVariable session -Uri "https://demo.yubico.com/api/v1/user" -Body $createUser -ContentType 'application/json'
```

### Lets begin registering the YubiKey
```pwsh
$registerBeginBody = @{'authenticatorAttachment' = 'cross-platform'; 'residentKey' = $true} | ConvertTo-JSON
$registerBeginReturn = Invoke-RestMethod -Method Post -WebSession $session -Uri "https://$site/api/v1/user/$($userCreation.data.uuid)/webauthn/register-begin" -Body $registerBeginBody -ContentType 'application/json'
$registerBeginReturn = Invoke-RestMethod -Method Post -WebSession $session -Uri "https://demo.yubico.com/api/v1/user/$($userCreation.data.uuid)/webauthn/register-begin" -Body $registerBeginBody -ContentType 'application/json'
$userEntity = [Yubico.YubiKey.Fido2.UserEntity]::new([system.convert]::FromBase64String($registerBeginReturn.data.publicKey.user.id.'$base64'))
$userEntity.Name = $registerBeginReturn.data.publicKey.user.name
Expand All @@ -39,7 +38,7 @@ $registerFinishBody = @{
'clientDataJSON' = @{'$base64'=$out.GetBase64clientDataJSON()}
}
} | ConvertTo-JSON -Compress
$registerFinishReturn = Invoke-RestMethod -Method Post -WebSession $session -Uri "https://$site/api/v1/user/$($userCreation.data.uuid)/webauthn/register-finish" -Body $registerFinishBody -ContentType 'application/json'
$registerFinishReturn = Invoke-RestMethod -Method Post -WebSession $session -Uri "https://demo.yubico.com/api/v1/user/$($userCreation.data.uuid)/webauthn/register-finish" -Body $registerFinishBody -ContentType 'application/json'
```

Now you can surf into [Yubikey Demo Site](https://demo.yubico.com/) and logon with your onboarded YubiKey.
Expand Down
8 changes: 3 additions & 5 deletions Module/types/FIDO2/Challenge.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
using Newtonsoft.Json.Linq;
using powershellYK.support;
using System.Management.Automation;
using powershellYK.support;
using Yubico.YubiKey.Cryptography;
using Yubico.YubiKey.Fido2;
using Yubico.YubiKey.Fido2.Cose;


namespace powershellYK.FIDO2
{
Expand Down Expand Up @@ -58,6 +55,7 @@ public static implicit operator string(Challenge source)
#endregion // Operators

#region support

private static byte[] BuildFakeClientDataHash(string relyingPartyId)
{
byte[] idBytes = System.Text.Encoding.Unicode.GetBytes(relyingPartyId);
Expand Down

0 comments on commit f61f4df

Please sign in to comment.