Skip to content

Commit

Permalink
Map authenticator transports on server side (#453)
Browse files Browse the repository at this point in the history
* Remove transports field as it is not mapped on server side

* Map transports

---------

Co-authored-by: Anders Åberg <[email protected]>
  • Loading branch information
joegoldman2 and abergs authored Dec 22, 2023
1 parent 66ae98f commit 5e5f289
Show file tree
Hide file tree
Showing 13 changed files with 20 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Demo/wwwroot/js/custom.register.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ async function registerNewCredential(newCredential) {
response: {
AttestationObject: coerceToBase64Url(attestationObject),
clientDataJSON: coerceToBase64Url(clientDataJSON),
transports: newCredential.response.getTransports(),
transports: newCredential.response.getTransports()
},
};

Expand Down
3 changes: 2 additions & 1 deletion Demo/wwwroot/js/mfa.register.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,8 @@ async function registerNewCredential(newCredential) {
extensions: newCredential.getClientExtensionResults(),
response: {
AttestationObject: coerceToBase64Url(attestationObject),
clientDataJSON: coerceToBase64Url(clientDataJSON)
clientDataJSON: coerceToBase64Url(clientDataJSON),
transports: newCredential.response.getTransports()
}
};

Expand Down
3 changes: 2 additions & 1 deletion Demo/wwwroot/js/passwordless.register.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,8 @@ async function registerNewCredential(newCredential) {
extensions: newCredential.getClientExtensionResults(),
response: {
AttestationObject: coerceToBase64Url(attestationObject),
clientDataJSON: coerceToBase64Url(clientDataJSON)
clientDataJSON: coerceToBase64Url(clientDataJSON),
transports: newCredential.response.getTransports()
}
};

Expand Down
3 changes: 2 additions & 1 deletion Demo/wwwroot/js/usernameless.register.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,8 @@ async function registerNewCredential(newCredential) {
extensions: newCredential.getClientExtensionResults(),
response: {
attestationObject: coerceToBase64Url(attestationObject),
clientDataJSON: coerceToBase64Url(clientDataJSON)
clientDataJSON: coerceToBase64Url(clientDataJSON),
transports: newCredential.response.getTransports()
}
};

Expand Down
2 changes: 1 addition & 1 deletion Src/Fido2.BlazorWebAssembly/wwwroot/js/WebAuthn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export async function createCreds(options: PublicKeyCredentialCreationOptions) {
response: {
attestationObject: toBase64Url(response.attestationObject),
clientDataJSON: toBase64Url(response.clientDataJSON),
transports: response.getTransports ? response.getTransports() : [],
transports: response.getTransports ? response.getTransports() : []
}
};
return retval;
Expand Down
3 changes: 3 additions & 0 deletions Src/Fido2.Models/AuthenticatorAttestationRawResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,8 @@ public sealed class AttestationResponse
[JsonConverter(typeof(Base64UrlConverter))]
[JsonPropertyName("clientDataJSON")]
public byte[] ClientDataJson { get; set; }

[JsonPropertyName("transports")]
public AuthenticatorTransport[] Transports { get; set; }
}
}
2 changes: 1 addition & 1 deletion Src/Fido2/AuthenticatorAttestationResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ public async Task<RegisteredPublicKeyCredential> VerifyAsync(
Id = authData.AttestedCredentialData.CredentialId,
PublicKey = authData.AttestedCredentialData.CredentialPublicKey.GetBytes(),
SignCount = authData.SignCount,
// Transports = result of response.getTransports();
Transports = Raw.Response.Transports,
IsBackupEligible = authData.IsBackupEligible,
IsBackedUp = authData.IsBackedUp,
AttestationObject = Raw.Response.AttestationObject,
Expand Down
1 change: 1 addition & 0 deletions Test/Attestation/AndroidKey.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ public async Task TestAndroidKey()
Assert.Equal("Test User", res.Result.User.DisplayName);
Assert.Equal("testuser"u8.ToArray(), res.Result.User.Id);
Assert.Equal("testuser", res.Result.User.Name);
Assert.Equal(new[] { AuthenticatorTransport.Internal }, res.Result.Transports);
}

[Fact]
Expand Down
1 change: 1 addition & 0 deletions Test/Attestation/AndroidSafetyNet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ public async Task TestAndroidSafetyNet()
Assert.Equal("Test User", res.Result.User.DisplayName);
Assert.Equal("testuser"u8.ToArray(), res.Result.User.Id);
Assert.Equal("testuser", res.Result.User.Name);
Assert.Equal(new[] { AuthenticatorTransport.Internal }, res.Result.Transports);
}

[Fact]
Expand Down
1 change: 1 addition & 0 deletions Test/Attestation/FidoU2f.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ public async Task TestU2f()
Assert.Equal("Test User", res.Result.User.DisplayName);
Assert.Equal("testuser"u8.ToArray(), res.Result.User.Id);
Assert.Equal("testuser", res.Result.User.Name);
Assert.Equal(new[] { AuthenticatorTransport.Internal }, res.Result.Transports);
}

[Fact]
Expand Down
1 change: 1 addition & 0 deletions Test/Attestation/Packed.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ public async Task TestSelf()
Assert.Equal("testuser"u8.ToArray(), res.Result.User.Id);
Assert.Equal("testuser", res.Result.User.Name);
_attestationObject = new CborMap { { "fmt", "packed" } };
Assert.Equal(new[] { AuthenticatorTransport.Internal }, res.Result.Transports);
}
}

Expand Down
3 changes: 3 additions & 0 deletions Test/Attestation/Tpm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,7 @@ public async Task TestTPM()
Assert.Equal("testuser"u8.ToArray(), res.Result.User.Id);
Assert.Equal("testuser", res.Result.User.Name);
_attestationObject = new CborMap { { "fmt", "tpm" } };
Assert.Equal(new[] { AuthenticatorTransport.Internal }, res.Result.Transports);
}
}

Expand Down Expand Up @@ -422,6 +423,7 @@ public async Task TestTPMAikCertSANTCGConformant()
Assert.Equal("Test User", res.Result.User.DisplayName);
Assert.Equal("testuser"u8.ToArray(), res.Result.User.Id);
Assert.Equal("testuser", res.Result.User.Name);
Assert.Equal(new[] { AuthenticatorTransport.Internal }, res.Result.Transports);
}

[Fact]
Expand Down Expand Up @@ -5060,6 +5062,7 @@ public async Task TestTPMAikCertMisingAAGUID()
Assert.Equal("Test User", res.Result.User.DisplayName);
Assert.Equal("testuser"u8.ToArray(), res.Result.User.Id);
Assert.Equal("testuser", res.Result.User.Name);
Assert.Equal(new[] { AuthenticatorTransport.Internal }, res.Result.Transports);
}

[Fact]
Expand Down
1 change: 1 addition & 0 deletions Test/Fido2Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ public async Task<MakeNewCredentialResult> MakeAttestationResponseAsync()
{
AttestationObject = _attestationObject.Encode(),
ClientDataJson = _clientDataJson,
Transports = new[] { AuthenticatorTransport.Internal }
},
Extensions = new AuthenticationExtensionsClientOutputs()
{
Expand Down

0 comments on commit 5e5f289

Please sign in to comment.