diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 196891d7..d20af166 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -13,17 +13,17 @@ jobs: steps: - name: Checkout uses: actions/checkout@v4 - - name: Setup .NET SDK 6.0 + - name: Setup .NET SDK 8.0 uses: actions/setup-dotnet@v4 with: - dotnet-version: 6.0.425 + dotnet-version: 8.0.405 source-url: ${{ secrets.NUGET_SOURCE }} env: NUGET_AUTH_TOKEN: ${{ secrets.PACKAGES_TOKEN }} - - name: Setup .NET SDK 8.0 + - name: Setup .NET SDK 9.0 uses: actions/setup-dotnet@v4 with: - dotnet-version: 8.0.402 + dotnet-version: 9.0.102 source-url: ${{ secrets.NUGET_SOURCE }} env: NUGET_AUTH_TOKEN: ${{ secrets.PACKAGES_TOKEN }} diff --git a/.github/workflows/Release.yml b/.github/workflows/Release.yml index 48e22e9f..e2c7159c 100644 --- a/.github/workflows/Release.yml +++ b/.github/workflows/Release.yml @@ -18,17 +18,17 @@ jobs: ref: ${{ github.sha }} - name: Set release version run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV - - name: Setup .NET SDK 6.0 + - name: Setup .NET SDK 8.0 uses: actions/setup-dotnet@v4 with: - dotnet-version: 6.0.425 + dotnet-version: 8.0.405 source-url: ${{ secrets.NUGET_SOURCE }} env: NUGET_AUTH_TOKEN: ${{ secrets.PACKAGES_TOKEN }} - - name: Setup .NET SDK 8.0 + - name: Setup .NET SDK 9.0 uses: actions/setup-dotnet@v4 with: - dotnet-version: 8.0.402 + dotnet-version: 9.0.102 source-url: ${{ secrets.NUGET_SOURCE }} env: NUGET_AUTH_TOKEN: ${{ secrets.PACKAGES_TOKEN }} diff --git a/README.md b/README.md index 027a6708..60a9118d 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # WebAuthn.Net -A production-ready, easy-to-use, extensible implementation of the [WebAuthn Level 3 standard](https://www.w3.org/TR/2023/WD-webauthn-3-20230927/), passing the [FIDO conformance test](https://fidoalliance.org/certification/functional-certification/conformance/), for the server side of web applications on .NET 6 and .NET 8. +A production-ready, easy-to-use, extensible implementation of the [WebAuthn Level 3 standard](https://www.w3.org/TR/2023/WD-webauthn-3-20230927/), passing the [FIDO conformance test](https://fidoalliance.org/certification/functional-certification/conformance/), for the server side of web applications on .NET 8 and .NET 9. @@ -61,8 +61,8 @@ The documentation for each project is described in its README.md file. ### Required dependencies -- [.NET SDK 6.0.425+](https://dotnet.microsoft.com/en-us/download/dotnet/6.0) -- [.NET SDK 8.0.402+](https://dotnet.microsoft.com/en-us/download/dotnet/8.0) +- [.NET SDK 8.0.405+](https://dotnet.microsoft.com/en-us/download/dotnet/8.0) +- [.NET SDK 9.0.102+](https://dotnet.microsoft.com/en-us/download/dotnet/9.0) ## Tips for Contribution diff --git a/demo/WebAuthn.Net.Demo.FidoConformance/README.md b/demo/WebAuthn.Net.Demo.FidoConformance/README.md index 1d686ab4..5fe75582 100644 --- a/demo/WebAuthn.Net.Demo.FidoConformance/README.md +++ b/demo/WebAuthn.Net.Demo.FidoConformance/README.md @@ -16,7 +16,7 @@ This project contains a demo application designed for passing the [FIDO conforma These steps need to be performed only if you have not done them before. -1. Install .NET SDK versions [6.0.425+](https://dotnet.microsoft.com/en-us/download/dotnet/6.0) and [8.0.402+](https://dotnet.microsoft.com/en-us/download/dotnet/8.0). +1. Install .NET SDK versions [8.0.405+](https://dotnet.microsoft.com/en-us/download/dotnet/8.0) and [9.0.102+](https://dotnet.microsoft.com/en-us/download/dotnet/9.0). 2. [Trust the ASP.NET Core HTTPS development certificate](https://learn.microsoft.com/en-us/aspnet/core/security/enforcing-ssl?view=aspnetcore-8.0&tabs=visual-studio%2Clinux-ubuntu#trust-the-aspnet-core-https-development-certificate-on-windows-and-macos) ### Starting the FIDO Conformance test diff --git a/demo/WebAuthn.Net.Demo.FidoConformance/WebAuthn.Net.Demo.FidoConformance.csproj b/demo/WebAuthn.Net.Demo.FidoConformance/WebAuthn.Net.Demo.FidoConformance.csproj index 0255b423..ee806568 100644 --- a/demo/WebAuthn.Net.Demo.FidoConformance/WebAuthn.Net.Demo.FidoConformance.csproj +++ b/demo/WebAuthn.Net.Demo.FidoConformance/WebAuthn.Net.Demo.FidoConformance.csproj @@ -5,6 +5,7 @@ enable enable 12 + $(NoWarn);CA1515;CA1819;CA2007; @@ -35,7 +36,7 @@ - + diff --git a/demo/WebAuthn.Net.Demo.Mvc/ViewModels/Error/ErrorViewModel.cs b/demo/WebAuthn.Net.Demo.Mvc/ViewModels/Error/ErrorViewModel.cs index 016f3646..caba181f 100644 --- a/demo/WebAuthn.Net.Demo.Mvc/ViewModels/Error/ErrorViewModel.cs +++ b/demo/WebAuthn.Net.Demo.Mvc/ViewModels/Error/ErrorViewModel.cs @@ -1,6 +1,8 @@ using System.Text.Json.Serialization; +#pragma warning disable CA1716 namespace WebAuthn.Net.Demo.Mvc.ViewModels.Error; +#pragma warning restore CA1716 [method: JsonConstructor] public class ErrorViewModel(string errorMessage, int statusCode, string requestId) diff --git a/demo/WebAuthn.Net.Demo.Mvc/WebAuthn.Net.Demo.Mvc.csproj b/demo/WebAuthn.Net.Demo.Mvc/WebAuthn.Net.Demo.Mvc.csproj index b4e55bff..7fa7cacf 100644 --- a/demo/WebAuthn.Net.Demo.Mvc/WebAuthn.Net.Demo.Mvc.csproj +++ b/demo/WebAuthn.Net.Demo.Mvc/WebAuthn.Net.Demo.Mvc.csproj @@ -5,6 +5,7 @@ enable enable 12 + $(NoWarn);CA1515;CA2007 @@ -14,11 +15,8 @@ - - - - - + + diff --git a/global.json b/global.json index fdc67008..50c1b41e 100644 --- a/global.json +++ b/global.json @@ -1,6 +1,6 @@ { "sdk": { - "version": "8.0.402", + "version": "9.0.102", "rollForward": "latestPatch", "allowPrerelease": false } diff --git a/src/WebAuthn.Net.OpenTelemetry/WebAuthn.Net.OpenTelemetry.csproj b/src/WebAuthn.Net.OpenTelemetry/WebAuthn.Net.OpenTelemetry.csproj index 183b3077..6863eb32 100644 --- a/src/WebAuthn.Net.OpenTelemetry/WebAuthn.Net.OpenTelemetry.csproj +++ b/src/WebAuthn.Net.OpenTelemetry/WebAuthn.Net.OpenTelemetry.csproj @@ -1,7 +1,7 @@ - net6.0;net8.0 + net8.0;net9.0 false LICENSE true @@ -25,12 +25,8 @@ - - - - - - + + diff --git a/src/WebAuthn.Net.Storage.InMemory/WebAuthn.Net.Storage.InMemory.csproj b/src/WebAuthn.Net.Storage.InMemory/WebAuthn.Net.Storage.InMemory.csproj index bed33691..3df75a8c 100644 --- a/src/WebAuthn.Net.Storage.InMemory/WebAuthn.Net.Storage.InMemory.csproj +++ b/src/WebAuthn.Net.Storage.InMemory/WebAuthn.Net.Storage.InMemory.csproj @@ -1,7 +1,7 @@ - net6.0;net8.0 + net8.0;net9.0 false LICENSE true diff --git a/src/WebAuthn.Net.Storage.MySql/WebAuthn.Net.Storage.MySql.csproj b/src/WebAuthn.Net.Storage.MySql/WebAuthn.Net.Storage.MySql.csproj index d3ca3144..8642d7ef 100644 --- a/src/WebAuthn.Net.Storage.MySql/WebAuthn.Net.Storage.MySql.csproj +++ b/src/WebAuthn.Net.Storage.MySql/WebAuthn.Net.Storage.MySql.csproj @@ -1,7 +1,7 @@ - net6.0;net8.0 + net8.0;net9.0 false LICENSE true @@ -25,13 +25,9 @@ - + - + - - - - diff --git a/src/WebAuthn.Net.Storage.PostgreSql/WebAuthn.Net.Storage.PostgreSql.csproj b/src/WebAuthn.Net.Storage.PostgreSql/WebAuthn.Net.Storage.PostgreSql.csproj index 749ad2ef..e7300a5b 100644 --- a/src/WebAuthn.Net.Storage.PostgreSql/WebAuthn.Net.Storage.PostgreSql.csproj +++ b/src/WebAuthn.Net.Storage.PostgreSql/WebAuthn.Net.Storage.PostgreSql.csproj @@ -1,7 +1,7 @@ - net6.0;net8.0 + net8.0;net9.0 false LICENSE true @@ -25,13 +25,9 @@ - + - + - - - - diff --git a/src/WebAuthn.Net.Storage.SqlServer/WebAuthn.Net.Storage.SqlServer.csproj b/src/WebAuthn.Net.Storage.SqlServer/WebAuthn.Net.Storage.SqlServer.csproj index a7b28569..921dd986 100644 --- a/src/WebAuthn.Net.Storage.SqlServer/WebAuthn.Net.Storage.SqlServer.csproj +++ b/src/WebAuthn.Net.Storage.SqlServer/WebAuthn.Net.Storage.SqlServer.csproj @@ -1,7 +1,7 @@ - net6.0;net8.0 + net8.0;net9.0 false LICENSE true @@ -23,7 +23,7 @@ - + diff --git a/src/WebAuthn.Net/Models/Protocol/RegistrationCeremony/CreateCredential/AuthenticatorAttestationResponse.cs b/src/WebAuthn.Net/Models/Protocol/RegistrationCeremony/CreateCredential/AuthenticatorAttestationResponse.cs index 16739307..b9fadc1a 100644 --- a/src/WebAuthn.Net/Models/Protocol/RegistrationCeremony/CreateCredential/AuthenticatorAttestationResponse.cs +++ b/src/WebAuthn.Net/Models/Protocol/RegistrationCeremony/CreateCredential/AuthenticatorAttestationResponse.cs @@ -67,7 +67,7 @@ public AuthenticatorAttestationResponse( { foreach (var transport in transports) { - if (!Enum.IsDefined(typeof(AuthenticatorTransport), transport)) + if (!Enum.IsDefined(transport)) { throw new InvalidEnumArgumentException(nameof(transports), (int) transport, typeof(AuthenticatorTransport)); } @@ -82,7 +82,7 @@ public AuthenticatorAttestationResponse( // publicKeyAlgorithm if (publicKeyAlgorithm.HasValue) { - if (!Enum.IsDefined(typeof(CoseAlgorithm), publicKeyAlgorithm.Value)) + if (!Enum.IsDefined(publicKeyAlgorithm.Value)) { throw new InvalidEnumArgumentException(nameof(publicKeyAlgorithm), (int) publicKeyAlgorithm.Value, typeof(CoseAlgorithm)); } diff --git a/src/WebAuthn.Net/Models/Protocol/RegistrationCeremony/CreateCredential/RegistrationResponse.cs b/src/WebAuthn.Net/Models/Protocol/RegistrationCeremony/CreateCredential/RegistrationResponse.cs index e9268384..eee6bfe2 100644 --- a/src/WebAuthn.Net/Models/Protocol/RegistrationCeremony/CreateCredential/RegistrationResponse.cs +++ b/src/WebAuthn.Net/Models/Protocol/RegistrationCeremony/CreateCredential/RegistrationResponse.cs @@ -98,7 +98,7 @@ public RegistrationResponse( // authenticatorAttachment if (authenticatorAttachment.HasValue) { - if (!Enum.IsDefined(typeof(AuthenticatorAttachment), authenticatorAttachment.Value)) + if (!Enum.IsDefined(authenticatorAttachment.Value)) { throw new InvalidEnumArgumentException(nameof(authenticatorAttachment), (int) authenticatorAttachment.Value, typeof(AuthenticatorAttachment)); } @@ -110,7 +110,7 @@ public RegistrationResponse( ClientExtensionResults = clientExtensionResults; // type - if (!Enum.IsDefined(typeof(PublicKeyCredentialType), type)) + if (!Enum.IsDefined(type)) { throw new InvalidEnumArgumentException(nameof(type), (int) type, typeof(PublicKeyCredentialType)); } diff --git a/src/WebAuthn.Net/Models/Protocol/RegistrationCeremony/CreateOptions/PublicKeyCredentialParameters.cs b/src/WebAuthn.Net/Models/Protocol/RegistrationCeremony/CreateOptions/PublicKeyCredentialParameters.cs index 2d3d263a..8b78a2ed 100644 --- a/src/WebAuthn.Net/Models/Protocol/RegistrationCeremony/CreateOptions/PublicKeyCredentialParameters.cs +++ b/src/WebAuthn.Net/Models/Protocol/RegistrationCeremony/CreateOptions/PublicKeyCredentialParameters.cs @@ -28,12 +28,12 @@ public class PublicKeyCredentialParameters /// contains a value that is not defined in public PublicKeyCredentialParameters(PublicKeyCredentialType type, CoseAlgorithm alg) { - if (!Enum.IsDefined(typeof(PublicKeyCredentialType), type)) + if (!Enum.IsDefined(type)) { throw new InvalidEnumArgumentException(nameof(type), (int) type, typeof(PublicKeyCredentialType)); } - if (!Enum.IsDefined(typeof(CoseAlgorithm), alg)) + if (!Enum.IsDefined(alg)) { throw new InvalidEnumArgumentException(nameof(alg), (int) alg, typeof(CoseAlgorithm)); } diff --git a/src/WebAuthn.Net/Services/Common/AttestationObjectDecoder/Models/AttestationObject.cs b/src/WebAuthn.Net/Services/Common/AttestationObjectDecoder/Models/AttestationObject.cs index 6e1d3766..c91969dd 100644 --- a/src/WebAuthn.Net/Services/Common/AttestationObjectDecoder/Models/AttestationObject.cs +++ b/src/WebAuthn.Net/Services/Common/AttestationObjectDecoder/Models/AttestationObject.cs @@ -26,7 +26,7 @@ public AttestationObject( byte[]? authData) { // fmt - if (!Enum.IsDefined(typeof(AttestationStatementFormat), fmt)) + if (!Enum.IsDefined(fmt)) { throw new InvalidEnumArgumentException(nameof(fmt), (int) fmt, typeof(AttestationStatementFormat)); } diff --git a/src/WebAuthn.Net/Services/Common/AttestationStatementDecoder/Implementation/DefaultAttestationStatementDecoder.cs b/src/WebAuthn.Net/Services/Common/AttestationStatementDecoder/Implementation/DefaultAttestationStatementDecoder.cs index a4d3c22b..307d4804 100644 --- a/src/WebAuthn.Net/Services/Common/AttestationStatementDecoder/Implementation/DefaultAttestationStatementDecoder.cs +++ b/src/WebAuthn.Net/Services/Common/AttestationStatementDecoder/Implementation/DefaultAttestationStatementDecoder.cs @@ -97,7 +97,7 @@ public virtual Result Decode( AttestationStatementFormat attestationStatementFormat) { ArgumentNullException.ThrowIfNull(attStmt); - if (!Enum.IsDefined(typeof(AttestationStatementFormat), attestationStatementFormat)) + if (!Enum.IsDefined(attestationStatementFormat)) { throw new InvalidEnumArgumentException(nameof(attestationStatementFormat), (int) attestationStatementFormat, typeof(AttestationStatementFormat)); } diff --git a/src/WebAuthn.Net/Services/Common/AttestationStatementDecoder/Models/AttestationStatements/AndroidKeyAttestationStatement.cs b/src/WebAuthn.Net/Services/Common/AttestationStatementDecoder/Models/AttestationStatements/AndroidKeyAttestationStatement.cs index 885fff95..246c5c5d 100644 --- a/src/WebAuthn.Net/Services/Common/AttestationStatementDecoder/Models/AttestationStatements/AndroidKeyAttestationStatement.cs +++ b/src/WebAuthn.Net/Services/Common/AttestationStatementDecoder/Models/AttestationStatements/AndroidKeyAttestationStatement.cs @@ -28,7 +28,7 @@ public class AndroidKeyAttestationStatement : AbstractAttestationStatement public AndroidKeyAttestationStatement(CoseAlgorithm alg, byte[] sig, byte[][] x5C) { // alg - if (!Enum.IsDefined(typeof(CoseAlgorithm), alg)) + if (!Enum.IsDefined(alg)) { throw new InvalidEnumArgumentException(nameof(alg), (int) alg, typeof(CoseAlgorithm)); } diff --git a/src/WebAuthn.Net/Services/Common/AttestationStatementDecoder/Models/AttestationStatements/PackedAttestationStatement.cs b/src/WebAuthn.Net/Services/Common/AttestationStatementDecoder/Models/AttestationStatements/PackedAttestationStatement.cs index e7972556..c6bec2b6 100644 --- a/src/WebAuthn.Net/Services/Common/AttestationStatementDecoder/Models/AttestationStatements/PackedAttestationStatement.cs +++ b/src/WebAuthn.Net/Services/Common/AttestationStatementDecoder/Models/AttestationStatements/PackedAttestationStatement.cs @@ -27,7 +27,7 @@ public class PackedAttestationStatement : AbstractAttestationStatement public PackedAttestationStatement(CoseAlgorithm alg, byte[] sig, byte[][]? x5C) { // alg - if (!Enum.IsDefined(typeof(CoseAlgorithm), alg)) + if (!Enum.IsDefined(alg)) { throw new InvalidEnumArgumentException(nameof(alg), (int) alg, typeof(CoseAlgorithm)); } diff --git a/src/WebAuthn.Net/Services/Common/AttestationStatementDecoder/Models/AttestationStatements/TpmAttestationStatement.cs b/src/WebAuthn.Net/Services/Common/AttestationStatementDecoder/Models/AttestationStatements/TpmAttestationStatement.cs index 2219229d..82d0e3f2 100644 --- a/src/WebAuthn.Net/Services/Common/AttestationStatementDecoder/Models/AttestationStatements/TpmAttestationStatement.cs +++ b/src/WebAuthn.Net/Services/Common/AttestationStatementDecoder/Models/AttestationStatements/TpmAttestationStatement.cs @@ -42,7 +42,7 @@ public TpmAttestationStatement(string ver, CoseAlgorithm alg, byte[][] x5C, byte Ver = ver; // alg - if (!Enum.IsDefined(typeof(CoseAlgorithm), alg)) + if (!Enum.IsDefined(alg)) { throw new InvalidEnumArgumentException(nameof(alg), (int) alg, typeof(CoseAlgorithm)); } diff --git a/src/WebAuthn.Net/Services/Common/AttestationStatementVerifier/Implementation/FidoU2F/Models/FidoU2FAttestationTypeResult.cs b/src/WebAuthn.Net/Services/Common/AttestationStatementVerifier/Implementation/FidoU2F/Models/FidoU2FAttestationTypeResult.cs index 3d96b5a8..2267124f 100644 --- a/src/WebAuthn.Net/Services/Common/AttestationStatementVerifier/Implementation/FidoU2F/Models/FidoU2FAttestationTypeResult.cs +++ b/src/WebAuthn.Net/Services/Common/AttestationStatementVerifier/Implementation/FidoU2F/Models/FidoU2FAttestationTypeResult.cs @@ -22,7 +22,7 @@ public FidoU2FAttestationTypeResult( AttestationType attestationType, UniqueByteArraysCollection attestationRootCertificates) { - if (!Enum.IsDefined(typeof(AttestationType), attestationType)) + if (!Enum.IsDefined(attestationType)) { throw new InvalidEnumArgumentException(nameof(attestationType), (int) attestationType, typeof(AttestationType)); } diff --git a/src/WebAuthn.Net/Services/Common/AttestationStatementVerifier/Implementation/Packed/Models/FidoPackedAttestationTypeResult.cs b/src/WebAuthn.Net/Services/Common/AttestationStatementVerifier/Implementation/Packed/Models/FidoPackedAttestationTypeResult.cs index 1bf81b6b..96a50aa6 100644 --- a/src/WebAuthn.Net/Services/Common/AttestationStatementVerifier/Implementation/Packed/Models/FidoPackedAttestationTypeResult.cs +++ b/src/WebAuthn.Net/Services/Common/AttestationStatementVerifier/Implementation/Packed/Models/FidoPackedAttestationTypeResult.cs @@ -22,7 +22,7 @@ public FidoPackedAttestationTypeResult( AttestationType attestationType, UniqueByteArraysCollection attestationRootCertificates) { - if (!Enum.IsDefined(typeof(AttestationType), attestationType)) + if (!Enum.IsDefined(attestationType)) { throw new InvalidEnumArgumentException(nameof(attestationType), (int) attestationType, typeof(AttestationType)); } diff --git a/src/WebAuthn.Net/Services/Common/AttestationStatementVerifier/Models/AttestationStatementVerifier/VerifiedAttestationStatement.cs b/src/WebAuthn.Net/Services/Common/AttestationStatementVerifier/Models/AttestationStatementVerifier/VerifiedAttestationStatement.cs index ecbfaa4e..68c9ff1b 100644 --- a/src/WebAuthn.Net/Services/Common/AttestationStatementVerifier/Models/AttestationStatementVerifier/VerifiedAttestationStatement.cs +++ b/src/WebAuthn.Net/Services/Common/AttestationStatementVerifier/Models/AttestationStatementVerifier/VerifiedAttestationStatement.cs @@ -30,7 +30,7 @@ public VerifiedAttestationStatement( UniqueByteArraysCollection? attestationRootCertificates) { // fmt - if (!Enum.IsDefined(typeof(AttestationStatementFormat), fmt)) + if (!Enum.IsDefined(fmt)) { throw new InvalidEnumArgumentException(nameof(fmt), (int) fmt, typeof(AttestationStatementFormat)); } @@ -38,7 +38,7 @@ public VerifiedAttestationStatement( Fmt = fmt; // attestationType - if (!Enum.IsDefined(typeof(AttestationType), attestationType)) + if (!Enum.IsDefined(attestationType)) { throw new InvalidEnumArgumentException(nameof(attestationType), (int) attestationType, typeof(AttestationType)); } diff --git a/src/WebAuthn.Net/Services/Common/ClientDataDecoder/Models/TokenBinding.cs b/src/WebAuthn.Net/Services/Common/ClientDataDecoder/Models/TokenBinding.cs index 822a710d..6edd4b8f 100644 --- a/src/WebAuthn.Net/Services/Common/ClientDataDecoder/Models/TokenBinding.cs +++ b/src/WebAuthn.Net/Services/Common/ClientDataDecoder/Models/TokenBinding.cs @@ -46,7 +46,7 @@ public class TokenBinding /// is empty when status is public TokenBinding(TokenBindingStatus status, byte[]? id) { - if (!Enum.IsDefined(typeof(TokenBindingStatus), status)) + if (!Enum.IsDefined(status)) { throw new InvalidEnumArgumentException(nameof(status), (int) status, typeof(TokenBindingStatus)); } diff --git a/src/WebAuthn.Net/Services/FidoMetadata/Implementation/FidoMetadataBackgroundIngest/FidoMetadataBackgroundIngestHostedService.cs b/src/WebAuthn.Net/Services/FidoMetadata/Implementation/FidoMetadataBackgroundIngest/FidoMetadataBackgroundIngestHostedService.cs index 8707a280..7bdc16e0 100644 --- a/src/WebAuthn.Net/Services/FidoMetadata/Implementation/FidoMetadataBackgroundIngest/FidoMetadataBackgroundIngestHostedService.cs +++ b/src/WebAuthn.Net/Services/FidoMetadata/Implementation/FidoMetadataBackgroundIngest/FidoMetadataBackgroundIngestHostedService.cs @@ -107,14 +107,10 @@ public virtual async Task StopAsync(CancellationToken cancellationToken) { // Signal cancellation to the executing method var stoppingCts = StoppingCts; -#if NET6_0 - stoppingCts?.Cancel(); -#else if (stoppingCts is not null) { await stoppingCts.CancelAsync(); } -#endif } finally { diff --git a/src/WebAuthn.Net/Services/FidoMetadata/Models/FidoMetadataDecoder/BiometricStatusReport.cs b/src/WebAuthn.Net/Services/FidoMetadata/Models/FidoMetadataDecoder/BiometricStatusReport.cs index b228505d..78504351 100644 --- a/src/WebAuthn.Net/Services/FidoMetadata/Models/FidoMetadataDecoder/BiometricStatusReport.cs +++ b/src/WebAuthn.Net/Services/FidoMetadata/Models/FidoMetadataDecoder/BiometricStatusReport.cs @@ -46,7 +46,7 @@ public BiometricStatusReport( throw new ArgumentException("'modality' must contain a single USER_VERIFY constant, representing biometric modality", nameof(modality)); } - if (!Enum.IsDefined(typeof(UserVerificationMethod), modality)) + if (!Enum.IsDefined(modality)) { throw new ArgumentOutOfRangeException(nameof(modality), "Value should be defined in the UserVerificationMethod enum."); } diff --git a/src/WebAuthn.Net/Services/FidoMetadata/Models/FidoMetadataDecoder/StatusReport.cs b/src/WebAuthn.Net/Services/FidoMetadata/Models/FidoMetadataDecoder/StatusReport.cs index 126424e7..f163142f 100644 --- a/src/WebAuthn.Net/Services/FidoMetadata/Models/FidoMetadataDecoder/StatusReport.cs +++ b/src/WebAuthn.Net/Services/FidoMetadata/Models/FidoMetadataDecoder/StatusReport.cs @@ -40,7 +40,7 @@ public StatusReport( string? certificationPolicyVersion, string? certificationRequirementsVersion) { - if (!Enum.IsDefined(typeof(AuthenticatorStatus), status)) + if (!Enum.IsDefined(status)) { throw new ArgumentOutOfRangeException(nameof(status), "Value should be defined in the AuthenticatorStatus enum."); } diff --git a/src/WebAuthn.Net/Services/Serialization/Cbor/Models/Tree/CborNegativeInteger.cs b/src/WebAuthn.Net/Services/Serialization/Cbor/Models/Tree/CborNegativeInteger.cs index 8a69c079..33919444 100644 --- a/src/WebAuthn.Net/Services/Serialization/Cbor/Models/Tree/CborNegativeInteger.cs +++ b/src/WebAuthn.Net/Services/Serialization/Cbor/Models/Tree/CborNegativeInteger.cs @@ -17,14 +17,7 @@ public class CborNegativeInteger : AbstractCborInteger, IEquatable is not in the range from -1 to . public CborNegativeInteger(int value) { -#if NET6_0 - if (value > 0) - { - throw new ArgumentOutOfRangeException(nameof(value)); - } -#else ArgumentOutOfRangeException.ThrowIfGreaterThan(value, 0, nameof(value)); -#endif RawValue = (ulong) (-1 - value); } diff --git a/src/WebAuthn.Net/Services/Serialization/Cose/Models/CoseEc2Key.cs b/src/WebAuthn.Net/Services/Serialization/Cose/Models/CoseEc2Key.cs index 538ea03b..a01ccdc8 100644 --- a/src/WebAuthn.Net/Services/Serialization/Cose/Models/CoseEc2Key.cs +++ b/src/WebAuthn.Net/Services/Serialization/Cose/Models/CoseEc2Key.cs @@ -44,7 +44,7 @@ public CoseEc2Key(CoseAlgorithm alg, CoseEc2EllipticCurve crv, byte[] x, byte[] Alg = alg; // crv - if (!Enum.IsDefined(typeof(CoseEc2EllipticCurve), crv)) + if (!Enum.IsDefined(crv)) { throw new InvalidEnumArgumentException(nameof(crv), (int) crv, typeof(CoseEc2EllipticCurve)); } diff --git a/src/WebAuthn.Net/Services/Serialization/Cose/Models/CoseOkpKey.cs b/src/WebAuthn.Net/Services/Serialization/Cose/Models/CoseOkpKey.cs index b2032e91..72d06098 100644 --- a/src/WebAuthn.Net/Services/Serialization/Cose/Models/CoseOkpKey.cs +++ b/src/WebAuthn.Net/Services/Serialization/Cose/Models/CoseOkpKey.cs @@ -41,7 +41,7 @@ public CoseOkpKey(CoseAlgorithm alg, CoseOkpEllipticCurve crv, byte[] x) Alg = alg; // crv - if (!Enum.IsDefined(typeof(CoseOkpEllipticCurve), crv)) + if (!Enum.IsDefined(crv)) { throw new InvalidEnumArgumentException(nameof(crv), (int) crv, typeof(CoseOkpEllipticCurve)); } diff --git a/src/WebAuthn.Net/Services/Static/X509CertificateInMemoryLoader.cs b/src/WebAuthn.Net/Services/Static/X509CertificateInMemoryLoader.cs index 0cfe563f..aa3be922 100644 --- a/src/WebAuthn.Net/Services/Static/X509CertificateInMemoryLoader.cs +++ b/src/WebAuthn.Net/Services/Static/X509CertificateInMemoryLoader.cs @@ -23,7 +23,9 @@ public static bool TryLoad(byte[] bytes, [NotNullWhen(true)] out X509Certificate X509Certificate2? cert = null; try { +#pragma warning disable SYSLIB0057 cert = new(bytes, password, keyStorageFlags); +#pragma warning restore SYSLIB0057 if (cert.GetRSAPublicKey() is { } rsaPublicKey) { rsaPublicKey.Dispose(); diff --git a/src/WebAuthn.Net/Storage/Credential/Models/CredentialPublicKeyRecord.cs b/src/WebAuthn.Net/Storage/Credential/Models/CredentialPublicKeyRecord.cs index 2ae60bb2..41d20466 100644 --- a/src/WebAuthn.Net/Storage/Credential/Models/CredentialPublicKeyRecord.cs +++ b/src/WebAuthn.Net/Storage/Credential/Models/CredentialPublicKeyRecord.cs @@ -35,7 +35,7 @@ public CredentialPublicKeyRecord( CredentialPublicKeyOkpParametersRecord? okp) { // kty - if (!Enum.IsDefined(typeof(CoseKeyType), kty)) + if (!Enum.IsDefined(kty)) { throw new InvalidEnumArgumentException(nameof(kty), (int) kty, typeof(CoseKeyType)); } @@ -43,7 +43,7 @@ public CredentialPublicKeyRecord( Kty = kty; // alg - if (!Enum.IsDefined(typeof(CoseAlgorithm), alg)) + if (!Enum.IsDefined(alg)) { throw new InvalidEnumArgumentException(nameof(alg), (int) alg, typeof(CoseAlgorithm)); } diff --git a/src/WebAuthn.Net/Storage/Credential/Models/CredentialRecord.cs b/src/WebAuthn.Net/Storage/Credential/Models/CredentialRecord.cs index 02a5fa75..53485e5a 100644 --- a/src/WebAuthn.Net/Storage/Credential/Models/CredentialRecord.cs +++ b/src/WebAuthn.Net/Storage/Credential/Models/CredentialRecord.cs @@ -74,7 +74,7 @@ public CredentialRecord( byte[]? attestationObject, byte[]? attestationClientDataJson) { - if (!Enum.IsDefined(typeof(PublicKeyCredentialType), type)) + if (!Enum.IsDefined(type)) { throw new InvalidEnumArgumentException(nameof(type), (int) type, typeof(PublicKeyCredentialType)); } diff --git a/src/WebAuthn.Net/WebAuthn.Net.csproj b/src/WebAuthn.Net/WebAuthn.Net.csproj index 1659af5c..91fb5028 100644 --- a/src/WebAuthn.Net/WebAuthn.Net.csproj +++ b/src/WebAuthn.Net/WebAuthn.Net.csproj @@ -1,7 +1,7 @@ - net6.0;net8.0 + net8.0;net9.0 false LICENSE true @@ -26,20 +26,20 @@ - - - - - - - - - + + + + + + + + + diff --git a/tests/WebAuthn.Net.Tests.Unit/WebAuthn.Net.Tests.Unit.csproj b/tests/WebAuthn.Net.Tests.Unit/WebAuthn.Net.Tests.Unit.csproj index 0e5fade6..ec5baefb 100644 --- a/tests/WebAuthn.Net.Tests.Unit/WebAuthn.Net.Tests.Unit.csproj +++ b/tests/WebAuthn.Net.Tests.Unit/WebAuthn.Net.Tests.Unit.csproj @@ -1,21 +1,21 @@ - net6.0;net8.0 + net8.0;net9.0 false WebAuthn.Net - $(NoWarn),CA1034,CA1812 + $(NoWarn);CA1034;CA1515;CA1707;CA1812;CA2007 - - + + - + all runtime; build; native; contentfiles; analyzers; buildtransitive - + all runtime; build; native; contentfiles; analyzers; buildtransitive