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

Upgrade TFM to net6, net7 & net8 #585

Open
wants to merge 37 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
81ea94a
Update dotnetcore.yml
ycrumeyrolle Dec 8, 2021
3d18959
Update JsonWebToken.csproj
ycrumeyrolle Dec 8, 2021
9679ba8
Remove netcoreapp2.1 (deprecated)
ycrumeyrolle Dec 8, 2021
588fd53
Add support for net7 & net8
ycrumeyrolle Apr 22, 2024
be2b43b
Remove support of netcoreapp and net5, add support of net7 and net8
ycrumeyrolle Apr 23, 2024
a27343c
fix support for net7 & net8
ycrumeyrolle Jul 21, 2024
a4b440d
net8
ycrumeyrolle Jul 21, 2024
255dfc5
fix CI for net8
ycrumeyrolle Jul 21, 2024
1e25d81
Merge branch 'master' into net6
ycrumeyrolle Jul 21, 2024
c206778
disable openssl fix for macos
ycrumeyrolle Jul 21, 2024
41d22ee
Merge branch 'net6' of https://github.com/uruk-project/Jwt into net6
ycrumeyrolle Jul 21, 2024
64b41e1
try fix
ycrumeyrolle Jul 21, 2024
4a72ad8
try fix2
ycrumeyrolle Jul 21, 2024
995af43
try fix 3
ycrumeyrolle Jul 21, 2024
2ad6f28
try fix 4
ycrumeyrolle Jul 21, 2024
8e52d85
try reduce impact of fix
ycrumeyrolle Jul 21, 2024
91a2dc8
fix
ycrumeyrolle Jul 21, 2024
e06910e
update gh actions versions
ycrumeyrolle Jul 21, 2024
76b9048
Fix warnings
ycrumeyrolle Jul 21, 2024
a085094
fix
ycrumeyrolle Jul 21, 2024
8fbd6ea
fix
ycrumeyrolle Jul 21, 2024
c00bde2
fix
ycrumeyrolle Jul 21, 2024
065e745
updates
ycrumeyrolle Jul 21, 2024
f90f3ee
Nits
ycrumeyrolle Jul 21, 2024
8d2ab87
Merge branch 'master' into net6
ycrumeyrolle Jul 21, 2024
cd1e228
update benchmark workflow
ycrumeyrolle Jul 21, 2024
62e6bb4
fix warning
ycrumeyrolle Jul 21, 2024
64f3f5b
Fix warnings
ycrumeyrolle Jul 21, 2024
de30c6c
update codecov
ycrumeyrolle Jul 21, 2024
5b82bc7
update gh workflow
ycrumeyrolle Jul 21, 2024
e1329fa
fix
ycrumeyrolle Jul 21, 2024
bf3a7f7
renable macos tests
ycrumeyrolle Jul 21, 2024
dfebe10
fix
ycrumeyrolle Jul 21, 2024
dbe63db
fix
ycrumeyrolle Jul 21, 2024
7333dd1
fix
ycrumeyrolle Jul 21, 2024
4031fbd
nits
ycrumeyrolle Jul 21, 2024
bac5aa2
fix macos
ycrumeyrolle Jul 21, 2024
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
4 changes: 4 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[*.cs]

# IDE0090: Utiliser 'new(...)'
dotnet_diagnostic.IDE0090.severity = none
23 changes: 9 additions & 14 deletions .github/workflows/benchmarks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,27 +19,22 @@ jobs:
NUGET_PACKAGES: ${{ github.workspace }}/.nuget/packages

