Skip to content

Commit

Permalink
Migrate to Microsoft.IdentityModel.JsonWebTokens (#476)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
iamcarbon committed Jan 15, 2024
1 parent 67eec54 commit 81e125d
Show file tree
Hide file tree
Showing 54 changed files with 306 additions and 396 deletions.
6 changes: 3 additions & 3 deletions BlazorWasmDemo/Client/BlazorWasmDemo.Client.csproj
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk.BlazorWebAssembly">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="6.0.13" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="6.0.13" PrivateAssets="all" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="8.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="8.0.1" PrivateAssets="all" />
</ItemGroup>

<ItemGroup>
Expand Down
7 changes: 4 additions & 3 deletions BlazorWasmDemo/Server/BlazorWasmDemo.Server.csproj
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<UserSecretsId>d4e312c9-f55a-43e0-b3ea-699aa6421a5c</UserSecretsId>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
<DockerfileContext>..\..</DockerfileContext>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Server" Version="6.0.13" />
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.17.2" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Server" Version="8.0.1" />
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.19.5" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" />
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="7.2.0" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion BlazorWasmDemo/Server/Controllers/UserController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ public async Task<string> CreateCredentialAsync([FromRoute] string username, [Fr
SignCount = result.Result.SignCount,
RegDate = DateTimeOffset.UtcNow,
AaGuid = result.Result.AaGuid,
DevicePublicKeys = new List<byte[]> { result.Result.DevicePublicKey },
DevicePublicKeys = [result.Result.DevicePublicKey],
Transports = result.Result.Transports,
IsBackupEligible = result.Result.IsBackupEligible,
IsBackedUp = result.Result.IsBackedUp,
Expand Down
2 changes: 1 addition & 1 deletion BlazorWasmDemo/Server/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

builder.Services.AddControllersWithViews();
builder.Services.AddRazorPages();
var origin = new Uri(builder.Configuration["Origin"]);
var origin = new Uri(builder.Configuration["Origin"]!);
builder.Services.AddFido2(options =>
{
options.ServerDomain = origin.Host;
Expand Down
4 changes: 1 addition & 3 deletions Demo/ConformanceTesting.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System.Collections.Generic;

using Fido2NetLib;
using Fido2NetLib;

namespace Fido2Demo;

Expand Down
12 changes: 2 additions & 10 deletions Demo/Controller.cs
Original file line number Diff line number Diff line change
@@ -1,19 +1,11 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Text;

using Fido2NetLib;
using Fido2NetLib.Development;
using Fido2NetLib.Objects;

using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

using static Fido2NetLib.Fido2;

namespace Fido2Demo;

[Route("api/[controller]")]
Expand Down Expand Up @@ -132,7 +124,7 @@ public async Task<JsonResult> MakeCredential([FromBody] AuthenticatorAttestation
IsBackedUp = success.Result.IsBackedUp,
AttestationObject = success.Result.AttestationObject,
AttestationClientDataJson = success.Result.AttestationClientDataJson,
DevicePublicKeys = new List<byte[]>() { success.Result.DevicePublicKey }
DevicePublicKeys = [success.Result.DevicePublicKey]
});

// 4. return "ok" to the client
Expand Down
6 changes: 3 additions & 3 deletions Demo/Demo.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<RootNamespace>Fido2Demo</RootNamespace>
<UserSecretsId>39589262-6aa1-4bde-aaa9-403a7542cf63</UserSecretsId>
</PropertyGroup>
Expand All @@ -13,8 +13,8 @@
<ProjectReference Include="..\Src\Fido2\Fido2.csproj" />
</ItemGroup>

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

<ItemGroup>
Expand Down
5 changes: 1 addition & 4 deletions Demo/Program.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Hosting;

namespace Fido2Demo;
namespace Fido2Demo;

public class Program
{
Expand Down
5 changes: 1 addition & 4 deletions Demo/RouteHelperExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.Extensions;
using Microsoft.AspNetCore.Http.Extensions;
using Microsoft.AspNetCore.Rewrite;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Net.Http.Headers;

namespace Fido2Demo;
Expand Down
11 changes: 1 addition & 10 deletions Demo/Startup.cs
Original file line number Diff line number Diff line change
@@ -1,16 +1,7 @@
using System;
using System.Collections.Generic;
using Fido2NetLib;

using Fido2NetLib;

using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Rewrite;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;

namespace Fido2Demo;

Expand Down
7 changes: 1 addition & 6 deletions Demo/TestController.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
using System;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Text;

using Fido2NetLib;
using Fido2NetLib.Development;
using Fido2NetLib.Objects;

using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Options;

Expand Down
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

<!-- Language + Compiler Settings-->
<PropertyGroup>
<LangVersion>11</LangVersion>
<LangVersion>12</LangVersion>
</PropertyGroup>

<!--MISC-->
Expand Down
4 changes: 1 addition & 3 deletions Src/Fido2.AspNet/DateTimeUtilities.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System;

namespace Fido2NetLib;
namespace Fido2NetLib;

internal static class DateTimeUtilities
{
Expand Down
7 changes: 1 addition & 6 deletions Src/Fido2.AspNet/DistributedCacheMetadataService.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.Json;
using System.Threading;
using System.Threading.Tasks;
using System.Text.Json;

using Microsoft.Extensions.Caching.Distributed;
using Microsoft.Extensions.Caching.Memory;
Expand Down
5 changes: 1 addition & 4 deletions Src/Fido2.AspNet/Fido2NetLibBuilderExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
using System;
using System.Net.Http;

using Fido2NetLib;
using Fido2NetLib;

using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection.Extensions;
Expand Down
6 changes: 1 addition & 5 deletions Src/Fido2.AspNet/NullMetadataService.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
using System;
using System.Threading;
using System.Threading.Tasks;

namespace Fido2NetLib;
namespace Fido2NetLib;

internal sealed class NullMetadataService : IMetadataService
{
Expand Down
6 changes: 3 additions & 3 deletions Src/Fido2.BlazorWebAssembly/Fido2.BlazorWebAssembly.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Razor">

<PropertyGroup>
<TargetFrameworks>$(SupportedTargetFrameworks)</TargetFrameworks>
<TargetFrameworks>net8.0</TargetFrameworks>
<RootNamespace>Fido2NetLib</RootNamespace>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<Nullable>enable</Nullable>
Expand All @@ -22,8 +22,8 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="6.0.13" />
<PackageReference Include="Microsoft.TypeScript.MSBuild" Version="4.9.5">
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="8.0.1" />
<PackageReference Include="Microsoft.TypeScript.MSBuild" Version="5.3.3">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
2 changes: 1 addition & 1 deletion Src/Fido2.Ctap2/Commands/CtapCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public byte[] GetPayload()

if (parameters is null)
{
return new byte[] { (byte)Type };
return [(byte)Type];
}

var encodedObject = parameters.Encode();
Expand Down
2 changes: 1 addition & 1 deletion Src/Fido2.Ctap2/Helpers/CryptoHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace Fido2NetLib.Ctap2;

public static class CryptoHelper
{
internal static readonly byte[] DefaultIV = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
internal static ReadOnlySpan<byte> DefaultIV => [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];

internal static byte[] AesCbcDefaultIvNoPadding(byte[] key, ReadOnlySpan<byte> data)
{
Expand Down
4 changes: 1 addition & 3 deletions Src/Fido2.Models/AssertionOptions.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System;
using System.Collections.Generic;
using System.Text.Json;
using System.Text.Json;
using System.Text.Json.Serialization;

using Fido2NetLib.Objects;
Expand Down
3 changes: 1 addition & 2 deletions Src/Fido2.Models/Base64Url.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using System.Buffers;
using System.Buffers;
using System.Buffers.Text;

namespace Fido2NetLib;
Expand Down
4 changes: 1 addition & 3 deletions Src/Fido2.Models/COSETypes.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System;

namespace Fido2NetLib.Objects;
namespace Fido2NetLib.Objects;

/// <summary>
/// CBOR Object Signing and Encryption RFC8152 https://tools.ietf.org/html/rfc8152
Expand Down
3 changes: 1 addition & 2 deletions Src/Fido2.Models/Converters/Base64Converter.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using System.Text.Json;
using System.Text.Json;
using System.Text.Json.Serialization;

namespace Fido2NetLib;
Expand Down
4 changes: 1 addition & 3 deletions Src/Fido2.Models/Converters/EnumNameMapper.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Diagnostics.CodeAnalysis;
using System.Reflection;
using System.Runtime.Serialization;

Expand Down
3 changes: 1 addition & 2 deletions Src/Fido2.Models/Converters/FidoEnumConverter.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using System.Diagnostics.CodeAnalysis;
using System.Diagnostics.CodeAnalysis;
using System.Text.Json;
using System.Text.Json.Serialization;

Expand Down
4 changes: 1 addition & 3 deletions Src/Fido2.Models/CredentialCreateOptions.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System;
using System.Collections.Generic;
using System.Text.Json;
using System.Text.Json;
using System.Text.Json.Serialization;

using Fido2NetLib.Objects;
Expand Down
4 changes: 1 addition & 3 deletions Src/Fido2.Models/Exceptions/Fido2ErrorCode.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System;

namespace Fido2NetLib.Exceptions;
namespace Fido2NetLib.Exceptions;

[Flags]
public enum Fido2ErrorCode
Expand Down
5 changes: 1 addition & 4 deletions Src/Fido2.Models/Exceptions/Fido2VerificationException.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
using System;
using System.Runtime.Serialization;

using Fido2NetLib.Exceptions;
using Fido2NetLib.Exceptions;

namespace Fido2NetLib;

Expand Down
5 changes: 1 addition & 4 deletions Src/Fido2.Models/Fido2Configuration.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.Runtime.Serialization;

namespace Fido2NetLib;

Expand Down
3 changes: 1 addition & 2 deletions Src/Fido2.Models/Metadata/AlternativeDescriptions.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.Collections.Generic;
using System.Text.Json.Serialization;
using System.Text.Json.Serialization;

namespace Fido2NetLib;

Expand Down
4 changes: 1 addition & 3 deletions Src/Fido2.Models/Metadata/MetadataBLOBPayloadEntry.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.ComponentModel.DataAnnotations;
using System.Text.Json.Serialization;

namespace Fido2NetLib;
Expand Down
3 changes: 1 addition & 2 deletions Src/Fido2.Models/Metadata/MetadataStatement.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations;
using System.Text.Json.Serialization;

namespace Fido2NetLib;
Expand Down
3 changes: 1 addition & 2 deletions Src/Fido2.Models/Metadata/RgbPaletteEntry.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using System.Text.Json.Serialization;
using System.Text.Json.Serialization;

namespace Fido2NetLib;

Expand Down
3 changes: 1 addition & 2 deletions Src/Fido2.Models/Metadata/UafVersion.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using System.Text.Json.Serialization;
using System.Text.Json.Serialization;

namespace Fido2NetLib;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.Collections.Generic;
using System.Text.Json.Serialization;
using System.Text.Json.Serialization;

namespace Fido2NetLib.Objects;

Expand Down
1 change: 0 additions & 1 deletion Src/Fido2.Models/Objects/PublicKeyCredentialDescriptor.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#nullable enable

using System;
using System.Text.Json.Serialization;

namespace Fido2NetLib.Objects;
Expand Down
3 changes: 1 addition & 2 deletions Src/Fido2.Models/Objects/RegisteredPublicKeyCredential.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using System.Text.Json.Serialization;
using System.Text.Json.Serialization;

namespace Fido2NetLib.Objects;

Expand Down
4 changes: 1 addition & 3 deletions Src/Fido2.Models/StringExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System;

namespace Fido2NetLib;
namespace Fido2NetLib;

public static class StringExtensions
{
Expand Down
Loading

0 comments on commit 81e125d

Please sign in to comment.