Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Map authenticator transports on server side #453

Merged
merged 4 commits into from
Dec 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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