Skip to content

Commit 81e125d

Browse files
authored
Migrate to Microsoft.IdentityModel.JsonWebTokens (#476)
* Enable C# 12 * Migrate to Microsoft.IdentityModel.JsonWebTokens * Update xunit * Update Blazer demos to .net8.0 * Update pipelines * Format code * Remove unneeded Microsoft.SourceLink.GitHub depedency * Update Microsoft.VisualStudio.Web.CodeGeneration.Design * Update Test.Sdk * Remove unnecessary condition * Fix nit * Replace DataHelper.Concat calls with collection expressions * Format code * Try to make dotnet format happy * [Ctap2] Use collection expressions * Update dependencies * Update xunit
1 parent 67eec54 commit 81e125d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+306
-396
lines changed

BlazorWasmDemo/Client/BlazorWasmDemo.Client.csproj

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
<Project Sdk="Microsoft.NET.Sdk.BlazorWebAssembly">
22

33
<PropertyGroup>
4-
<TargetFramework>net6.0</TargetFramework>
4+
<TargetFramework>net8.0</TargetFramework>
55
<Nullable>enable</Nullable>
66
</PropertyGroup>
77

88
<ItemGroup>
9-
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="6.0.13" />
10-
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="6.0.13" PrivateAssets="all" />
9+
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="8.0.1" />
10+
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="8.0.1" PrivateAssets="all" />
1111
</ItemGroup>
1212

1313
<ItemGroup>

BlazorWasmDemo/Server/BlazorWasmDemo.Server.csproj

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
11
<Project Sdk="Microsoft.NET.Sdk.Web">
22

33
<PropertyGroup>
4-
<TargetFramework>net6.0</TargetFramework>
4+
<TargetFramework>net8.0</TargetFramework>
55
<Nullable>enable</Nullable>
66
<UserSecretsId>d4e312c9-f55a-43e0-b3ea-699aa6421a5c</UserSecretsId>
77
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
88
<DockerfileContext>..\..</DockerfileContext>
99
</PropertyGroup>
1010

1111
<ItemGroup>
12-
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Server" Version="6.0.13" />
13-
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.17.2" />
12+
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Server" Version="8.0.1" />
13+
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.19.5" />
1414
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" />
15+
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="7.2.0" />
1516
</ItemGroup>
1617

1718
<ItemGroup>

BlazorWasmDemo/Server/Controllers/UserController.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ public async Task<string> CreateCredentialAsync([FromRoute] string username, [Fr
168168
SignCount = result.Result.SignCount,
169169
RegDate = DateTimeOffset.UtcNow,
170170
AaGuid = result.Result.AaGuid,
171-
DevicePublicKeys = new List<byte[]> { result.Result.DevicePublicKey },
171+
DevicePublicKeys = [result.Result.DevicePublicKey],
172172
Transports = result.Result.Transports,
173173
IsBackupEligible = result.Result.IsBackupEligible,
174174
IsBackedUp = result.Result.IsBackedUp,

BlazorWasmDemo/Server/Program.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
builder.Services.AddControllersWithViews();
66
builder.Services.AddRazorPages();
7-
var origin = new Uri(builder.Configuration["Origin"]);
7+
var origin = new Uri(builder.Configuration["Origin"]!);
88
builder.Services.AddFido2(options =>
99
{
1010
options.ServerDomain = origin.Host;

Demo/ConformanceTesting.cs

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
using System.Collections.Generic;
2-
3-
using Fido2NetLib;
1+
using Fido2NetLib;
42

53
namespace Fido2Demo;
64

Demo/Controller.cs

+2-10
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,11 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Linq;
4-
using System.Text;
5-
using System.Threading;
6-
using System.Threading.Tasks;
1+
using System.Text;
72

83
using Fido2NetLib;
94
using Fido2NetLib.Development;
105
using Fido2NetLib.Objects;
116

12-
using Microsoft.AspNetCore.Http;
137
using Microsoft.AspNetCore.Mvc;
148

15-
using static Fido2NetLib.Fido2;
16-
179
namespace Fido2Demo;
1810

1911
[Route("api/[controller]")]
@@ -132,7 +124,7 @@ public async Task<JsonResult> MakeCredential([FromBody] AuthenticatorAttestation
132124
IsBackedUp = success.Result.IsBackedUp,
133125
AttestationObject = success.Result.AttestationObject,
134126
AttestationClientDataJson = success.Result.AttestationClientDataJson,
135-
DevicePublicKeys = new List<byte[]>() { success.Result.DevicePublicKey }
127+
DevicePublicKeys = [success.Result.DevicePublicKey]
136128
});
137129

138130
// 4. return "ok" to the client

Demo/Demo.csproj

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk.Web">
22

33
<PropertyGroup>
4-
<TargetFramework>net6.0</TargetFramework>
4+
<TargetFramework>net8.0</TargetFramework>
55
<RootNamespace>Fido2Demo</RootNamespace>
66
<UserSecretsId>39589262-6aa1-4bde-aaa9-403a7542cf63</UserSecretsId>
77
</PropertyGroup>
@@ -13,8 +13,8 @@
1313
<ProjectReference Include="..\Src\Fido2\Fido2.csproj" />
1414
</ItemGroup>
1515

16-
<ItemGroup Condition=" '$(TargetFramework)' == 'net6.0' ">
17-
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="6.0.0" />
16+
<ItemGroup>
17+
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="8.0.0" />
1818
</ItemGroup>
1919

2020
<ItemGroup>

Demo/Program.cs

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
using Microsoft.AspNetCore.Hosting;
2-
using Microsoft.Extensions.Hosting;
3-
4-
namespace Fido2Demo;
1+
namespace Fido2Demo;
52

63
public class Program
74
{

Demo/RouteHelperExtensions.cs

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
1-
using Microsoft.AspNetCore.Http;
2-
using Microsoft.AspNetCore.Http.Extensions;
1+
using Microsoft.AspNetCore.Http.Extensions;
32
using Microsoft.AspNetCore.Rewrite;
4-
using Microsoft.Extensions.Configuration;
5-
using Microsoft.Extensions.DependencyInjection;
63
using Microsoft.Net.Http.Headers;
74

85
namespace Fido2Demo;

Demo/Startup.cs

+1-10
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,7 @@
1-
using System;
2-
using System.Collections.Generic;
1+
using Fido2NetLib;
32

4-
using Fido2NetLib;
5-
6-
using Microsoft.AspNetCore.Builder;
7-
using Microsoft.AspNetCore.Hosting;
8-
using Microsoft.AspNetCore.Http;
93
using Microsoft.AspNetCore.Mvc;
104
using Microsoft.AspNetCore.Rewrite;
11-
using Microsoft.Extensions.Configuration;
12-
using Microsoft.Extensions.DependencyInjection;
13-
using Microsoft.Extensions.Hosting;
145

156
namespace Fido2Demo;
167

Demo/TestController.cs

+1-6
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,9 @@
1-
using System;
2-
using System.Linq;
3-
using System.Text;
4-
using System.Threading;
5-
using System.Threading.Tasks;
1+
using System.Text;
62

73
using Fido2NetLib;
84
using Fido2NetLib.Development;
95
using Fido2NetLib.Objects;
106

11-
using Microsoft.AspNetCore.Http;
127
using Microsoft.AspNetCore.Mvc;
138
using Microsoft.Extensions.Options;
149

Directory.Build.props

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
<!-- Language + Compiler Settings-->
2424
<PropertyGroup>
25-
<LangVersion>11</LangVersion>
25+
<LangVersion>12</LangVersion>
2626
</PropertyGroup>
2727

2828
<!--MISC-->

Src/Fido2.AspNet/DateTimeUtilities.cs

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
using System;
2-
3-
namespace Fido2NetLib;
1+
namespace Fido2NetLib;
42

53
internal static class DateTimeUtilities
64
{

Src/Fido2.AspNet/DistributedCacheMetadataService.cs

+1-6
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Linq;
4-
using System.Text.Json;
5-
using System.Threading;
6-
using System.Threading.Tasks;
1+
using System.Text.Json;
72

83
using Microsoft.Extensions.Caching.Distributed;
94
using Microsoft.Extensions.Caching.Memory;

Src/Fido2.AspNet/Fido2NetLibBuilderExtensions.cs

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
using System;
2-
using System.Net.Http;
3-
4-
using Fido2NetLib;
1+
using Fido2NetLib;
52

63
using Microsoft.Extensions.Configuration;
74
using Microsoft.Extensions.DependencyInjection.Extensions;

Src/Fido2.AspNet/NullMetadataService.cs

+1-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
1-
using System;
2-
using System.Threading;
3-
using System.Threading.Tasks;
4-
5-
namespace Fido2NetLib;
1+
namespace Fido2NetLib;
62

73
internal sealed class NullMetadataService : IMetadataService
84
{

Src/Fido2.BlazorWebAssembly/Fido2.BlazorWebAssembly.csproj

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk.Razor">
22

33
<PropertyGroup>
4-
<TargetFrameworks>$(SupportedTargetFrameworks)</TargetFrameworks>
4+
<TargetFrameworks>net8.0</TargetFrameworks>
55
<RootNamespace>Fido2NetLib</RootNamespace>
66
<GenerateDocumentationFile>true</GenerateDocumentationFile>
77
<Nullable>enable</Nullable>
@@ -22,8 +22,8 @@
2222
</ItemGroup>
2323

2424
<ItemGroup>
25-
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="6.0.13" />
26-
<PackageReference Include="Microsoft.TypeScript.MSBuild" Version="4.9.5">
25+
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="8.0.1" />
26+
<PackageReference Include="Microsoft.TypeScript.MSBuild" Version="5.3.3">
2727
<PrivateAssets>all</PrivateAssets>
2828
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
2929
</PackageReference>

Src/Fido2.Ctap2/Commands/CtapCommand.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public byte[] GetPayload()
1414

1515
if (parameters is null)
1616
{
17-
return new byte[] { (byte)Type };
17+
return [(byte)Type];
1818
}
1919

2020
var encodedObject = parameters.Encode();

Src/Fido2.Ctap2/Helpers/CryptoHelper.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ namespace Fido2NetLib.Ctap2;
66

77
public static class CryptoHelper
88
{
9-
internal static readonly byte[] DefaultIV = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
9+
internal static ReadOnlySpan<byte> DefaultIV => [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
1010

1111
internal static byte[] AesCbcDefaultIvNoPadding(byte[] key, ReadOnlySpan<byte> data)
1212
{

Src/Fido2.Models/AssertionOptions.cs

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Text.Json;
1+
using System.Text.Json;
42
using System.Text.Json.Serialization;
53

64
using Fido2NetLib.Objects;

Src/Fido2.Models/Base64Url.cs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
using System;
2-
using System.Buffers;
1+
using System.Buffers;
32
using System.Buffers.Text;
43

54
namespace Fido2NetLib;

Src/Fido2.Models/COSETypes.cs

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
using System;
2-
3-
namespace Fido2NetLib.Objects;
1+
namespace Fido2NetLib.Objects;
42

53
/// <summary>
64
/// CBOR Object Signing and Encryption RFC8152 https://tools.ietf.org/html/rfc8152

Src/Fido2.Models/Converters/Base64Converter.cs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
using System;
2-
using System.Text.Json;
1+
using System.Text.Json;
32
using System.Text.Json.Serialization;
43

54
namespace Fido2NetLib;

Src/Fido2.Models/Converters/EnumNameMapper.cs

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Diagnostics.CodeAnalysis;
1+
using System.Diagnostics.CodeAnalysis;
42
using System.Reflection;
53
using System.Runtime.Serialization;
64

Src/Fido2.Models/Converters/FidoEnumConverter.cs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
using System;
2-
using System.Diagnostics.CodeAnalysis;
1+
using System.Diagnostics.CodeAnalysis;
32
using System.Text.Json;
43
using System.Text.Json.Serialization;
54

Src/Fido2.Models/CredentialCreateOptions.cs

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Text.Json;
1+
using System.Text.Json;
42
using System.Text.Json.Serialization;
53

64
using Fido2NetLib.Objects;

Src/Fido2.Models/Exceptions/Fido2ErrorCode.cs

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
using System;
2-
3-
namespace Fido2NetLib.Exceptions;
1+
namespace Fido2NetLib.Exceptions;
42

53
[Flags]
64
public enum Fido2ErrorCode

Src/Fido2.Models/Exceptions/Fido2VerificationException.cs

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
using System;
2-
using System.Runtime.Serialization;
3-
4-
using Fido2NetLib.Exceptions;
1+
using Fido2NetLib.Exceptions;
52

63
namespace Fido2NetLib;
74

Src/Fido2.Models/Fido2Configuration.cs

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Linq;
4-
using System.Runtime.Serialization;
1+
using System.Runtime.Serialization;
52

63
namespace Fido2NetLib;
74

Src/Fido2.Models/Metadata/AlternativeDescriptions.cs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
using System.Collections.Generic;
2-
using System.Text.Json.Serialization;
1+
using System.Text.Json.Serialization;
32

43
namespace Fido2NetLib;
54

Src/Fido2.Models/Metadata/MetadataBLOBPayloadEntry.cs

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
using System;
2-
using System.ComponentModel.DataAnnotations;
3-
using System.Linq;
1+
using System.ComponentModel.DataAnnotations;
42
using System.Text.Json.Serialization;
53

64
namespace Fido2NetLib;

Src/Fido2.Models/Metadata/MetadataStatement.cs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
using System;
2-
using System.ComponentModel.DataAnnotations;
1+
using System.ComponentModel.DataAnnotations;
32
using System.Text.Json.Serialization;
43

54
namespace Fido2NetLib;

Src/Fido2.Models/Metadata/RgbPaletteEntry.cs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
using System;
2-
using System.Text.Json.Serialization;
1+
using System.Text.Json.Serialization;
32

43
namespace Fido2NetLib;
54

Src/Fido2.Models/Metadata/UafVersion.cs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
using System;
2-
using System.Text.Json.Serialization;
1+
using System.Text.Json.Serialization;
32

43
namespace Fido2NetLib;
54

Src/Fido2.Models/Objects/AuthenticationExtensionsPRFInputs.cs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
using System.Collections.Generic;
2-
using System.Text.Json.Serialization;
1+
using System.Text.Json.Serialization;
32

43
namespace Fido2NetLib.Objects;
54

Src/Fido2.Models/Objects/PublicKeyCredentialDescriptor.cs

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#nullable enable
22

3-
using System;
43
using System.Text.Json.Serialization;
54

65
namespace Fido2NetLib.Objects;

Src/Fido2.Models/Objects/RegisteredPublicKeyCredential.cs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
using System;
2-
using System.Text.Json.Serialization;
1+
using System.Text.Json.Serialization;
32

43
namespace Fido2NetLib.Objects;
54

Src/Fido2.Models/StringExtensions.cs

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
using System;
2-
3-
namespace Fido2NetLib;
1+
namespace Fido2NetLib;
42

53
public static class StringExtensions
64
{

0 commit comments

Comments
 (0)