steps:
- uses: actions/checkout@master
- name: Setup dotnet '1.1.x'
uses: actions/setup-dotnet@v1
- uses: actions/checkout@v4
- name: Setup dotnet
uses: actions/setup-dotnet@v4
with:
dotnet-version: '2.1.x'
- name: Setup dotnet '3.1.x'
uses: actions/setup-dotnet@v1
with:
dotnet-version: '3.1.x'
- name: Setup dotnet '5.x'
uses: actions/setup-dotnet@v1
with:
dotnet-version: '5.0.100'
dotnet-version: |
6.x
7.x
8.x
- name: Install dependencies
run: dotnet restore
- name: Build
run: dotnet build --configuration Release --no-restore
- name: Validate Benchmark
run: dotnet run -c Release -f net5 -p ./perf/Benchmarks -- --filter JsonWebToken.Performance.Validate* --join
run: dotnet run -c Release -f net8 -p ./perf/Benchmarks -- --filter JsonWebToken.Performance.Validate* --join
- name: Write Benchmark
run: dotnet run -c Release -f net5 -p ./perf/Benchmarks -- --filter JsonWebToken.Performance.Write* --join
run: dotnet run -c Release -f net8 -p ./perf/Benchmarks -- --filter JsonWebToken.Performance.Write* --join
- name: Upload results
uses: actions/upload-artifact@v2
with:
Expand Down
50 changes: 23 additions & 27 deletions .github/workflows/dotnetcore.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@ jobs:
- os: ubuntu-latest
configuration: Release
is-main: true
- os: windows-latest
configuration: Release
is-netfx: true
env:
DOTNET_CLI_TELEMETRY_OPTOUT: 1
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1
Expand All @@ -38,28 +35,20 @@ jobs:
DYLD_FALLBACK_LIBRARY_PATH: /usr/local/Cellar/[email protected]/

steps:
- uses: actions/checkout@v2
- name: Checkout
uses: actions/checkout@v4
# - name: Setup OpenSSL (macOS)
# if: matrix.os == 'macos-latest'
# run: |
# wget https://www.openssl.org/source/openssl-1.1.1c.tar.gz
# tar -xzvf openssl-1.1.1c.tar.gz
# cd openssl-1.1.1c
# ./config
# make
# sudo make install
- name: setup dotnet '2.2.x'
uses: actions/setup-dotnet@v1
with:
dotnet-version: '2.2.x'
- name: Setup dotnet '3.1.x'
uses: actions/setup-dotnet@v1
with:
dotnet-version: '3.1.x'
- name: Setup dotnet '5.x'
uses: actions/setup-dotnet@v1
# ln -s /usr/local/opt/[email protected]/lib/libssl.1.1.dylib /usr/local/lib/libssl.1.1.dylib
# ln -s /usr/local/opt/[email protected]/lib/libcrypto.1.1.dylib /usr/local/lib/libcrypto.1.1.dylib
- name: Setup dotnet
uses: actions/setup-dotnet@v4
with:
dotnet-version: '5.0.x'
dotnet-version: |
6.x
7.x
8.x

- name: Restore dependencies
run: dotnet restore
Expand All @@ -69,12 +58,19 @@ jobs:

- name: Test
# disable macOS tests
if: matrix.os != 'macos-latest'
run: dotnet test -c ${{ matrix.configuration }} --no-build --collect:"XPlat Code Coverage" --settings coverlet.runsettings
# if: matrix.os != 'macos-latest'
run: dotnet test -c ${{ matrix.configuration }} --no-build --collect:"XPlat Code Coverage" --settings coverlet.runsettings --logger trx --results-directory "TestResults"

- name: Upload dotnet test results
if: ${{ always() }}
uses: actions/upload-artifact@v4
with:
name: dotnet-results-${{ matrix.configuration }}-${{ matrix.os }}
path: TestResults

- name: Upload coverage to Codecov
if: matrix.is-netfx
uses: codecov/codecov-action@v1
if: matrix.is-main
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}

