Skip to content

Commit 31a4f94

Browse files
Rename 'extensions' to 'clientExtensionResults' for deserialization (#474)
* Rename 'extensions' to 'clientExtensionResults' for deserialization during registration. * fix
1 parent d847702 commit 31a4f94

4 files changed

+38
-30
lines changed

Src/Fido2.Models/AuthenticatorAssertionRawResponse.cs

+9-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,15 @@ public class AuthenticatorAssertionRawResponse
2727
public PublicKeyCredentialType? Type { get; set; }
2828

2929
[JsonPropertyName("extensions")]
30-
public AuthenticationExtensionsClientOutputs Extensions { get; set; }
30+
[Obsolete("Use ClientExtensionResults instead")]
31+
public AuthenticationExtensionsClientOutputs Extensions
32+
{
33+
get => ClientExtensionResults;
34+
set => ClientExtensionResults = value;
35+
}
36+
37+
[JsonPropertyName("clientExtensionResults")]
38+
public AuthenticationExtensionsClientOutputs ClientExtensionResults { get; set; }
3139

3240
public sealed class AssertionResponse
3341
{

Src/Fido2/AuthenticatorAssertionResponse.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ public async Task<VerifyAssertionResult> VerifyAsync(
115115
// https://www.w3.org/TR/webauthn/#sctn-appid-extension
116116
// FIDO AppID Extension:
117117
// If true, the AppID was used and thus, when verifying an assertion, the Relying Party MUST expect the rpIdHash to be the hash of the AppID, not the RP ID.
118-
var rpid = Raw.Extensions?.AppID ?? false ? options.Extensions?.AppID : options.RpId;
118+
var rpid = Raw.ClientExtensionResults?.AppID ?? false ? options.Extensions?.AppID : options.RpId;
119119
byte[] hashedRpId = SHA256.HashData(Encoding.UTF8.GetBytes(rpid ?? string.Empty));
120120
byte[] hash = SHA256.HashData(Raw.Response.ClientDataJson);
121121

@@ -144,9 +144,9 @@ public async Task<VerifyAssertionResult> VerifyAsync(
144144
// considering the client extension input values that were given in options.extensions and any specific policy of the Relying Party regarding unsolicited extensions,
145145
// i.e., those that were not specified as part of options.extensions. In the general case, the meaning of "are as expected" is specific to the Relying Party and which extensions are in use.
146146
byte[]? devicePublicKeyResult = null;
147-
if (Raw.Extensions?.DevicePubKey is not null)
147+
if (Raw.ClientExtensionResults?.DevicePubKey is not null)
148148
{
149-
devicePublicKeyResult = await DevicePublicKeyAuthenticationAsync(storedDevicePublicKeys, Raw.Extensions, AuthenticatorData, hash).ConfigureAwait(false);
149+
devicePublicKeyResult = await DevicePublicKeyAuthenticationAsync(storedDevicePublicKeys, Raw.ClientExtensionResults, AuthenticatorData, hash).ConfigureAwait(false);
150150
}
151151

152152
// Pretty sure these conditions are not able to be met due to the AuthenticatorData constructor implementation

Test/AuthenticatorResponse.cs

+25-25
Original file line numberDiff line numberDiff line change
@@ -1234,7 +1234,7 @@ public void TestAuthenticatorAssertionRawResponse()
12341234
Type = PublicKeyCredentialType.PublicKey,
12351235
Id = new byte[] { 0xf1, 0xd0 },
12361236
RawId = new byte[] { 0xf1, 0xd0 },
1237-
Extensions = new AuthenticationExtensionsClientOutputs
1237+
ClientExtensionResults = new AuthenticationExtensionsClientOutputs
12381238
{
12391239
AppID = true,
12401240
Extensions = new string[] { "foo", "bar" },
@@ -1264,13 +1264,13 @@ public void TestAuthenticatorAssertionRawResponse()
12641264
Assert.Equal(new byte[] { 0xf1, 0xd0 }, assertionResponse.Response.Signature);
12651265
Assert.Equal(clientDataJson, assertionResponse.Response.ClientDataJson);
12661266
Assert.Equal(new byte[] { 0xf1, 0xd0 }, assertionResponse.Response.UserHandle);
1267-
Assert.True(assertionResponse.Extensions.AppID);
1268-
Assert.Equal(new string[] { "foo", "bar" }, assertionResponse.Extensions.Extensions);
1269-
Assert.Equal("test", assertionResponse.Extensions.Example);
1270-
Assert.Equal((ulong)4, assertionResponse.Extensions.UserVerificationMethod[0][0]);
1271-
Assert.True(assertionResponse.Extensions.PRF.Enabled);
1272-
Assert.Equal(new byte[] { 0xf1, 0xd0 }, assertionResponse.Extensions.PRF.Results.First);
1273-
Assert.Equal(new byte[] { 0xf1, 0xd0 }, assertionResponse.Extensions.PRF.Results.Second);
1267+
Assert.True(assertionResponse.ClientExtensionResults.AppID);
1268+
Assert.Equal(new string[] { "foo", "bar" }, assertionResponse.ClientExtensionResults.Extensions);
1269+
Assert.Equal("test", assertionResponse.ClientExtensionResults.Example);
1270+
Assert.Equal((ulong)4, assertionResponse.ClientExtensionResults.UserVerificationMethod[0][0]);
1271+
Assert.True(assertionResponse.ClientExtensionResults.PRF.Enabled);
1272+
Assert.Equal(new byte[] { 0xf1, 0xd0 }, assertionResponse.ClientExtensionResults.PRF.Results.First);
1273+
Assert.Equal(new byte[] { 0xf1, 0xd0 }, assertionResponse.ClientExtensionResults.PRF.Results.Second);
12741274
}
12751275

12761276
[Fact]
@@ -1310,7 +1310,7 @@ public async Task TestAuthenticatorAssertionTypeNotPublicKey()
13101310
Type = PublicKeyCredentialType.Invalid,
13111311
Id = new byte[] { 0xf1, 0xd0 },
13121312
RawId = new byte[] { 0xf1, 0xd0 },
1313-
Extensions = new AuthenticationExtensionsClientOutputs
1313+
ClientExtensionResults = new AuthenticationExtensionsClientOutputs
13141314
{
13151315
AppID = false,
13161316
Extensions = new string[] { "foo", "bar" },
@@ -1378,7 +1378,7 @@ public async Task TestAuthenticatorAssertionIdMissing()
13781378
Response = assertion,
13791379
Type = PublicKeyCredentialType.PublicKey,
13801380
RawId = new byte[] { 0xf1, 0xd0 },
1381-
Extensions = new AuthenticationExtensionsClientOutputs
1381+
ClientExtensionResults = new AuthenticationExtensionsClientOutputs
13821382
{
13831383
AppID = false,
13841384
Extensions = new string[] { "foo", "bar" },
@@ -1447,7 +1447,7 @@ public async Task TestAuthenticatorAssertionRawIdMissing()
14471447
Response = assertion,
14481448
Type = PublicKeyCredentialType.PublicKey,
14491449
Id = new byte[] { 0xf1, 0xd0 },
1450-
Extensions = new AuthenticationExtensionsClientOutputs()
1450+
ClientExtensionResults = new AuthenticationExtensionsClientOutputs()
14511451
{
14521452
AppID = false,
14531453
Extensions = new string[] { "foo", "bar" },
@@ -1516,7 +1516,7 @@ public async Task TestAuthenticatorAssertionUserHandleEmpty()
15161516
Type = PublicKeyCredentialType.PublicKey,
15171517
Id = new byte[] { 0xf1, 0xd0 },
15181518
RawId = new byte[] { 0xf1, 0xd0 },
1519-
Extensions = new AuthenticationExtensionsClientOutputs()
1519+
ClientExtensionResults = new AuthenticationExtensionsClientOutputs()
15201520
{
15211521
AppID = false,
15221522
Extensions = new string[] { "foo", "bar" },
@@ -1585,7 +1585,7 @@ public async Task TestAuthenticatorAssertionUserHandleNotOwnerOfPublicKey()
15851585
Type = PublicKeyCredentialType.PublicKey,
15861586
Id = new byte[] { 0xf1, 0xd0 },
15871587
RawId = new byte[] { 0xf1, 0xd0 },
1588-
Extensions = new AuthenticationExtensionsClientOutputs()
1588+
ClientExtensionResults = new AuthenticationExtensionsClientOutputs()
15891589
{
15901590
AppID = false,
15911591
Extensions = new string[] { "foo", "bar" },
@@ -1654,7 +1654,7 @@ public async Task TestAuthenticatorAssertionTypeNotWebAuthnGet()
16541654
Type = PublicKeyCredentialType.PublicKey,
16551655
Id = new byte[] { 0xf1, 0xd0 },
16561656
RawId = new byte[] { 0xf1, 0xd0 },
1657-
Extensions = new AuthenticationExtensionsClientOutputs
1657+
ClientExtensionResults = new AuthenticationExtensionsClientOutputs
16581658
{
16591659
AppID = false,
16601660
Extensions = new string[] { "foo", "bar" },
@@ -1725,7 +1725,7 @@ public async Task TestAuthenticatorAssertionAppId()
17251725
Type = PublicKeyCredentialType.PublicKey,
17261726
Id = new byte[] { 0xf1, 0xd0 },
17271727
RawId = new byte[] { 0xf1, 0xd0 },
1728-
Extensions = new AuthenticationExtensionsClientOutputs()
1728+
ClientExtensionResults = new AuthenticationExtensionsClientOutputs()
17291729
{
17301730
AppID = true,
17311731
Extensions = new string[] { "foo", "bar" },
@@ -1795,7 +1795,7 @@ public async Task TestAuthenticatorAssertionInvalidRpIdHash()
17951795
Type = PublicKeyCredentialType.PublicKey,
17961796
Id = new byte[] { 0xf1, 0xd0 },
17971797
RawId = new byte[] { 0xf1, 0xd0 },
1798-
Extensions = new AuthenticationExtensionsClientOutputs()
1798+
ClientExtensionResults = new AuthenticationExtensionsClientOutputs()
17991799
{
18001800
AppID = false,
18011801
Extensions = new string[] { "foo", "bar" },
@@ -1866,7 +1866,7 @@ public async Task TestAuthenticatorAssertionUPRequirementNotMet()
18661866
Type = PublicKeyCredentialType.PublicKey,
18671867
Id = new byte[] { 0xf1, 0xd0 },
18681868
RawId = new byte[] { 0xf1, 0xd0 },
1869-
Extensions = new AuthenticationExtensionsClientOutputs
1869+
ClientExtensionResults = new AuthenticationExtensionsClientOutputs
18701870
{
18711871
AppID = false,
18721872
Extensions = new string[] { "foo", "bar" },
@@ -1936,7 +1936,7 @@ public async Task TestAuthenticatorAssertionUVPolicyNotMet()
19361936
Type = PublicKeyCredentialType.PublicKey,
19371937
Id = new byte[] { 0xf1, 0xd0 },
19381938
RawId = new byte[] { 0xf1, 0xd0 },
1939-
Extensions = new AuthenticationExtensionsClientOutputs
1939+
ClientExtensionResults = new AuthenticationExtensionsClientOutputs
19401940
{
19411941
AppID = false,
19421942
Extensions = new string[] { "foo", "bar" },
@@ -2004,7 +2004,7 @@ public async Task TestAuthenticatorAssertionBEPolicyRequired()
20042004
Type = PublicKeyCredentialType.PublicKey,
20052005
Id = new byte[] { 0xf1, 0xd0 },
20062006
RawId = new byte[] { 0xf1, 0xd0 },
2007-
Extensions = new AuthenticationExtensionsClientOutputs()
2007+
ClientExtensionResults = new AuthenticationExtensionsClientOutputs()
20082008
{
20092009
AppID = false,
20102010
Extensions = new string[] { "foo", "bar" },
@@ -2073,7 +2073,7 @@ public async Task TestAuthenticatorAssertionBEPolicyDisallow()
20732073
Type = PublicKeyCredentialType.PublicKey,
20742074
Id = new byte[] { 0xf1, 0xd0 },
20752075
RawId = new byte[] { 0xf1, 0xd0 },
2076-
Extensions = new AuthenticationExtensionsClientOutputs
2076+
ClientExtensionResults = new AuthenticationExtensionsClientOutputs
20772077
{
20782078
AppID = false,
20792079
Extensions = new string[] { "foo", "bar" },
@@ -2142,7 +2142,7 @@ public async Task TestAuthenticatorAssertionBSPolicyRequired()
21422142
Type = PublicKeyCredentialType.PublicKey,
21432143
Id = new byte[] { 0xf1, 0xd0 },
21442144
RawId = new byte[] { 0xf1, 0xd0 },
2145-
Extensions = new AuthenticationExtensionsClientOutputs
2145+
ClientExtensionResults = new AuthenticationExtensionsClientOutputs
21462146
{
21472147
AppID = false,
21482148
Extensions = new string[] { "foo", "bar" },
@@ -2211,7 +2211,7 @@ public async Task TestAuthenticatorAssertionBSPolicyDisallow()
22112211
Type = PublicKeyCredentialType.PublicKey,
22122212
Id = new byte[] { 0xf1, 0xd0 },
22132213
RawId = new byte[] { 0xf1, 0xd0 },
2214-
Extensions = new AuthenticationExtensionsClientOutputs
2214+
ClientExtensionResults = new AuthenticationExtensionsClientOutputs
22152215
{
22162216
AppID = false,
22172217
Extensions = new string[] { "foo", "bar" },
@@ -2281,7 +2281,7 @@ public async Task TestAuthenticatorAssertionStoredPublicKeyMissing()
22812281
Type = PublicKeyCredentialType.PublicKey,
22822282
Id = new byte[] { 0xf1, 0xd0 },
22832283
RawId = new byte[] { 0xf1, 0xd0 },
2284-
Extensions = new AuthenticationExtensionsClientOutputs()
2284+
ClientExtensionResults = new AuthenticationExtensionsClientOutputs()
22852285
{
22862286
AppID = false,
22872287
Extensions = new string[] { "foo", "bar" },
@@ -2350,7 +2350,7 @@ public async Task TestAuthenticatorAssertionInvalidSignature()
23502350
Type = PublicKeyCredentialType.PublicKey,
23512351
Id = new byte[] { 0xf1, 0xd0 },
23522352
RawId = new byte[] { 0xf1, 0xd0 },
2353-
Extensions = new AuthenticationExtensionsClientOutputs()
2353+
ClientExtensionResults = new AuthenticationExtensionsClientOutputs()
23542354
{
23552355
AppID = false,
23562356
Extensions = new string[] { "foo", "bar" },
@@ -2426,7 +2426,7 @@ public async Task TestAuthenticatorAssertionSignCountSignature()
24262426
Type = PublicKeyCredentialType.PublicKey,
24272427
Id = new byte[] { 0xf1, 0xd0 },
24282428
RawId = new byte[] { 0xf1, 0xd0 },
2429-
Extensions = new AuthenticationExtensionsClientOutputs()
2429+
ClientExtensionResults = new AuthenticationExtensionsClientOutputs()
24302430
{
24312431
AppID = false,
24322432
Extensions = new string[] { "foo", "bar" },

Test/ExistingU2fRegistrationDataTests.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public async Task TestFido2AssertionWithExistingU2fRegistrationWithAppId()
3838
Id = keyHandleData,
3939
RawId = keyHandleData,
4040
Type = PublicKeyCredentialType.PublicKey,
41-
Extensions = new AuthenticationExtensionsClientOutputs
41+
ClientExtensionResults = new AuthenticationExtensionsClientOutputs
4242
{
4343
AppID = true
4444
},

0 commit comments

Comments
 (0)