Skip to content

Commit c7d64cc

Browse files
author
Joshua Coffey
authored
Add support for largeBlob extension (#508)
* Add `largeBlob` support * `dotnet format`
1 parent b0bb79d commit c7d64cc

5 files changed

+143
-0
lines changed

Src/Fido2.Models/Objects/AuthenticationExtensionsClientInputs.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,14 @@ public sealed class AuthenticationExtensionsClientInputs
6262
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
6363
public AuthenticationExtensionsPRFInputs? PRF { get; set; }
6464

65+
/// <summary>
66+
/// This client registration extension and authentication extension allows a Relying Party to store opaque data associated with a credential.
67+
/// https://w3c.github.io/webauthn/#sctn-large-blob-extension
68+
/// </summary>
69+
[JsonPropertyName("largeBlob")]
70+
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
71+
public AuthenticationExtensionsLargeBlobInputs? LargeBlob { get; set; }
72+
6573
/// <summary>
6674
/// This registration extension allows relying parties to specify a credential protection policy when creating a credential.
6775
/// Additionally, authenticators MAY choose to establish a default credential protection policy greater than <c>UserVerificationOptional</c> (the lowest level)

Src/Fido2.Models/Objects/AuthenticationExtensionsClientOutputs.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,13 @@ public class AuthenticationExtensionsClientOutputs
5959
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
6060
public AuthenticationExtensionsPRFOutputs? PRF { get; set; }
6161

62+
/// <summary>
63+
/// This client registration extension and authentication extension allows a Relying Party to store opaque data associated with a credential.
64+
/// https://w3c.github.io/webauthn/#sctn-large-blob-extension
65+
/// </summary>
66+
[JsonPropertyName("largeBlob")]
67+
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
68+
public AuthenticationExtensionsLargeBlobOutputs? LargeBlob { get; set; }
6269

6370
/// <summary>
6471
/// The <c>CredentialProtectionPolicy</c> stored alongside the created credential
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
#nullable enable
2+
using System.Text.Json.Serialization;
3+
4+
namespace Fido2NetLib.Objects;
5+
6+
/// <summary>
7+
/// Input values for the largeBlob extension.
8+
///
9+
/// Note: If a value is specified for <see cref="Write"/>, and the assertion is intended to be invoked on a web browser,
10+
/// additional transformation must be performed on the client side before calling navigator.credentials.get().
11+
/// Specifically, the value must be converted from a base64url-encoded string to a Uint8Array.
12+
///
13+
/// https://w3c.github.io/webauthn/#dictdef-authenticationextensionslargeblobinputs
14+
/// </summary>
15+
public sealed class AuthenticationExtensionsLargeBlobInputs
16+
{
17+
/// <summary>
18+
/// Requests that the credential be created with largeBlob support.
19+
///
20+
/// A value of <c>Required</c> will cause credential creation to fail on the client side if largeBlob support is not available.
21+
/// A value of <c>Preferred</c> will allow credential creation to succeed even if largeBlob support is not available.
22+
///
23+
/// Valid only during registration.
24+
///
25+
/// https://w3c.github.io/webauthn/#dom-authenticationextensionslargeblobinputs-support
26+
/// </summary>
27+
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
28+
[JsonPropertyName("support")]
29+
public LargeBlobSupport? Support { get; set; }
30+
31+
/// <summary>
32+
/// Whether or not to read from the blob.
33+
///
34+
/// Cannot be used in combination with <see cref="Write"/>.
35+
///
36+
/// Valid only during assertion.
37+
///
38+
/// https://w3c.github.io/webauthn/#dom-authenticationextensionslargeblobinputs-read
39+
/// </summary>
40+
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
41+
[JsonPropertyName("read")]
42+
public bool Read { get; set; }
43+
44+
/// <summary>
45+
/// A blob to write to the authenticator.
46+
///
47+
/// Cannot be used in combination with <see cref="Read"/>.
48+
///
49+
/// Valid only during assertion.
50+
///
51+
/// https://w3c.github.io/webauthn/#dom-authenticationextensionslargeblobinputs-write
52+
/// </summary>
53+
[JsonConverter(typeof(Base64UrlConverter))]
54+
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
55+
[JsonPropertyName("write")]
56+
public byte[]? Write { get; set; }
57+
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#nullable enable
2+
using System.Text.Json.Serialization;
3+
4+
namespace Fido2NetLib.Objects;
5+
6+
/// <summary>
7+
/// Output values for the largeBlob extension.
8+
///
9+
/// Note: If the assertion is intended to be run on a web browser, additional transformation must be performed
10+
/// on the client extension output on the browser side after calling navigator.credentials.get(). Specifically,
11+
/// the value of <c>largeBlob.blob</c> must be converted from a Uint8Array to a base64url-encoded string.
12+
///
13+
/// https://w3c.github.io/webauthn/#dictdef-authenticationextensionslargebloboutputs
14+
/// </summary>
15+
public sealed class AuthenticationExtensionsLargeBlobOutputs
16+
{
17+
/// <summary>
18+
/// Whether or not the credential was created with largeBlob support.
19+
///
20+
/// Valid only during registration.
21+
///
22+
/// https://w3c.github.io/webauthn/#dom-authenticationextensionslargebloboutputs-supported
23+
/// </summary>
24+
[JsonPropertyName("supported")]
25+
public bool Supported { get; set; } = false;
26+
27+
/// <summary>
28+
/// The blob read from the authenticator.
29+
///
30+
/// Valid only during assertion.
31+
///
32+
/// https://w3c.github.io/webauthn/#dom-authenticationextensionslargebloboutputs-blob
33+
/// </summary>
34+
[JsonConverter(typeof(Base64UrlConverter))]
35+
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
36+
[JsonPropertyName("blob")]
37+
public byte[]? Blob { get; set; }
38+
39+
/// <summary>
40+
/// Whether or not a blob was written to the authenticator.
41+
///
42+
/// Valid only during assertion.
43+
///
44+
/// https://w3c.github.io/webauthn/#dom-authenticationextensionslargebloboutputs-written
45+
/// </summary>
46+
[JsonPropertyName("written")]
47+
public bool Written { get; set; } = false;
48+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
using System.Runtime.Serialization;
2+
using System.Text.Json.Serialization;
3+
4+
namespace Fido2NetLib.Objects;
5+
6+
/// <summary>
7+
/// The possible values for requesting the largeBlob extension during credential registration.
8+
///
9+
/// https://w3c.github.io/webauthn/#sctn-large-blob-extension
10+
/// </summary>
11+
[JsonConverter(typeof(FidoEnumConverter<LargeBlobSupport>))]
12+
public enum LargeBlobSupport
13+
{
14+
/// <summary>
15+
/// largeBlob support is required -- credential creation will fail if largeBlob is not supported
16+
/// </summary>
17+
[EnumMember(Value = "required")] Required,
18+
19+
/// <summary>
20+
/// largeBlob support is preferred -- credential creation will succeed even if largeBlob is not supported.
21+
/// </summary>
22+
[EnumMember(Value = "preferred")] Preferred
23+
}

0 commit comments

Comments
 (0)