Expand All @@ -83,7 +79,7 @@ jobs:
run: dotnet pack -c ${{ matrix.configuration }} --output=nuget_packed --no-build
- name: Upload NuGet packages to Artifacts
if: matrix.is-main
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
name: nuget-packages
path: |
Expand All @@ -102,7 +98,7 @@ jobs:
NUGET_PACKAGES: ${{ github.workspace }}/.nuget/packages
steps:
- name: Download generated NuGet packages
uses: actions/download-artifact@v2
uses: actions/download-artifact@v4
with:
name: nuget-packages
- name: Push packages to api.nuget.org
Expand Down
17 changes: 9 additions & 8 deletions Jwt.sln
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.28531.58
# Visual Studio Version 17
VisualStudioVersion = 17.9.34728.123
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{BD2706C5-6C57-484D-89C8-A0CF5F8E3D19}"
ProjectSection(SolutionItems) = preProject
Expand All @@ -24,6 +24,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "JsonWebToken.KeyVault", "sr
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{81504C49-6E6B-499F-B2EE-10C5E5B69614}"
ProjectSection(SolutionItems) = preProject
.editorconfig = .editorconfig
Benchmark.md = Benchmark.md
.github\workflows\benchmarks.yml = .github\workflows\benchmarks.yml
BreakingChanges.md = BreakingChanges.md
Expand Down Expand Up @@ -93,21 +94,21 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "docs", "docs", "{45F5CD67-C
docs\Performance_considerations.md = docs\Performance_considerations.md
docs\Security_considerations.md = docs\Security_considerations.md
docs\Validate_JWE.md = docs\Validate_JWE.md
docs\validate_jwe_allocated.png = docs\validate_jwe_allocated.png
docs\validate_jwe_ops.png = docs\validate_jwe_ops.png
docs\validate_jwec_allocated.png = docs\validate_jwec_allocated.png
docs\validate_jwec_ops.png = docs\validate_jwec_ops.png
docs\validate_jwe_allocated.png = docs\validate_jwe_allocated.png
docs\validate_jwe_ops.png = docs\validate_jwe_ops.png
docs\validate_jwsi_allocated.png = docs\validate_jwsi_allocated.png
docs\validate_jwsi_ops.png = docs\validate_jwsi_ops.png
docs\validate_jws_allocated.png = docs\validate_jws_allocated.png
docs\Validate_JWS_EC.md = docs\Validate_JWS_EC.md
docs\Validate_JWS_HMAC.md = docs\Validate_JWS_HMAC.md
docs\validate_jws_ops.png = docs\validate_jws_ops.png
docs\Validate_JWS_RSA.md = docs\Validate_JWS_RSA.md
docs\validate_jwsi_allocated.png = docs\validate_jwsi_allocated.png
docs\validate_jwsi_ops.png = docs\validate_jwsi_ops.png
docs\write_jwe_allocated.png = docs\write_jwe_allocated.png
docs\write_jwe_ops.png = docs\write_jwe_ops.png
docs\write_jwec_allocated.png = docs\write_jwec_allocated.png
docs\write_jwec_ops.png = docs\write_jwec_ops.png
docs\write_jwe_allocated.png = docs\write_jwe_allocated.png
docs\write_jwe_ops.png = docs\write_jwe_ops.png
docs\write_jws_allocated.png = docs\write_jws_allocated.png
docs\write_jws_ops.png = docs\write_jws_ops.png
EndProjectSection
Expand Down
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,10 @@ The main reason of the efficiency of this library is the usage of the new API pr
| RS256 | RSASSA-PKCS1-v1_5 using SHA-256 | netstandard2.0
| RS384 | RSASSA-PKCS1-v1_5 using SHA-384 | netstandard2.0
| RS512 | RSASSA-PKCS1-v1_5 using SHA-512 | netstandard2.0
| ES256 | ECDSA using curve P-256 and SHA-256 | netcoreapp2.1
| ES384 | ECDSA using curve P-384 and SHA-384 | netcoreapp2.1
| ES512 | ECDSA using curve P-521 and SHA-512 | netcoreapp2.1
| ES256K | ECDSA using curve secp256k1 and SHA-256 | netcoreapp2.1 (not available on MacOS)
| ES256 | ECDSA using curve P-256 and SHA-256 | netcoreapp2.2
| ES384 | ECDSA using curve P-384 and SHA-384 | netcoreapp2.2
| ES512 | ECDSA using curve P-521 and SHA-512 | netcoreapp2.2
| ES256K | ECDSA using curve secp256k1 and SHA-256 | netcoreapp2.2 (not available on MacOS)
| PS256 | RSASSA-PSS using SHA-256 and MGF1 with SHA-256 | netstandard2.0
| PS384 | RSASSA-PSS using SHA-384 and MGF1 with SHA-384 | netstandard2.0
| PS512 | RSASSA-PSS using SHA-512 and MGF1 with SHA-512 | netstandard2.0
Expand All @@ -155,10 +155,10 @@ The main reason of the efficiency of this library is the usage of the new API pr
| A192KW | AES Key Wrap with default initial value using 192-bit key | netstandard2.0
| A256KW | AES Key Wrap with default initial value using 256-bit key | netstandard2.0
| dir | Direct use of a shared symmetric key as the CEK | netstandard2.0
| ECDH-ES | Elliptic Curve Diffie-Hellman Ephemeral Static key agreement using Concat KDF | netcoreapp2.1
| ECDH-ES+A128KW | ECDH-ES using Concat KDF and CEK wrapped with "A128KW" | netcoreapp2.1
| ECDH-ES+A192KW | ECDH-ES using Concat KDF and CEK wrapped with "A192KW" | netcoreapp2.1
| ECDH-ES+A256KW | ECDH-ES using Concat KDF and CEK wrapped with "A256KW" | netcoreapp2.1
| ECDH-ES | Elliptic Curve Diffie-Hellman Ephemeral Static key agreement using Concat KDF | netcoreapp2.2
| ECDH-ES+A128KW | ECDH-ES using Concat KDF and CEK wrapped with "A128KW" | netcoreapp2.2
| ECDH-ES+A192KW | ECDH-ES using Concat KDF and CEK wrapped with "A192KW" | netcoreapp2.2
| ECDH-ES+A256KW | ECDH-ES using Concat KDF and CEK wrapped with "A256KW" | netcoreapp2.2
| A128GCMKW | Key wrapping with AES GCM using 128-bit key | netcoreapp3.0
| A192GCMKW | Key wrapping with AES GCM using 192-bit key | netcoreapp3.0
| A256GCMKW | Key wrapping with AES GCM using 256-bit key | netcoreapp3.0
Expand Down
2 changes: 1 addition & 1 deletion fuzz/FuzzTest/FuzzTest.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<IsPackable>false</IsPackable>
<GeneratePackageOnBuild>false</GeneratePackageOnBuild>
</PropertyGroup>
Expand Down
100 changes: 52 additions & 48 deletions perf/Benchmarks/Benchmarks.csproj
Original file line number Diff line number Diff line change
@@ -1,57 +1,61 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netcoreapp3.1;net5</TargetFrameworks>
<GeneratePackageOnBuild>false</GeneratePackageOnBuild>
<IsPackable>false</IsPackable>
</PropertyGroup>
<PropertyGroup>
<TargetFrameworks>net6.0;net7.0;net8.0</TargetFrameworks>
<GeneratePackageOnBuild>false</GeneratePackageOnBuild>
<IsPackable>false</IsPackable>
</PropertyGroup>

