Skip to content

Commit

Permalink
Resolve StoredCredential.Descriptor at access(?) (#528)
Browse files Browse the repository at this point in the history
* Just resolve the descriptor at runtime

* Missing ;

* Update StoredCredential.cs
  • Loading branch information
abergs authored Jul 16, 2024
1 parent df37692 commit 184f70f
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 5 deletions.
1 change: 0 additions & 1 deletion BlazorWasmDemo/Server/Controllers/UserController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,6 @@ public async Task<string> CreateCredentialAsync([FromRoute] string username, [Fr
{
AttestationFormat = result.Result.AttestationFormat,
Id = result.Result.Id,
Descriptor = new PublicKeyCredentialDescriptor(result.Result.Id),
PublicKey = result.Result.PublicKey,
UserHandle = result.Result.User.Id,
SignCount = result.Result.SignCount,
Expand Down
1 change: 0 additions & 1 deletion Demo/Controller.cs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@ public async Task<JsonResult> MakeCredential([FromBody] AuthenticatorAttestation
DemoStorage.AddCredentialToUser(options.User, new StoredCredential
{
Id = success.Result.Id,
Descriptor = new PublicKeyCredentialDescriptor(success.Result.Id),
PublicKey = success.Result.PublicKey,
UserHandle = success.Result.User.Id,
SignCount = success.Result.SignCount,
Expand Down
2 changes: 1 addition & 1 deletion Demo/TestController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public async Task<JsonResult> MakeCredentialResultTestAsync([FromBody] Authentic
// 3. Store the credentials in db
_demoStorage.AddCredentialToUser(options.User, new StoredCredential
{
Descriptor = new PublicKeyCredentialDescriptor(success.Result.Id),
Id = success.Result.Id,
PublicKey = success.Result.PublicKey,
UserHandle = success.Result.User.Id,
SignCount = success.Result.SignCount
Expand Down
7 changes: 5 additions & 2 deletions Src/Fido2.Development/StoredCredential.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public class StoredCredential
/// <summary>
/// The Credential ID of the public key credential source.
/// </summary>
public byte[] Id { get; set; }
public required byte[] Id { get; set; }

/// <summary>
/// The credential public key of the public key credential source.
Expand Down Expand Up @@ -52,7 +52,10 @@ public class StoredCredential

public byte[] UserId { get; set; }

public PublicKeyCredentialDescriptor Descriptor { get; set; }
/// <summary>
/// Exposes an Descriptor Object for this credential, used as input to the library for certain operations.
/// </summary>
public PublicKeyCredentialDescriptor Descriptor => new(PublicKeyCredentialType.PublicKey, Id, Transports);

public byte[] UserHandle { get; set; }

Expand Down

0 comments on commit 184f70f

Please sign in to comment.