Skip to content

Commit 83b8214

Browse files
committed
Include port if URI is not utilizing the default port for the scheme
1 parent e082a67 commit 83b8214

File tree

3 files changed

+513
-511
lines changed

3 files changed

+513
-511
lines changed

Src/Fido2/AuthenticatorResponse.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,9 @@ private string FullyQualifiedOrigin(string origin)
8383
{
8484
var uri = new Uri(origin);
8585

86-
return $"{uri.Scheme}://{uri.Host}";
86+
var fullyQualifiedOrigin = uri.IsDefaultPort ? $"{uri.Scheme}://{uri.Host}" : $"{uri.Scheme}://{uri.Host}:{uri.Port}";
87+
88+
return fullyQualifiedOrigin;
8789
}
8890
}
8991
}

Test/AuthenticatorResponse.cs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public void TestAuthenticatorAttestationRawResponse()
2626
{
2727
Type = "webauthn.create",
2828
Challenge = challenge,
29-
Origin = "fido2.azurewebsites.net",
29+
Origin = "https://www.passwordless.dev",
3030
}
3131
)
3232
);
@@ -156,7 +156,7 @@ public void TestAuthenticatorAttestationObjectMalformed(byte[] value)
156156
public void TestAuthenticatorAttestationResponseInvalidType()
157157
{
158158
var challenge = RandomGenerator.Default.GenerateBytes(128);
159-
var rp = "fido2.azurewebsites.net";
159+
var rp = "https://www.passwordless.dev";
160160
var clientDataJson = Encoding.UTF8.GetBytes(
161161
JsonConvert.SerializeObject
162162
(
@@ -232,7 +232,7 @@ public void TestAuthenticatorAttestationResponseInvalidType()
232232
public void TestAuthenticatorAttestationResponseInvalidRawId(byte[] value)
233233
{
234234
var challenge = RandomGenerator.Default.GenerateBytes(128);
235-
var rp = "fido2.azurewebsites.net";
235+
var rp = "https://www.passwordless.dev";
236236
var clientDataJson = Encoding.UTF8.GetBytes(
237237
JsonConvert.SerializeObject
238238
(
@@ -306,7 +306,7 @@ public void TestAuthenticatorAttestationResponseInvalidRawId(byte[] value)
306306
public void TestAuthenticatorAttestationResponseInvalidRawType()
307307
{
308308
var challenge = RandomGenerator.Default.GenerateBytes(128);
309-
var rp = "fido2.azurewebsites.net";
309+
var rp = "https://www.passwordless.dev";
310310
var clientDataJson = Encoding.UTF8.GetBytes(
311311
JsonConvert.SerializeObject
312312
(
@@ -380,7 +380,7 @@ public void TestAuthenticatorAttestationResponseInvalidRawType()
380380
public void TestAuthenticatorAttestationResponseRpidMismatch()
381381
{
382382
var challenge = RandomGenerator.Default.GenerateBytes(128);
383-
var rp = "fido2.azurewebsites.net";
383+
var rp = "https://www.passwordless.dev";
384384
var authData = new AuthenticatorData(
385385
SHA256.Create().ComputeHash(Encoding.UTF8.GetBytes("passwordless.dev")),
386386
AuthenticatorFlags.UV,
@@ -461,7 +461,7 @@ public void TestAuthenticatorAttestationResponseRpidMismatch()
461461
public void TestAuthenticatorAttestationResponseNotUserPresent()
462462
{
463463
var challenge = RandomGenerator.Default.GenerateBytes(128);
464-
var rp = "fido2.azurewebsites.net";
464+
var rp = "https://www.passwordless.dev";
465465
var authData = new AuthenticatorData(
466466
SHA256.Create().ComputeHash(Encoding.UTF8.GetBytes(rp)),
467467
AuthenticatorFlags.UV,
@@ -542,7 +542,7 @@ public void TestAuthenticatorAttestationResponseNotUserPresent()
542542
public void TestAuthenticatorAttestationResponseNoAttestedCredentialData()
543543
{
544544
var challenge = RandomGenerator.Default.GenerateBytes(128);
545-
var rp = "fido2.azurewebsites.net";
545+
var rp = "https://www.passwordless.dev";
546546
var authData = new AuthenticatorData(
547547
SHA256.Create().ComputeHash(Encoding.UTF8.GetBytes(rp)),
548548
AuthenticatorFlags.UP | AuthenticatorFlags.UV,
@@ -623,7 +623,7 @@ public void TestAuthenticatorAttestationResponseNoAttestedCredentialData()
623623
public void TestAuthenticatorAttestationResponseUnknownAttestationType()
624624
{
625625
var challenge = RandomGenerator.Default.GenerateBytes(128);
626-
var rp = "fido2.azurewebsites.net";
626+
var rp = "https://www.passwordless.dev";
627627
var acd = new AttestedCredentialData(("00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-40-FE-6A-32-63-BE-37-D1-01-B1-2E-57-CA-96-6C-00-22-93-E4-19-C8-CD-01-06-23-0B-C6-92-E8-CC-77-12-21-F1-DB-11-5D-41-0F-82-6B-DB-98-AC-64-2E-B1-AE-B5-A8-03-D1-DB-C1-47-EF-37-1C-FD-B1-CE-B0-48-CB-2C-A5-01-02-03-26-20-01-21-58-20-A6-D1-09-38-5A-C7-8E-5B-F0-3D-1C-2E-08-74-BE-6D-BB-A4-0B-4F-2A-5F-2F-11-82-45-65-65-53-4F-67-28-22-58-20-43-E1-08-2A-F3-13-5B-40-60-93-79-AC-47-42-58-AA-B3-97-B8-86-1D-E4-41-B4-4E-83-08-5D-1C-6B-E0-D0").Split('-').Select(c => Convert.ToByte(c, 16)).ToArray());
628628
var authData = new AuthenticatorData(
629629
SHA256.Create().ComputeHash(Encoding.UTF8.GetBytes(rp)),
@@ -705,7 +705,7 @@ public void TestAuthenticatorAttestationResponseUnknownAttestationType()
705705
public void TestAuthenticatorAttestationResponseNotUniqueCredId()
706706
{
707707
var challenge = RandomGenerator.Default.GenerateBytes(128);
708-
var rp = "fido2.azurewebsites.net";
708+
var rp = "https://www.passwordless.dev";
709709
var acd = new AttestedCredentialData(("00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-40-FE-6A-32-63-BE-37-D1-01-B1-2E-57-CA-96-6C-00-22-93-E4-19-C8-CD-01-06-23-0B-C6-92-E8-CC-77-12-21-F1-DB-11-5D-41-0F-82-6B-DB-98-AC-64-2E-B1-AE-B5-A8-03-D1-DB-C1-47-EF-37-1C-FD-B1-CE-B0-48-CB-2C-A5-01-02-03-26-20-01-21-58-20-A6-D1-09-38-5A-C7-8E-5B-F0-3D-1C-2E-08-74-BE-6D-BB-A4-0B-4F-2A-5F-2F-11-82-45-65-65-53-4F-67-28-22-58-20-43-E1-08-2A-F3-13-5B-40-60-93-79-AC-47-42-58-AA-B3-97-B8-86-1D-E4-41-B4-4E-83-08-5D-1C-6B-E0-D0").Split('-').Select(c => Convert.ToByte(c, 16)).ToArray());
710710
var authData = new AuthenticatorData(
711711
SHA256.Create().ComputeHash(Encoding.UTF8.GetBytes(rp)),
@@ -794,7 +794,7 @@ public void TestAuthenticatorAssertionRawResponse()
794794
{
795795
Type = "webauthn.get",
796796
Challenge = challenge,
797-
Origin = "fido2.azurewebsites.net",
797+
Origin = "https://www.passwordless.dev",
798798
}
799799
)
800800
);

0 commit comments

Comments
 (0)