<PropertyGroup>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<OutputType>Exe</OutputType>
<GenerateDocumentationFile>false</GenerateDocumentationFile>
<PlatformTarget>AnyCPU</PlatformTarget>
<LangVersion>9.0</LangVersion>
<Nullable>enable</Nullable>
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>../../jwt.snk</AssemblyOriginatorKeyFile>
<GeneratePackageOnBuild>false</GeneratePackageOnBuild>
<DebugType>pdbonly</DebugType>
<DebugSymbols>true</DebugSymbols>
</PropertyGroup>
<PropertyGroup>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<OutputType>Exe</OutputType>
<GenerateDocumentationFile>false</GenerateDocumentationFile>
<PlatformTarget>AnyCPU</PlatformTarget>
<LangVersion>9.0</LangVersion>
<Nullable>enable</Nullable>
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>../../jwt.snk</AssemblyOriginatorKeyFile>
<GeneratePackageOnBuild>false</GeneratePackageOnBuild>
<DebugType>pdbonly</DebugType>
<DebugSymbols>true</DebugSymbols>
</PropertyGroup>

<PropertyGroup>
<NoWarn>1701;1702;8002</NoWarn>
</PropertyGroup>
<PropertyGroup>
<NoWarn>1701;1702;8002</NoWarn>
</PropertyGroup>


<ItemGroup Condition=" '$(TargetFrameworkIdentifier)' == '.NETFramework' ">
<Reference Include="System.Reflection" />
</ItemGroup>
<ItemGroup>
<Compile Remove="BenchmarkDotNet.Artifacts\results\**" />
<EmbeddedResource Remove="BenchmarkDotNet.Artifacts\results\**" />
<None Remove="BenchmarkDotNet.Artifacts\results\**" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="BenchmarkDotNet" Version="0.12.1" />
<PackageReference Include="jose-jwt" Version="2.6.0" />
<PackageReference Include="JWT" Version="7.2.2" />
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="6.8.0" />
<PackageReference Include="Microsoft.IdentityModel.JsonWebTokens" Version="6.8.0" />
<PackageReference Include="gfoidl.Base64" Version="1.1.1" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\src\JsonWebToken\JsonWebToken.csproj" />
</ItemGroup>
<ItemGroup>
<None Update="resources\payloads.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="resources\tokens.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
<ItemGroup Condition=" '$(TargetFrameworkIdentifier)' == '.NETFramework' ">
<Reference Include="System.Reflection" />
</ItemGroup>
<ItemGroup>
<Compile Remove="BenchmarkDotNet.Artifacts\results\**" />
<EmbeddedResource Remove="BenchmarkDotNet.Artifacts\results\**" />
<None Remove="BenchmarkDotNet.Artifacts\results\**" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="BenchmarkDotNet" Version="0.13.12" />
<PackageReference Include="jose-jwt" Version="5.0.0" />
<PackageReference Include="JWT" Version="10.1.1" />
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="7.5.1" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'net6.0'">
<PackageReference Include="gfoidl.Base64" Version="1.1.1" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' != 'net6.0'">
<PackageReference Include="gfoidl.Base64" Version="2.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\src\JsonWebToken\JsonWebToken.csproj" />
</ItemGroup>
<ItemGroup>
<None Update="resources\payloads.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="resources\tokens.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>


</Project>
16 changes: 9 additions & 7 deletions perf/Benchmarks/Internal/Tokens.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ private static IDictionary<string, JwtDescriptor> CreateDescriptors(IDictionary<
descriptor.Payload!.Add(property.Name, (long)property.Value);
break;
default:
descriptor.Payload!.Add(property.Name, (string)property.Value);
descriptor.Payload!.Add(property.Name, (string)property.Value!);
break;
}
}
Expand All @@ -130,7 +130,7 @@ private static IDictionary<string, JwtDescriptor> CreateDescriptors(IDictionary<
descriptor.Payload!.Add(property.Name, (long)property.Value);
break;
default:
descriptor.Payload!.Add(property.Name, (string)property.Value);
descriptor.Payload!.Add(property.Name, (string)property.Value!);
break;
}
}
Expand All @@ -152,7 +152,7 @@ private static IDictionary<string, JwtDescriptor> CreateDescriptors(IDictionary<
descriptor.Payload!.Add(property.Name, (long)property.Value);
break;
default:
descriptor.Payload!.Add(property.Name, (string)property.Value);
descriptor.Payload!.Add(property.Name, (string)property.Value!);
break;
}
}
Expand All @@ -179,7 +179,7 @@ private static IDictionary<string, JwtDescriptor> CreateDescriptors(IDictionary<
descriptor.Payload!.Add(property.Name, (long)property.Value);
break;
default:
descriptor.Payload!.Add(property.Name, (string)property.Value);
descriptor.Payload!.Add(property.Name, (string)property.Value!);
break;
}
}
Expand Down Expand Up @@ -312,10 +312,10 @@ private static JwsDescriptor CreateJws(Jwk signingKey, JObject descriptor, Token
}


switch (kvp.Value.Type)
switch (kvp.Value?.Type)
{
case JTokenType.Object:
payload.Add(kvp.Key, (object)kvp.Value);
payload.Add(kvp.Key, kvp.Value);
break;
case JTokenType.Array:
payload.Add(kvp.Key, (object[])(object)kvp.Value);
Expand All @@ -327,14 +327,16 @@ private static JwsDescriptor CreateJws(Jwk signingKey, JObject descriptor, Token
payload.Add(kvp.Key, (double)kvp.Value);
break;
case JTokenType.String:
payload.Add(kvp.Key, (string)kvp.Value);
payload.Add(kvp.Key, (string)kvp.Value!);
break;
case JTokenType.Boolean:
payload.Add(kvp.Key, (bool)kvp.Value);
break;
case JTokenType.Null:
payload.Add(kvp.Key, (object)kvp.Value);
break;
default:
break;
}
}

Expand Down
Loading