From 5dc6a7e8d4ee893a2055575537b644d7ab5d242a Mon Sep 17 00:00:00 2001 From: witskeeper Date: Fri, 29 Sep 2023 21:49:14 +0800 Subject: [PATCH] update to net6.0 net7.0 net8.0 --- .github/workflows/ci.yml | 6 +- .github/workflows/dotnet.yml | 26 ++++ Directory.Build.props | 3 + NuGet.config | 2 - eng/versions.props | 7 + global.json | 4 +- netcorepal.identityserver4.sln | 85 ++++++++++++ .../src/IdentityServer4.AspNetIdentity.csproj | 8 +- src/Directory.Build.targets | 128 ++++++++++-------- ...tityServer4.EntityFramework.Storage.csproj | 9 +- ...r4.EntityFramework.IntegrationTests.csproj | 8 +- .../Stores/DeviceFlowStoreTests.cs | 2 +- ...tyServer4.EntityFramework.UnitTests.csproj | 2 +- .../Mappers/ApiResourceMappersTests.cs | 2 +- .../UnitTests/Mappers/ClientMappersTests.cs | 2 +- .../Mappers/IdentityResourcesMappersTests.cs | 2 +- .../Mappers/PersistedGrantMappersTests.cs | 2 +- .../UnitTests/Mappers/ScopeMappersTests.cs | 2 +- .../IdentityServer4.EntityFramework.csproj | 10 +- ...entityServer4.EntityFramework.Tests.csproj | 2 +- .../src/Extensions/CustomJwtPayload.cs | 21 +++ .../src/Extensions/TokenExtensions.cs | 2 +- .../src/IdentityServer4.csproj | 97 +++++++------ .../Validation/Default/JwtRequestValidator.cs | 33 +++-- .../Clients/ClientAssertionClient.cs | 68 +++++----- .../CustomTokenRequestValidatorClient.cs | 8 +- .../Clients/CustomTokenResponseClients.cs | 38 +++--- .../Clients/UserInfoClient.cs | 3 +- .../Common/IdentityServerPipeline.cs | 4 +- .../Endpoints/Authorize/AuthorizeTests.cs | 49 ++++--- .../Endpoints/Authorize/ConsentTests.cs | 23 ++-- .../Authorize/JwtRequestAuthorizeTests.cs | 93 ++++++------- .../Introspection/IntrospectionTests.cs | 64 ++++----- .../IdentityServer.IntegrationTests.csproj | 66 +++++---- .../JsonExtensions.cs | 17 +++ .../IdentityServer.UnitTests.csproj | 4 +- .../src/IdentityServer4.Storage.csproj | 75 +++++----- 37 files changed, 582 insertions(+), 395 deletions(-) create mode 100644 .github/workflows/dotnet.yml create mode 100644 Directory.Build.props create mode 100644 eng/versions.props create mode 100644 netcorepal.identityserver4.sln create mode 100644 src/IdentityServer4/src/Extensions/CustomJwtPayload.cs create mode 100644 src/IdentityServer4/test/IdentityServer.IntegrationTests/JsonExtensions.cs diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8fde5e98fa..aa51983b6d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -3,10 +3,8 @@ name: 'CI' on: push: branches: - - main - - features/** - tags: - - '*.*.*' + - mainx + - featuresx/** pull_request: env: diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml new file mode 100644 index 0000000000..7ea66e0e29 --- /dev/null +++ b/.github/workflows/dotnet.yml @@ -0,0 +1,26 @@ +name: preview build + +on: + push: + branches: [ netcorepal ] + pull_request: + branches: [ netcorepal ] +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Setup .NET + uses: actions/setup-dotnet@v3 + with: + global-json-file: global.json + - name: Restore dependencies + run: dotnet restore + - name: Build + run: dotnet build -c Release --no-restore + - name: Test + run: dotnet test # --verbosity normal + - name: Pack NuGet + run: dotnet pack -c Release --version-suffix preview.1.`date +%y%m%d%H%M` -o ./ -p:IncludeSymbols=true -p:SymbolPackageFormat=snupkg + - name: Push MyGet + run: dotnet nuget push '*.nupkg' -s https://www.myget.org/F/netcorepal/api/v3/index.json -k ${{ secrets.MYGET_API_KEY }} --skip-duplicate diff --git a/Directory.Build.props b/Directory.Build.props new file mode 100644 index 0000000000..709711db7f --- /dev/null +++ b/Directory.Build.props @@ -0,0 +1,3 @@ + + + diff --git a/NuGet.config b/NuGet.config index a347cc617a..3ed18e229b 100644 --- a/NuGet.config +++ b/NuGet.config @@ -1,8 +1,6 @@ - - \ No newline at end of file diff --git a/eng/versions.props b/eng/versions.props new file mode 100644 index 0000000000..025d07359b --- /dev/null +++ b/eng/versions.props @@ -0,0 +1,7 @@ + + + 0.1.0 + + NetCorePal.$(AssemblyName) + + diff --git a/global.json b/global.json index 3b1b3a1854..e2f820959d 100644 --- a/global.json +++ b/global.json @@ -1,5 +1,7 @@ { "sdk": { - "version": "6.0.406" + "version": "8.0.100-preview.7.23376.3", + "allowPrerelease": true, + "rollForward": "latestMinor" } } \ No newline at end of file diff --git a/netcorepal.identityserver4.sln b/netcorepal.identityserver4.sln new file mode 100644 index 0000000000..61b05c1407 --- /dev/null +++ b/netcorepal.identityserver4.sln @@ -0,0 +1,85 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.0.31903.59 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IdentityServer4", "src\IdentityServer4\src\IdentityServer4.csproj", "{95E6BE6A-9EE0-42CD-B341-AB5119327085}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IdentityServer4.EntityFramework", "src\EntityFramework\src\IdentityServer4.EntityFramework.csproj", "{19C53216-A194-4A67-B325-7C151B3123FE}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IdentityServer4.EntityFramework.Storage", "src\EntityFramework.Storage\src\IdentityServer4.EntityFramework.Storage.csproj", "{657D452F-CE20-492D-80D8-BF64587856D2}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IdentityServer4.Storage", "src\Storage\src\IdentityServer4.Storage.csproj", "{21812066-32ED-4A27-B216-0B7D8407A256}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IdentityServer4.AspNetIdentity", "src\AspNetIdentity\src\IdentityServer4.AspNetIdentity.csproj", "{E0630A5C-DE93-471C-843D-55F2F5CBBA94}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IdentityServer.UnitTests", "src\IdentityServer4\test\IdentityServer.UnitTests\IdentityServer.UnitTests.csproj", "{27C2B16B-6270-4AAA-9C9D-A36F31788E45}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{BC762CB2-A04C-4945-815A-C654EFCB46F4}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IdentityServer.IntegrationTests", "src\IdentityServer4\test\IdentityServer.IntegrationTests\IdentityServer.IntegrationTests.csproj", "{D6B44DFB-E63C-44D3-82C8-0AD290800D93}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IdentityServer4.EntityFramework.UnitTests", "src\EntityFramework.Storage\test\UnitTests\IdentityServer4.EntityFramework.UnitTests.csproj", "{9EC1AEE6-8AE3-4FEC-9F15-64D7E9AB256A}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IdentityServer4.EntityFramework.IntegrationTests", "src\EntityFramework.Storage\test\IntegrationTests\IdentityServer4.EntityFramework.IntegrationTests.csproj", "{2E7CC7A4-482F-4938-985A-BBFF8F78E773}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IdentityServer4.EntityFramework.Tests", "src\EntityFramework\test\IdentityServer4.EntityFramework.Tests\IdentityServer4.EntityFramework.Tests.csproj", "{9BB5E9C0-96B9-4C09-A3C4-17E5E79F452E}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {95E6BE6A-9EE0-42CD-B341-AB5119327085}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {95E6BE6A-9EE0-42CD-B341-AB5119327085}.Debug|Any CPU.Build.0 = Debug|Any CPU + {95E6BE6A-9EE0-42CD-B341-AB5119327085}.Release|Any CPU.ActiveCfg = Release|Any CPU + {95E6BE6A-9EE0-42CD-B341-AB5119327085}.Release|Any CPU.Build.0 = Release|Any CPU + {19C53216-A194-4A67-B325-7C151B3123FE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {19C53216-A194-4A67-B325-7C151B3123FE}.Debug|Any CPU.Build.0 = Debug|Any CPU + {19C53216-A194-4A67-B325-7C151B3123FE}.Release|Any CPU.ActiveCfg = Release|Any CPU + {19C53216-A194-4A67-B325-7C151B3123FE}.Release|Any CPU.Build.0 = Release|Any CPU + {657D452F-CE20-492D-80D8-BF64587856D2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {657D452F-CE20-492D-80D8-BF64587856D2}.Debug|Any CPU.Build.0 = Debug|Any CPU + {657D452F-CE20-492D-80D8-BF64587856D2}.Release|Any CPU.ActiveCfg = Release|Any CPU + {657D452F-CE20-492D-80D8-BF64587856D2}.Release|Any CPU.Build.0 = Release|Any CPU + {21812066-32ED-4A27-B216-0B7D8407A256}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {21812066-32ED-4A27-B216-0B7D8407A256}.Debug|Any CPU.Build.0 = Debug|Any CPU + {21812066-32ED-4A27-B216-0B7D8407A256}.Release|Any CPU.ActiveCfg = Release|Any CPU + {21812066-32ED-4A27-B216-0B7D8407A256}.Release|Any CPU.Build.0 = Release|Any CPU + {E0630A5C-DE93-471C-843D-55F2F5CBBA94}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E0630A5C-DE93-471C-843D-55F2F5CBBA94}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E0630A5C-DE93-471C-843D-55F2F5CBBA94}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E0630A5C-DE93-471C-843D-55F2F5CBBA94}.Release|Any CPU.Build.0 = Release|Any CPU + {27C2B16B-6270-4AAA-9C9D-A36F31788E45}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {27C2B16B-6270-4AAA-9C9D-A36F31788E45}.Debug|Any CPU.Build.0 = Debug|Any CPU + {27C2B16B-6270-4AAA-9C9D-A36F31788E45}.Release|Any CPU.ActiveCfg = Release|Any CPU + {27C2B16B-6270-4AAA-9C9D-A36F31788E45}.Release|Any CPU.Build.0 = Release|Any CPU + {D6B44DFB-E63C-44D3-82C8-0AD290800D93}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D6B44DFB-E63C-44D3-82C8-0AD290800D93}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D6B44DFB-E63C-44D3-82C8-0AD290800D93}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D6B44DFB-E63C-44D3-82C8-0AD290800D93}.Release|Any CPU.Build.0 = Release|Any CPU + {9EC1AEE6-8AE3-4FEC-9F15-64D7E9AB256A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {9EC1AEE6-8AE3-4FEC-9F15-64D7E9AB256A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {9EC1AEE6-8AE3-4FEC-9F15-64D7E9AB256A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {9EC1AEE6-8AE3-4FEC-9F15-64D7E9AB256A}.Release|Any CPU.Build.0 = Release|Any CPU + {2E7CC7A4-482F-4938-985A-BBFF8F78E773}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {2E7CC7A4-482F-4938-985A-BBFF8F78E773}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2E7CC7A4-482F-4938-985A-BBFF8F78E773}.Release|Any CPU.ActiveCfg = Release|Any CPU + {2E7CC7A4-482F-4938-985A-BBFF8F78E773}.Release|Any CPU.Build.0 = Release|Any CPU + {9BB5E9C0-96B9-4C09-A3C4-17E5E79F452E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {9BB5E9C0-96B9-4C09-A3C4-17E5E79F452E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {9BB5E9C0-96B9-4C09-A3C4-17E5E79F452E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {9BB5E9C0-96B9-4C09-A3C4-17E5E79F452E}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(NestedProjects) = preSolution + {27C2B16B-6270-4AAA-9C9D-A36F31788E45} = {BC762CB2-A04C-4945-815A-C654EFCB46F4} + {D6B44DFB-E63C-44D3-82C8-0AD290800D93} = {BC762CB2-A04C-4945-815A-C654EFCB46F4} + {9EC1AEE6-8AE3-4FEC-9F15-64D7E9AB256A} = {BC762CB2-A04C-4945-815A-C654EFCB46F4} + {2E7CC7A4-482F-4938-985A-BBFF8F78E773} = {BC762CB2-A04C-4945-815A-C654EFCB46F4} + {9BB5E9C0-96B9-4C09-A3C4-17E5E79F452E} = {BC762CB2-A04C-4945-815A-C654EFCB46F4} + EndGlobalSection +EndGlobal diff --git a/src/AspNetIdentity/src/IdentityServer4.AspNetIdentity.csproj b/src/AspNetIdentity/src/IdentityServer4.AspNetIdentity.csproj index fd77a97050..d6d2bbc415 100644 --- a/src/AspNetIdentity/src/IdentityServer4.AspNetIdentity.csproj +++ b/src/AspNetIdentity/src/IdentityServer4.AspNetIdentity.csproj @@ -2,7 +2,7 @@ IdentityServer4.AspNetIdentity - netcoreapp3.1 + net6.0;net7.0;net8.0 ASP.NET Core Identity Integration for IdentityServer4 Brock Allen;Dominick Baier @@ -39,9 +39,11 @@ - - + + + + \ No newline at end of file diff --git a/src/Directory.Build.targets b/src/Directory.Build.targets index 40764d237a..b77937693a 100644 --- a/src/Directory.Build.targets +++ b/src/Directory.Build.targets @@ -1,70 +1,78 @@ + + 6.0.0 + 6.0.0 + 7.0.11 + 4.1.2-* + + + 7.0.0 + 7.0.0 + 7.0.11 + 4.1.2-* + + + 8.0.0-preview.7.23375.9 + 8.0.0-preview.7.23375.9 + 7.0.11 + 4.1.2-* + + + + + + + - - 3.1.0 - 3.1.0 - 3.1.0 - - 4.1.2-* - + + + + + - - - - - - + + + + + + + - - - - - + + + + + + + - - + + + + + + - - - - - + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + - + - - - $(MinVerMajor).$(MinVerMinor).$(MinVerPatch).0 - - + + + $(MinVerMajor).$(MinVerMinor).$(MinVerPatch).0 + + \ No newline at end of file diff --git a/src/EntityFramework.Storage/src/IdentityServer4.EntityFramework.Storage.csproj b/src/EntityFramework.Storage/src/IdentityServer4.EntityFramework.Storage.csproj index cd8a6c576d..e2c43470d1 100644 --- a/src/EntityFramework.Storage/src/IdentityServer4.EntityFramework.Storage.csproj +++ b/src/EntityFramework.Storage/src/IdentityServer4.EntityFramework.Storage.csproj @@ -2,7 +2,7 @@ IdentityServer4.EntityFramework.Storage - netstandard2.0 + net6.0;net7.0;net8.0 EntityFramework persistence layer for IdentityServer4 Brock Allen;Dominick Baier;Scott Brady @@ -32,12 +32,13 @@ - - - + + + + diff --git a/src/EntityFramework.Storage/test/IntegrationTests/IdentityServer4.EntityFramework.IntegrationTests.csproj b/src/EntityFramework.Storage/test/IntegrationTests/IdentityServer4.EntityFramework.IntegrationTests.csproj index 754006b8ea..117d2c24f8 100644 --- a/src/EntityFramework.Storage/test/IntegrationTests/IdentityServer4.EntityFramework.IntegrationTests.csproj +++ b/src/EntityFramework.Storage/test/IntegrationTests/IdentityServer4.EntityFramework.IntegrationTests.csproj @@ -1,7 +1,7 @@  - netcoreapp3.1 + net6.0;net7.0;net8.0 ../../../../key.snk true @@ -13,18 +13,16 @@ + + - - - - diff --git a/src/EntityFramework.Storage/test/IntegrationTests/Stores/DeviceFlowStoreTests.cs b/src/EntityFramework.Storage/test/IntegrationTests/Stores/DeviceFlowStoreTests.cs index 471deba071..329436d524 100644 --- a/src/EntityFramework.Storage/test/IntegrationTests/Stores/DeviceFlowStoreTests.cs +++ b/src/EntityFramework.Storage/test/IntegrationTests/Stores/DeviceFlowStoreTests.cs @@ -83,7 +83,7 @@ public async Task StoreDeviceAuthorizationAsync_WhenSuccessful_ExpectDataStored( foundDeviceFlowCodes.Should().NotBeNull(); var deserializedData = new PersistentGrantSerializer().Deserialize(foundDeviceFlowCodes?.Data); - deserializedData.CreationTime.Should().BeCloseTo(data.CreationTime); + deserializedData.CreationTime.Should().BeCloseTo(data.CreationTime,TimeSpan.Zero); deserializedData.ClientId.Should().Be(data.ClientId); deserializedData.Lifetime.Should().Be(data.Lifetime); } diff --git a/src/EntityFramework.Storage/test/UnitTests/IdentityServer4.EntityFramework.UnitTests.csproj b/src/EntityFramework.Storage/test/UnitTests/IdentityServer4.EntityFramework.UnitTests.csproj index c350083d45..feeefd0fec 100644 --- a/src/EntityFramework.Storage/test/UnitTests/IdentityServer4.EntityFramework.UnitTests.csproj +++ b/src/EntityFramework.Storage/test/UnitTests/IdentityServer4.EntityFramework.UnitTests.csproj @@ -1,7 +1,7 @@  - netcoreapp3.1 + net6.0;net7.0;net8.0 ../../../../key.snk true diff --git a/src/EntityFramework.Storage/test/UnitTests/Mappers/ApiResourceMappersTests.cs b/src/EntityFramework.Storage/test/UnitTests/Mappers/ApiResourceMappersTests.cs index ec55c1a66b..b297caff57 100644 --- a/src/EntityFramework.Storage/test/UnitTests/Mappers/ApiResourceMappersTests.cs +++ b/src/EntityFramework.Storage/test/UnitTests/Mappers/ApiResourceMappersTests.cs @@ -15,7 +15,7 @@ public class ApiResourceMappersTests [Fact] public void AutomapperConfigurationIsValid() { - ApiResourceMappers.Mapper.ConfigurationProvider.AssertConfigurationIsValid(); + ApiResourceMappers.Mapper.ConfigurationProvider.AssertConfigurationIsValid(); } [Fact] diff --git a/src/EntityFramework.Storage/test/UnitTests/Mappers/ClientMappersTests.cs b/src/EntityFramework.Storage/test/UnitTests/Mappers/ClientMappersTests.cs index 99a0e44593..91ac1b01fd 100644 --- a/src/EntityFramework.Storage/test/UnitTests/Mappers/ClientMappersTests.cs +++ b/src/EntityFramework.Storage/test/UnitTests/Mappers/ClientMappersTests.cs @@ -16,7 +16,7 @@ public class ClientMappersTests [Fact] public void AutomapperConfigurationIsValid() { - ClientMappers.Mapper.ConfigurationProvider.AssertConfigurationIsValid(); + ClientMappers.Mapper.ConfigurationProvider.AssertConfigurationIsValid(); } [Fact] diff --git a/src/EntityFramework.Storage/test/UnitTests/Mappers/IdentityResourcesMappersTests.cs b/src/EntityFramework.Storage/test/UnitTests/Mappers/IdentityResourcesMappersTests.cs index fe2119319e..783b11079d 100644 --- a/src/EntityFramework.Storage/test/UnitTests/Mappers/IdentityResourcesMappersTests.cs +++ b/src/EntityFramework.Storage/test/UnitTests/Mappers/IdentityResourcesMappersTests.cs @@ -13,7 +13,7 @@ public class IdentityResourcesMappersTests [Fact] public void IdentityResourceAutomapperConfigurationIsValid() { - IdentityResourceMappers.Mapper.ConfigurationProvider.AssertConfigurationIsValid(); + IdentityResourceMappers.Mapper.ConfigurationProvider.AssertConfigurationIsValid(); } [Fact] diff --git a/src/EntityFramework.Storage/test/UnitTests/Mappers/PersistedGrantMappersTests.cs b/src/EntityFramework.Storage/test/UnitTests/Mappers/PersistedGrantMappersTests.cs index 48fbeffb47..6cdad39ac2 100644 --- a/src/EntityFramework.Storage/test/UnitTests/Mappers/PersistedGrantMappersTests.cs +++ b/src/EntityFramework.Storage/test/UnitTests/Mappers/PersistedGrantMappersTests.cs @@ -14,7 +14,7 @@ public class PersistedGrantMappersTests [Fact] public void PersistedGrantAutomapperConfigurationIsValid() { - PersistedGrantMappers.Mapper.ConfigurationProvider.AssertConfigurationIsValid(); + PersistedGrantMappers.Mapper.ConfigurationProvider.AssertConfigurationIsValid(); } [Fact] diff --git a/src/EntityFramework.Storage/test/UnitTests/Mappers/ScopeMappersTests.cs b/src/EntityFramework.Storage/test/UnitTests/Mappers/ScopeMappersTests.cs index 2765e4aa47..a7395b5409 100644 --- a/src/EntityFramework.Storage/test/UnitTests/Mappers/ScopeMappersTests.cs +++ b/src/EntityFramework.Storage/test/UnitTests/Mappers/ScopeMappersTests.cs @@ -15,7 +15,7 @@ public class ScopesMappersTests [Fact] public void ScopeAutomapperConfigurationIsValid() { - ScopeMappers.Mapper.ConfigurationProvider.AssertConfigurationIsValid(); + ScopeMappers.Mapper.ConfigurationProvider.AssertConfigurationIsValid(); } [Fact] diff --git a/src/EntityFramework/src/IdentityServer4.EntityFramework.csproj b/src/EntityFramework/src/IdentityServer4.EntityFramework.csproj index 2941966a90..88e9ed60af 100644 --- a/src/EntityFramework/src/IdentityServer4.EntityFramework.csproj +++ b/src/EntityFramework/src/IdentityServer4.EntityFramework.csproj @@ -2,7 +2,7 @@ IdentityServer4.EntityFramework - netcoreapp3.1 + net6.0;net7.0;net8.0 EntityFramework persistence layer for IdentityServer4 Brock Allen;Dominick Baier;Scott Brady @@ -33,9 +33,11 @@ - - - + + + + + \ No newline at end of file diff --git a/src/EntityFramework/test/IdentityServer4.EntityFramework.Tests/IdentityServer4.EntityFramework.Tests.csproj b/src/EntityFramework/test/IdentityServer4.EntityFramework.Tests/IdentityServer4.EntityFramework.Tests.csproj index dcf5c194cc..572a955d62 100644 --- a/src/EntityFramework/test/IdentityServer4.EntityFramework.Tests/IdentityServer4.EntityFramework.Tests.csproj +++ b/src/EntityFramework/test/IdentityServer4.EntityFramework.Tests/IdentityServer4.EntityFramework.Tests.csproj @@ -1,7 +1,7 @@  - netcoreapp3.1 + net6.0;net7.0;net8.0 false diff --git a/src/IdentityServer4/src/Extensions/CustomJwtPayload.cs b/src/IdentityServer4/src/Extensions/CustomJwtPayload.cs new file mode 100644 index 0000000000..08906af4c4 --- /dev/null +++ b/src/IdentityServer4/src/Extensions/CustomJwtPayload.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.IdentityModel.Tokens.Jwt; +using System.Security.Claims; +using Newtonsoft.Json; +using JsonSerializer = System.Text.Json.JsonSerializer; + +namespace IdentityServer4.Extensions; + +internal class CustomJwtPayload : JwtPayload +{ + public CustomJwtPayload(string issuer, string audience, IEnumerable claims, DateTime? notBefore, DateTime? expires) : + base(issuer, audience, claims, notBefore, expires) + { + } + + public override string SerializeToJson() + { + return JsonConvert.SerializeObject(this); + } +} \ No newline at end of file diff --git a/src/IdentityServer4/src/Extensions/TokenExtensions.cs b/src/IdentityServer4/src/Extensions/TokenExtensions.cs index 343ee5b2ab..c3b46dc32c 100644 --- a/src/IdentityServer4/src/Extensions/TokenExtensions.cs +++ b/src/IdentityServer4/src/Extensions/TokenExtensions.cs @@ -33,7 +33,7 @@ public static class TokenExtensions /// public static JwtPayload CreateJwtPayload(this Token token, ISystemClock clock, IdentityServerOptions options, ILogger logger) { - var payload = new JwtPayload( + var payload = new CustomJwtPayload( token.Issuer, null, null, diff --git a/src/IdentityServer4/src/IdentityServer4.csproj b/src/IdentityServer4/src/IdentityServer4.csproj index 602534d9bf..3053c3802d 100644 --- a/src/IdentityServer4/src/IdentityServer4.csproj +++ b/src/IdentityServer4/src/IdentityServer4.csproj @@ -1,51 +1,50 @@  - - - IdentityServer4 - net6.0 - OpenID Connect and OAuth 2.0 Framework for ASP.NET Core - Brock Allen;Dominick Baier - IdentityServer4 - OAuth2;OAuth 2.0;OpenID Connect;Security;Identity;IdentityServer - icon.jpg - https://github.com/IdentityServer/IdentityServer4 - Apache-2.0 - https://github.com/IdentityServer/IdentityServer4/releases - - - true - - true - - $(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb - - - ../key.snk - true - true - true - - - - True - True - - - - - - - - - - - - - - - - - - - + + + IdentityServer4 + net6.0;net7.0;net8.0 + OpenID Connect and OAuth 2.0 Framework for ASP.NET Core + Brock Allen;Dominick Baier + IdentityServer4 + OAuth2;OAuth 2.0;OpenID Connect;Security;Identity;IdentityServer + icon.jpg + https://github.com/IdentityServer/IdentityServer4 + Apache-2.0 + https://github.com/IdentityServer/IdentityServer4/releases + + + true + + true + + $(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb + + + ../key.snk + true + true + true + + + + True + True + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/IdentityServer4/src/Validation/Default/JwtRequestValidator.cs b/src/IdentityServer4/src/Validation/Default/JwtRequestValidator.cs index 2201116173..10dab98b6f 100644 --- a/src/IdentityServer4/src/Validation/Default/JwtRequestValidator.cs +++ b/src/IdentityServer4/src/Validation/Default/JwtRequestValidator.cs @@ -26,7 +26,7 @@ public class JwtRequestValidator { private readonly string _audienceUri; private readonly IHttpContextAccessor _httpContextAccessor; - + /// /// JWT handler /// @@ -55,7 +55,7 @@ protected string AudienceUri /// The logger /// protected readonly ILogger Logger; - + /// /// The optione /// @@ -64,10 +64,11 @@ protected string AudienceUri /// /// Instantiates an instance of private_key_jwt secret validator /// - public JwtRequestValidator(IHttpContextAccessor contextAccessor, IdentityServerOptions options, ILogger logger) + public JwtRequestValidator(IHttpContextAccessor contextAccessor, IdentityServerOptions options, + ILogger logger) { _httpContextAccessor = contextAccessor; - + Options = options; Logger = logger; } @@ -158,7 +159,8 @@ protected virtual Task> GetKeysAsync(Client client) /// The keys /// The client /// - protected virtual Task ValidateJwtAsync(string jwtTokenString, IEnumerable keys, Client client) + protected virtual Task ValidateJwtAsync(string jwtTokenString, IEnumerable keys, + Client client) { var tokenValidationParameters = new TokenValidationParameters { @@ -181,8 +183,8 @@ protected virtual Task ValidateJwtAsync(string jwtTokenString, } Handler.ValidateToken(jwtTokenString, tokenValidationParameters, out var token); - - return Task.FromResult((JwtSecurityToken)token); + + return Task.FromResult((JwtSecurityToken) token); } /// @@ -199,17 +201,20 @@ protected virtual Task> ProcessPayloadAsync(JwtSecuri if (!Constants.Filters.JwtRequestClaimTypesFilter.Contains(key)) { var value = token.Payload[key]; + Type valueType = value.GetType(); - switch (value) + switch (valueType.Name) { - case string s: - payload.Add(key, s); + case "String": + payload.Add(key, (string) value); + break; + case "JObject": + payload.Add(key, value.ToString()); break; - case JObject jobj: - payload.Add(key, jobj.ToString(Formatting.None)); + case "JArray": + payload.Add(key, value.ToString()); break; - case JArray jarr: - payload.Add(key, jarr.ToString(Formatting.None)); + default: break; } } diff --git a/src/IdentityServer4/test/IdentityServer.IntegrationTests/Clients/ClientAssertionClient.cs b/src/IdentityServer4/test/IdentityServer.IntegrationTests/Clients/ClientAssertionClient.cs index ffad33f12e..4b11c6cfac 100644 --- a/src/IdentityServer4/test/IdentityServer.IntegrationTests/Clients/ClientAssertionClient.cs +++ b/src/IdentityServer4/test/IdentityServer.IntegrationTests/Clients/ClientAssertionClient.cs @@ -45,13 +45,13 @@ public async Task Valid_client_with_manual_payload_should_succeed() { var token = CreateToken(ClientId); var requestBody = new FormUrlEncodedContent(new Dictionary - { - { "client_id", ClientId }, - { "client_assertion_type", "urn:ietf:params:oauth:client-assertion-type:jwt-bearer" }, - { "client_assertion", token }, - { "grant_type", "client_credentials" }, - { "scope", "api1" } - }); + { + { "client_id", ClientId }, + { "client_assertion_type", "urn:ietf:params:oauth:client-assertion-type:jwt-bearer" }, + { "client_assertion", token }, + { "grant_type", "client_credentials" }, + { "scope", "api1" } + }); var response = await GetToken(requestBody); @@ -67,7 +67,7 @@ public async Task Valid_client_should_succeed() { Address = TokenEndpoint, - ClientId = ClientId, + ClientId = string.Empty, ClientAssertion = { Type = OidcConstants.ClientAssertionTypes.JwtBearer, @@ -88,7 +88,7 @@ public async Task Valid_client_with_implicit_clientId_should_succeed() var response = await _client.RequestClientCredentialsTokenAsync(new ClientCredentialsTokenRequest { Address = TokenEndpoint, - ClientId = "client", + ClientId = string.Empty, ClientAssertion = { @@ -101,7 +101,7 @@ public async Task Valid_client_with_implicit_clientId_should_succeed() AssertValidToken(response); } - + [Fact] public async Task Valid_client_with_token_replay_should_fail() { @@ -111,7 +111,7 @@ public async Task Valid_client_with_token_replay_should_fail() { Address = TokenEndpoint, - ClientId = ClientId, + ClientId = string.Empty, ClientAssertion = { Type = OidcConstants.ClientAssertionTypes.JwtBearer, @@ -122,13 +122,13 @@ public async Task Valid_client_with_token_replay_should_fail() }); AssertValidToken(response); - + // replay response = await _client.RequestClientCredentialsTokenAsync(new ClientCredentialsTokenRequest { Address = TokenEndpoint, - ClientId = ClientId, + ClientId = string.Empty, ClientAssertion = { Type = OidcConstants.ClientAssertionTypes.JwtBearer, @@ -149,14 +149,13 @@ public async Task Client_with_invalid_secret_should_fail() { Address = TokenEndpoint, - ClientId = ClientId, + ClientId = string.Empty, ClientAssertion = { Type = OidcConstants.ClientAssertionTypes.JwtBearer, Value = "invalid" }, - - Scope = "api1" + Scope = "api1", }); response.IsError.Should().Be(true); @@ -174,7 +173,7 @@ public async Task Invalid_client_should_fail() { Address = TokenEndpoint, - ClientId = clientId, + ClientId = string.Empty, ClientAssertion = { Type = OidcConstants.ClientAssertionTypes.JwtBearer, @@ -204,12 +203,12 @@ private void AssertValidToken(TokenResponse response) response.RefreshToken.Should().BeNull(); var payload = GetPayload(response); - + payload.Count().Should().Be(8); payload.Should().Contain("iss", "https://idsvr4"); payload.Should().Contain("client_id", ClientId); payload.Keys.Should().Contain("iat"); - + var scopes = payload["scope"] as JArray; scopes.First().ToString().Should().Be("api1"); @@ -231,21 +230,22 @@ private string CreateToken(string clientId, DateTime? nowOverride = null) var now = nowOverride ?? DateTime.UtcNow; var token = new JwtSecurityToken( - clientId, - TokenEndpoint, - new List() - { - new Claim("jti", Guid.NewGuid().ToString()), - new Claim(JwtClaimTypes.Subject, clientId), - new Claim(JwtClaimTypes.IssuedAt, new DateTimeOffset(now).ToUnixTimeSeconds().ToString(), ClaimValueTypes.Integer64) - }, - now, - now.AddMinutes(1), - new SigningCredentials( - new X509SecurityKey(certificate), - SecurityAlgorithms.RsaSha256 - ) - ); + clientId, + TokenEndpoint, + new List() + { + new Claim("jti", Guid.NewGuid().ToString()), + new Claim(JwtClaimTypes.Subject, clientId), + new Claim(JwtClaimTypes.IssuedAt, new DateTimeOffset(now).ToUnixTimeSeconds().ToString(), + ClaimValueTypes.Integer64) + }, + now, + now.AddMinutes(1), + new SigningCredentials( + new X509SecurityKey(certificate), + SecurityAlgorithms.RsaSha256 + ) + ); var tokenHandler = new JwtSecurityTokenHandler(); return tokenHandler.WriteToken(token); diff --git a/src/IdentityServer4/test/IdentityServer.IntegrationTests/Clients/CustomTokenRequestValidatorClient.cs b/src/IdentityServer4/test/IdentityServer.IntegrationTests/Clients/CustomTokenRequestValidatorClient.cs index 83cd26793b..968935c88c 100644 --- a/src/IdentityServer4/test/IdentityServer.IntegrationTests/Clients/CustomTokenRequestValidatorClient.cs +++ b/src/IdentityServer4/test/IdentityServer.IntegrationTests/Clients/CustomTokenRequestValidatorClient.cs @@ -45,7 +45,7 @@ public async Task Client_credentials_request_should_contain_custom_response() }); var fields = GetFields(response); - fields.Should().Contain("custom", "custom"); + fields.Should().ContainKey("custom", "custom"); } [Fact] @@ -64,7 +64,7 @@ public async Task Resource_owner_credentials_request_should_contain_custom_respo }); var fields = GetFields(response); - fields.Should().Contain("custom", "custom"); + fields.Should().ContainKey("custom", "custom"); } [Fact] @@ -92,7 +92,7 @@ public async Task Refreshing_a_token_should_contain_custom_response() }); var fields = GetFields(response); - fields.Should().Contain("custom", "custom"); + fields.Should().ContainKey("custom", "custom"); } [Fact] @@ -114,7 +114,7 @@ public async Task Extension_grant_request_should_contain_custom_response() }); var fields = GetFields(response); - fields.Should().Contain("custom", "custom"); + fields.Should().ContainKey("custom", "custom"); } private Dictionary GetFields(TokenResponse response) diff --git a/src/IdentityServer4/test/IdentityServer.IntegrationTests/Clients/CustomTokenResponseClients.cs b/src/IdentityServer4/test/IdentityServer.IntegrationTests/Clients/CustomTokenResponseClients.cs index 7179109569..1954b7fee6 100644 --- a/src/IdentityServer4/test/IdentityServer.IntegrationTests/Clients/CustomTokenResponseClients.cs +++ b/src/IdentityServer4/test/IdentityServer.IntegrationTests/Clients/CustomTokenResponseClients.cs @@ -7,6 +7,7 @@ using System.Linq; using System.Net.Http; using System.Text; +using System.Text.Json; using System.Threading.Tasks; using FluentAssertions; using IdentityModel; @@ -51,8 +52,9 @@ public async Task Resource_owner_success_should_return_custom_response() // raw fields var fields = GetFields(response); - fields.Should().Contain("string_value", "some_string"); - ((Int64)fields["int_value"]).Should().Be(42); + fields.Should().ContainKey("string_value"); + fields["string_value"].ToString().Should().Be("some_string"); + (fields["int_value"].As().GetInt64()).Should().Be(42); object temp; fields.TryGetValue("identity_token", out temp).Should().BeFalse(); @@ -62,7 +64,7 @@ public async Task Resource_owner_success_should_return_custom_response() fields.TryGetValue("token_type", out temp).Should().BeTrue(); fields.TryGetValue("expires_in", out temp).Should().BeTrue(); - var responseObject = fields["dto"] as JObject; + var responseObject = fields["dto"].As(); responseObject.Should().NotBeNull(); var responseDto = GetDto(responseObject); @@ -80,7 +82,7 @@ public async Task Resource_owner_success_should_return_custom_response() response.TokenType.Should().Be("Bearer"); response.IdentityToken.Should().BeNull(); response.RefreshToken.Should().BeNull(); - + // token content var payload = GetPayload(response); @@ -116,8 +118,9 @@ public async Task Resource_owner_failure_should_return_custom_error_response() // raw fields var fields = GetFields(response); - fields.Should().Contain("string_value", "some_string"); - ((Int64)fields["int_value"]).Should().Be(42); + fields.Should().ContainKey("string_value"); + fields["string_value"].ToString().Should().Be("some_string"); + (fields["int_value"].As().GetInt64()).Should().Be(42); object temp; fields.TryGetValue("identity_token", out temp).Should().BeFalse(); @@ -127,7 +130,7 @@ public async Task Resource_owner_failure_should_return_custom_error_response() fields.TryGetValue("token_type", out temp).Should().BeFalse(); fields.TryGetValue("expires_in", out temp).Should().BeFalse(); - var responseObject = fields["dto"] as JObject; + var responseObject = fields["dto"].As(); responseObject.Should().NotBeNull(); var responseDto = GetDto(responseObject); @@ -163,15 +166,16 @@ public async Task Extension_grant_success_should_return_custom_response() Parameters = { { "scope", "api1" }, - { "outcome", "succeed"} + { "outcome", "succeed" } } }); // raw fields var fields = GetFields(response); - fields.Should().Contain("string_value", "some_string"); - ((Int64)fields["int_value"]).Should().Be(42); + fields.Should().ContainKey("string_value"); + fields["string_value"].ToString().Should().Be("some_string"); + (fields["int_value"].As().GetInt64()).Should().Be(42); object temp; fields.TryGetValue("identity_token", out temp).Should().BeFalse(); @@ -181,7 +185,7 @@ public async Task Extension_grant_success_should_return_custom_response() fields.TryGetValue("token_type", out temp).Should().BeTrue(); fields.TryGetValue("expires_in", out temp).Should().BeTrue(); - var responseObject = fields["dto"] as JObject; + var responseObject = fields["dto"].As(); responseObject.Should().NotBeNull(); var responseDto = GetDto(responseObject); @@ -217,7 +221,6 @@ public async Task Extension_grant_success_should_return_custom_response() var amr = payload["amr"] as JArray; amr.Count().Should().Be(1); amr.First().ToString().Should().Be("custom"); - } [Fact] @@ -234,15 +237,16 @@ public async Task Extension_grant_failure_should_return_custom_error_response() Parameters = { { "scope", "api1" }, - { "outcome", "fail"} + { "outcome", "fail" } } }); // raw fields var fields = GetFields(response); - fields.Should().Contain("string_value", "some_string"); - ((Int64)fields["int_value"]).Should().Be(42); + fields.Should().ContainKey("string_value"); + fields["string_value"].ToString().Should().Be("some_string"); + (fields["int_value"].As().GetInt64()).Should().Be(42); object temp; fields.TryGetValue("identity_token", out temp).Should().BeFalse(); @@ -252,7 +256,7 @@ public async Task Extension_grant_failure_should_return_custom_error_response() fields.TryGetValue("token_type", out temp).Should().BeFalse(); fields.TryGetValue("expires_in", out temp).Should().BeFalse(); - var responseObject = fields["dto"] as JObject; + var responseObject = fields["dto"].As() ; responseObject.Should().NotBeNull(); var responseDto = GetDto(responseObject); @@ -274,7 +278,7 @@ public async Task Extension_grant_failure_should_return_custom_error_response() response.RefreshToken.Should().BeNull(); } - private CustomResponseDto GetDto(JObject responseObject) + private CustomResponseDto GetDto(JsonElement responseObject) { return responseObject.ToObject(); } diff --git a/src/IdentityServer4/test/IdentityServer.IntegrationTests/Clients/UserInfoClient.cs b/src/IdentityServer4/test/IdentityServer.IntegrationTests/Clients/UserInfoClient.cs index 5fa8482f28..b8297dada5 100644 --- a/src/IdentityServer4/test/IdentityServer.IntegrationTests/Clients/UserInfoClient.cs +++ b/src/IdentityServer4/test/IdentityServer.IntegrationTests/Clients/UserInfoClient.cs @@ -7,6 +7,7 @@ using System.Net; using System.Net.Http; using System.Text; +using System.Text.Json; using System.Threading.Tasks; using FluentAssertions; using IdentityModel; @@ -194,7 +195,7 @@ public async Task Complex_json_should_be_correct() Token = response.AccessToken }); - roles = ((JArray)userInfo.Json["role"]).Select(x => x.ToString()).ToArray(); + roles = userInfo.Json.GetProperty("role").EnumerateArray().Select(x => x.ToString()).ToArray(); roles.Length.Should().Be(2); roles.Should().Contain("Geek"); roles.Should().Contain("Developer"); diff --git a/src/IdentityServer4/test/IdentityServer.IntegrationTests/Common/IdentityServerPipeline.cs b/src/IdentityServer4/test/IdentityServer.IntegrationTests/Common/IdentityServerPipeline.cs index ef604dcad3..09a12659ad 100644 --- a/src/IdentityServer4/test/IdentityServer.IntegrationTests/Common/IdentityServerPipeline.cs +++ b/src/IdentityServer4/test/IdentityServer.IntegrationTests/Common/IdentityServerPipeline.cs @@ -318,7 +318,7 @@ public string CreateAuthorizeUrl( string responseMode = null, string codeChallenge = null, string codeChallengeMethod = null, - object extra = null) + Parameters extra = null) { var url = new RequestUrl(AuthorizeEndpoint).CreateAuthorizeUrl( clientId: clientId, @@ -353,7 +353,7 @@ public async Task RequestAuthorizationEndpointAsync( string responseMode = null, string codeChallenge = null, string codeChallengeMethod = null, - object extra = null) + Parameters extra = null) { var old = BrowserClient.AllowAutoRedirect; BrowserClient.AllowAutoRedirect = false; diff --git a/src/IdentityServer4/test/IdentityServer.IntegrationTests/Endpoints/Authorize/AuthorizeTests.cs b/src/IdentityServer4/test/IdentityServer.IntegrationTests/Endpoints/Authorize/AuthorizeTests.cs index c9e0440d97..9aa73c90c1 100644 --- a/src/IdentityServer4/test/IdentityServer.IntegrationTests/Endpoints/Authorize/AuthorizeTests.cs +++ b/src/IdentityServer4/test/IdentityServer.IntegrationTests/Endpoints/Authorize/AuthorizeTests.cs @@ -10,6 +10,7 @@ using System.Threading.Tasks; using FluentAssertions; using IdentityModel; +using IdentityModel.Client; using IdentityServer.IntegrationTests.Common; using IdentityServer4; using IdentityServer4.Models; @@ -31,13 +32,14 @@ public class AuthorizeTests public AuthorizeTests() { - _mockPipeline.Clients.AddRange(new Client[] { + _mockPipeline.Clients.AddRange(new Client[] + { _client1 = new Client { ClientId = "client1", AllowedGrantTypes = GrantTypes.Implicit, RequireConsent = false, - + AllowedScopes = new List { "openid", "profile" }, RedirectUris = new List { "https://client1/callback" }, AllowAccessTokensViaBrowser = true @@ -47,7 +49,7 @@ public AuthorizeTests() ClientId = "client2", AllowedGrantTypes = GrantTypes.Implicit, RequireConsent = true, - + AllowedScopes = new List { "openid", "profile", "api1", "api2" }, RedirectUris = new List { "https://client2/callback" }, AllowAccessTokensViaBrowser = true @@ -57,7 +59,7 @@ public AuthorizeTests() ClientId = "client3", AllowedGrantTypes = GrantTypes.Implicit, RequireConsent = false, - + AllowedScopes = new List { "openid", "profile", "api1", "api2" }, RedirectUris = new List { "https://client3/callback" }, AllowAccessTokensViaBrowser = true, @@ -74,7 +76,6 @@ public AuthorizeTests() AllowedScopes = new List { "openid", "profile", "api1", "api2" }, RedirectUris = new List { "https://client4/callback" }, }, - }); _mockPipeline.Users.Add(new TestUser @@ -89,19 +90,22 @@ public AuthorizeTests() } }); - _mockPipeline.IdentityScopes.AddRange(new IdentityResource[] { + _mockPipeline.IdentityScopes.AddRange(new IdentityResource[] + { new IdentityResources.OpenId(), new IdentityResources.Profile(), new IdentityResources.Email() }); - _mockPipeline.ApiResources.AddRange(new ApiResource[] { + _mockPipeline.ApiResources.AddRange(new ApiResource[] + { new ApiResource { Name = "api", Scopes = { "api1", "api2" } } }); - _mockPipeline.ApiScopes.AddRange(new ApiScope[] { + _mockPipeline.ApiScopes.AddRange(new ApiScope[] + { new ApiScope { Name = "api1" @@ -128,7 +132,8 @@ public async Task get_request_should_not_return_404() [Trait("Category", Category)] public async Task post_request_without_form_should_return_415() { - var response = await _mockPipeline.BrowserClient.PostAsync(IdentityServerPipeline.AuthorizeEndpoint, new StringContent("foo")); + var response = await _mockPipeline.BrowserClient.PostAsync(IdentityServerPipeline.AuthorizeEndpoint, + new StringContent("foo")); response.StatusCode.Should().Be(HttpStatusCode.UnsupportedMediaType); } @@ -150,7 +155,7 @@ public async Task get_request_should_not_return_500() { var response = await _mockPipeline.BrowserClient.GetAsync(IdentityServerPipeline.AuthorizeEndpoint); - ((int)response.StatusCode).Should().BeLessThan(500); + ((int) response.StatusCode).Should().BeLessThan(500); } [Fact] @@ -170,7 +175,7 @@ public async Task anonymous_user_should_be_redirected_to_login_page() } [Theory] - [InlineData((Type)null)] + [InlineData((Type) null)] [InlineData(typeof(QueryStringAuthorizationParametersMessageStore))] [InlineData(typeof(DistributedCacheAuthorizationParametersMessageStore))] [Trait("Category", Category)] @@ -194,12 +199,12 @@ public async Task signin_request_should_have_authorization_params(Type storeType nonce: "123_nonce", loginHint: "login_hint_value", acrValues: "acr_1 acr_2 tenant:tenant_value idp:idp_value", - extra: new + extra: Parameters.FromObject(new { display = "popup", // must use a valid value from the spec for display ui_locales = "ui_locale_value", custom_foo = "foo_value" - }); + })); var response = await _mockPipeline.BrowserClient.GetAsync(url + "&foo=bar"); _mockPipeline.LoginRequest.Should().NotBeNull(); @@ -266,7 +271,7 @@ public async Task authenticated_user_with_valid_request_should_receive_authoriza } [Theory] - [InlineData((Type)null)] + [InlineData((Type) null)] [InlineData(typeof(QueryStringAuthorizationParametersMessageStore))] [InlineData(typeof(DistributedCacheAuthorizationParametersMessageStore))] [Trait("Category", Category)] @@ -892,7 +897,7 @@ public async Task missing_nonce_should_show_error_page() scope: "openid", redirectUri: "https://client1/callback", state: "123_state" - //nonce: "123_nonce" + //nonce: "123_nonce" ); await _mockPipeline.BrowserClient.GetAsync(url); @@ -938,7 +943,7 @@ public async Task locale_too_long_should_show_error_page() redirectUri: "https://client1/callback", state: "123_state", nonce: "123_nonce", - extra: new { ui_locales = new string('x', 500) }); + extra: Parameters.FromObject(new { ui_locales = new string('x', 500) })); await _mockPipeline.BrowserClient.GetAsync(url); _mockPipeline.ErrorWasCalled.Should().BeTrue(); @@ -961,7 +966,7 @@ public async Task invalid_max_age_should_show_error_page() redirectUri: "https://client1/callback", state: "123_state", nonce: "123_nonce", - extra: new { max_age = "invalid" }); + extra: Parameters.FromObject(new { max_age = "invalid" })); await _mockPipeline.BrowserClient.GetAsync(url); _mockPipeline.ErrorWasCalled.Should().BeTrue(); @@ -984,7 +989,7 @@ public async Task negative_max_age_should_show_error_page() redirectUri: "https://client1/callback", state: "123_state", nonce: "123_nonce", - extra: new { max_age = "-10" }); + extra: Parameters.FromObject(new { max_age = "-10" })); await _mockPipeline.BrowserClient.GetAsync(url); _mockPipeline.ErrorWasCalled.Should().BeTrue(); @@ -1077,7 +1082,7 @@ public async Task ui_locales_should_be_passed_to_error_page() state: "123_state", nonce: "123_nonce", acrValues: new string('x', 500), - extra: new { ui_locales = "fr-FR" }); + extra: Parameters.FromObject(new { ui_locales = "fr-FR" })); await _mockPipeline.BrowserClient.GetAsync(url); _mockPipeline.ErrorWasCalled.Should().BeTrue(); @@ -1098,7 +1103,7 @@ public async Task display_mode_should_be_passed_to_error_page() state: "123_state", nonce: "123_nonce", acrValues: new string('x', 500), - extra: new { display = "popup" }); + extra: Parameters.FromObject(new { display = "popup" })); await _mockPipeline.BrowserClient.GetAsync(url); _mockPipeline.ErrorWasCalled.Should().BeTrue(); @@ -1153,11 +1158,11 @@ public async Task prompt_login_should_show_login_page() redirectUri: "https://client3/callback", state: "123_state", nonce: "123_nonce", - extra:new { prompt = "login" } + extra: Parameters.FromObject(new { prompt = "login" }) ); var response = await _mockPipeline.BrowserClient.GetAsync(url); _mockPipeline.LoginWasCalled.Should().BeTrue(); } } -} +} \ No newline at end of file diff --git a/src/IdentityServer4/test/IdentityServer.IntegrationTests/Endpoints/Authorize/ConsentTests.cs b/src/IdentityServer4/test/IdentityServer.IntegrationTests/Endpoints/Authorize/ConsentTests.cs index b620b19599..a91dcae2e2 100644 --- a/src/IdentityServer4/test/IdentityServer.IntegrationTests/Endpoints/Authorize/ConsentTests.cs +++ b/src/IdentityServer4/test/IdentityServer.IntegrationTests/Endpoints/Authorize/ConsentTests.cs @@ -8,6 +8,7 @@ using System.Security.Claims; using System.Threading.Tasks; using FluentAssertions; +using IdentityModel.Client; using IdentityServer.IntegrationTests.Common; using IdentityServer4.Models; using IdentityServer4.Stores; @@ -26,7 +27,8 @@ public class ConsentTests public ConsentTests() { - _mockPipeline.Clients.AddRange(new Client[] { + _mockPipeline.Clients.AddRange(new Client[] + { new Client { ClientId = "client1", @@ -69,12 +71,14 @@ public ConsentTests() } }); - _mockPipeline.IdentityScopes.AddRange(new IdentityResource[] { + _mockPipeline.IdentityScopes.AddRange(new IdentityResource[] + { new IdentityResources.OpenId(), new IdentityResources.Profile(), new IdentityResources.Email() }); - _mockPipeline.ApiResources.AddRange(new ApiResource[] { + _mockPipeline.ApiResources.AddRange(new ApiResource[] + { new ApiResource { Name = "api", @@ -117,7 +121,7 @@ public async Task client_requires_consent_should_show_consent_page() } [Theory] - [InlineData((Type)null)] + [InlineData((Type) null)] [InlineData(typeof(QueryStringAuthorizationParametersMessageStore))] [InlineData(typeof(DistributedCacheAuthorizationParametersMessageStore))] [Trait("Category", Category)] @@ -142,12 +146,12 @@ public async Task consent_page_should_have_authorization_params(Type storeType) state: "123_state", nonce: "123_nonce", acrValues: "acr_1 acr_2 tenant:tenant_value", - extra: new + extra: Parameters.FromObject(new { display = "popup", // must use a valid value form the spec for display ui_locales = "ui_locale_value", custom_foo = "foo_value" - } + }) ); var response = await _mockPipeline.BrowserClient.GetAsync(url); @@ -159,11 +163,12 @@ public async Task consent_page_should_have_authorization_params(Type storeType) _mockPipeline.ConsentRequest.AcrValues.Should().BeEquivalentTo(new string[] { "acr_2", "acr_1" }); _mockPipeline.ConsentRequest.Parameters.AllKeys.Should().Contain("custom_foo"); _mockPipeline.ConsentRequest.Parameters["custom_foo"].Should().Be("foo_value"); - _mockPipeline.ConsentRequest.ValidatedResources.RawScopeValues.Should().BeEquivalentTo(new string[] { "api2", "openid", "api1" }); + _mockPipeline.ConsentRequest.ValidatedResources.RawScopeValues.Should() + .BeEquivalentTo(new string[] { "api2", "openid", "api1" }); } [Theory] - [InlineData((Type)null)] + [InlineData((Type) null)] [InlineData(typeof(QueryStringAuthorizationParametersMessageStore))] [InlineData(typeof(DistributedCacheAuthorizationParametersMessageStore))] [Trait("Category", Category)] @@ -272,4 +277,4 @@ public async Task consent_response_missing_required_scopes_should_error() authorization.State.Should().Be("123_state"); } } -} +} \ No newline at end of file diff --git a/src/IdentityServer4/test/IdentityServer.IntegrationTests/Endpoints/Authorize/JwtRequestAuthorizeTests.cs b/src/IdentityServer4/test/IdentityServer.IntegrationTests/Endpoints/Authorize/JwtRequestAuthorizeTests.cs index 01206f02f1..3e17006c39 100644 --- a/src/IdentityServer4/test/IdentityServer.IntegrationTests/Endpoints/Authorize/JwtRequestAuthorizeTests.cs +++ b/src/IdentityServer4/test/IdentityServer.IntegrationTests/Endpoints/Authorize/JwtRequestAuthorizeTests.cs @@ -12,6 +12,7 @@ using System.Threading.Tasks; using FluentAssertions; using IdentityModel; +using IdentityModel.Client; using IdentityServer.IntegrationTests.Common; using IdentityServer4; using IdentityServer4.Configuration; @@ -233,10 +234,10 @@ public async Task authorize_should_accept_valid_JWT_request_object_parameters_us var url = _mockPipeline.CreateAuthorizeUrl( clientId: _client.ClientId, responseType: "id_token", - extra: new + extra: Parameters.FromObject(new { request = requestJwt - }); + })); var response = await _mockPipeline.BrowserClient.GetAsync(url); _mockPipeline.LoginRequest.Should().NotBeNull(); @@ -281,10 +282,10 @@ public async Task authorize_should_accept_valid_JWT_request_object_parameters_us var url = _mockPipeline.CreateAuthorizeUrl( clientId: _client.ClientId, responseType: "id_token", - extra: new + extra: Parameters.FromObject(new { request = requestJwt - }); + })); var response = await _mockPipeline.BrowserClient.GetAsync(url); _mockPipeline.LoginRequest.Should().NotBeNull(); @@ -329,10 +330,10 @@ public async Task authorize_should_accept_valid_JWT_request_object_parameters_us var url = _mockPipeline.CreateAuthorizeUrl( clientId: _client.ClientId, responseType: "id_token", - extra: new + extra: Parameters.FromObject(new { request = requestJwt - }); + })); var response = await _mockPipeline.BrowserClient.GetAsync(url); _mockPipeline.LoginRequest.Should().NotBeNull(); @@ -379,10 +380,10 @@ public async Task correct_jwt_typ_should_pass_strict_validation() var url = _mockPipeline.CreateAuthorizeUrl( clientId: _client.ClientId, responseType: "id_token", - extra: new + extra: Parameters.FromObject(new { request = requestJwt - }); + })); var response = await _mockPipeline.BrowserClient.GetAsync(url); _mockPipeline.LoginRequest.Should().NotBeNull(); @@ -429,10 +430,10 @@ public async Task missing_jwt_typ_should_error() var url = _mockPipeline.CreateAuthorizeUrl( clientId: _client.ClientId, responseType: "id_token", - extra: new + extra: Parameters.FromObject(new { request = requestJwt - }); + })); var response = await _mockPipeline.BrowserClient.GetAsync(url); _mockPipeline.ErrorMessage.Error.Should().Be("invalid_request_object"); @@ -470,13 +471,13 @@ public async Task mismatch_in_jwt_values_should_error() redirectUri: "bad", acrValues: "bad", loginHint: "bad", - extra: new + extra: Parameters.FromObject(new { display = "bad", ui_locales = "bad", foo = "bad", request = requestJwt - }); + })); var response = await _mockPipeline.BrowserClient.GetAsync(url); _mockPipeline.ErrorMessage.Error.Should().Be("invalid_request"); @@ -517,10 +518,10 @@ public async Task authorize_should_accept_complex_objects_in_request_object() var url = _mockPipeline.CreateAuthorizeUrl( clientId: _client.ClientId, responseType: "id_token", - extra: new + extra: Parameters.FromObject(new { request = requestJwt - }); + })); var response = await _mockPipeline.BrowserClient.GetAsync(url); _mockPipeline.LoginRequest.Should().NotBeNull(); @@ -566,10 +567,10 @@ public async Task authorize_should_reject_jwt_request_without_client_id() var url = _mockPipeline.CreateAuthorizeUrl( responseType: "id_token", - extra: new + extra: Parameters.FromObject(new { request = requestJwt - }); + })); var response = await _mockPipeline.BrowserClient.GetAsync(url); _mockPipeline.ErrorMessage.Error.Should().Be("invalid_request"); @@ -601,10 +602,10 @@ public async Task authorize_should_reject_jwt_request_without_client_id_in_jwt() var url = _mockPipeline.CreateAuthorizeUrl( clientId: _client.ClientId, responseType: "id_token", - extra: new + extra: Parameters.FromObject(new { request = requestJwt - }); + })); var response = await _mockPipeline.BrowserClient.GetAsync(url); _mockPipeline.ErrorMessage.Error.Should().Be("invalid_request_object"); @@ -637,10 +638,10 @@ public async Task authorize_should_reject_jwt_request_if_audience_is_incorrect() var url = _mockPipeline.CreateAuthorizeUrl( clientId: _client.ClientId, responseType: "id_token", - extra: new + extra: Parameters.FromObject(new { request = requestJwt - }); + })); var response = await _mockPipeline.BrowserClient.GetAsync(url); @@ -674,10 +675,10 @@ public async Task authorize_should_reject_jwt_request_if_issuer_does_not_match_c var url = _mockPipeline.CreateAuthorizeUrl( clientId: _client.ClientId, responseType: "id_token", - extra: new + extra: Parameters.FromObject(new { request = requestJwt - }); + })); var response = await _mockPipeline.BrowserClient.GetAsync(url); @@ -711,10 +712,10 @@ public async Task authorize_should_reject_jwt_request_that_includes_request_para var url = _mockPipeline.CreateAuthorizeUrl( clientId: _client.ClientId, responseType: "id_token", - extra: new + extra: Parameters.FromObject(new { request = requestJwt - }); + })); var response = await _mockPipeline.BrowserClient.GetAsync(url); @@ -748,10 +749,10 @@ public async Task authorize_should_reject_jwt_request_that_includes_request_uri_ var url = _mockPipeline.CreateAuthorizeUrl( clientId: _client.ClientId, responseType: "id_token", - extra: new + extra: Parameters.FromObject(new { request = requestJwt - }); + })); var response = await _mockPipeline.BrowserClient.GetAsync(url); @@ -784,10 +785,10 @@ public async Task authorize_should_reject_jwt_request_if_response_type_does_not_ var url = _mockPipeline.CreateAuthorizeUrl( clientId: _client.ClientId, responseType: "id_token", - extra: new + extra: Parameters.FromObject(new { request = requestJwt - }); + })); var response = await _mockPipeline.BrowserClient.GetAsync(url); @@ -821,10 +822,10 @@ public async Task authorize_should_reject_jwt_request_if_client_id_does_not_matc var url = _mockPipeline.CreateAuthorizeUrl( clientId: "client2", responseType: "id_token", - extra: new + extra: Parameters.FromObject(new { request = requestJwt - }); + })); var response = await _mockPipeline.BrowserClient.GetAsync(url); @@ -867,10 +868,10 @@ public async Task authorize_should_ignore_request_uri_when_feature_is_disabled() var url = _mockPipeline.CreateAuthorizeUrl( clientId: _client.ClientId, responseType: "id_token", - extra: new + extra: Parameters.FromObject(new { request_uri = "http://client_jwt" - }); + })); var response = await _mockPipeline.BrowserClient.GetAsync(url); _mockPipeline.ErrorWasCalled.Should().BeTrue(); @@ -911,10 +912,10 @@ public async Task authorize_should_accept_request_uri_with_valid_jwt() var url = _mockPipeline.CreateAuthorizeUrl( clientId: _client.ClientId, responseType: "id_token", - extra: new + extra: Parameters.FromObject(new { request_uri = "http://client_jwt" - }); + })); var response = await _mockPipeline.BrowserClient.GetAsync(url); _mockPipeline.LoginRequest.Should().NotBeNull(); @@ -967,10 +968,10 @@ public async Task authorize_should_accept_request_uri_with_valid_jwt_and_strict_ var url = _mockPipeline.CreateAuthorizeUrl( clientId: _client.ClientId, responseType: "id_token", - extra: new + extra: Parameters.FromObject(new { request_uri = "http://client_jwt" - }); + })); var response = await _mockPipeline.BrowserClient.GetAsync(url); _mockPipeline.LoginRequest.Should().NotBeNull(); @@ -1022,10 +1023,10 @@ public async Task authorize_should_reject_request_uri_with_valid_jwt_and_strict_ var url = _mockPipeline.CreateAuthorizeUrl( clientId: _client.ClientId, responseType: "id_token", - extra: new + extra: Parameters.FromObject(new { request_uri = "http://client_jwt" - }); + })); var response = await _mockPipeline.BrowserClient.GetAsync(url); _mockPipeline.ErrorMessage.Error.Should().Be("invalid_request_uri"); @@ -1044,10 +1045,10 @@ public async Task request_uri_response_returns_500_should_fail() var url = _mockPipeline.CreateAuthorizeUrl( clientId: _client.ClientId, responseType: "id_token", - extra: new + extra: Parameters.FromObject(new { request_uri = "http://client_jwt" - }); + })); var response = await _mockPipeline.BrowserClient.GetAsync(url); _mockPipeline.ErrorWasCalled.Should().BeTrue(); @@ -1067,10 +1068,10 @@ public async Task request_uri_response_returns_404_should_fail() var url = _mockPipeline.CreateAuthorizeUrl( clientId: _client.ClientId, responseType: "id_token", - extra: new + extra: Parameters.FromObject(new { request_uri = "http://client_jwt" - }); + })); var response = await _mockPipeline.BrowserClient.GetAsync(url); _mockPipeline.ErrorWasCalled.Should().BeTrue(); @@ -1088,10 +1089,10 @@ public async Task request_uri_length_too_long_should_fail() var url = _mockPipeline.CreateAuthorizeUrl( clientId: _client.ClientId, responseType: "id_token", - extra: new + extra: Parameters.FromObject(new { request_uri = "http://" + new string('x', 512) - }); + })); var response = await _mockPipeline.BrowserClient.GetAsync(url); _mockPipeline.ErrorWasCalled.Should().BeTrue(); _mockPipeline.LoginRequest.Should().BeNull(); @@ -1128,11 +1129,11 @@ public async Task both_request_and_request_uri_params_should_fail() var url = _mockPipeline.CreateAuthorizeUrl( clientId: _client.ClientId, responseType: "id_token", - extra: new + extra: Parameters.FromObject(new { request = requestJwt, request_uri = "http://client_jwt" - }); + })); var response = await _mockPipeline.BrowserClient.GetAsync(url); _mockPipeline.ErrorWasCalled.Should().BeTrue(); _mockPipeline.LoginRequest.Should().BeNull(); diff --git a/src/IdentityServer4/test/IdentityServer.IntegrationTests/Endpoints/Introspection/IntrospectionTests.cs b/src/IdentityServer4/test/IdentityServer.IntegrationTests/Endpoints/Introspection/IntrospectionTests.cs index edf61e872e..2991e19a93 100644 --- a/src/IdentityServer4/test/IdentityServer.IntegrationTests/Endpoints/Introspection/IntrospectionTests.cs +++ b/src/IdentityServer4/test/IdentityServer.IntegrationTests/Endpoints/Introspection/IntrospectionTests.cs @@ -7,6 +7,7 @@ using System.Net; using System.Net.Http; using System.Text; +using System.Text.Json; using System.Threading.Tasks; using FluentAssertions; using IdentityModel.Client; @@ -182,13 +183,13 @@ public async Task Response_data_should_be_valid_using_single_scope() var values = introspectionResponse.Json.ToObject>(); - values["aud"].GetType().Name.Should().Be("String"); - values["iss"].GetType().Name.Should().Be("String"); - values["nbf"].GetType().Name.Should().Be("Int64"); - values["exp"].GetType().Name.Should().Be("Int64"); - values["client_id"].GetType().Name.Should().Be("String"); - values["active"].GetType().Name.Should().Be("Boolean"); - values["scope"].GetType().Name.Should().Be("String"); + values["aud"].As().ValueKind.Should().Be(JsonValueKind.String); + values["iss"].As().ValueKind.Should().Be(JsonValueKind.String); + values["nbf"].As().ValueKind.Should().Be(JsonValueKind.Number); + values["exp"].As().ValueKind.Should().Be(JsonValueKind.Number); + values["client_id"].As().ValueKind.Should().Be(JsonValueKind.String); + values["active"].As().ValueKind.Should().Be(JsonValueKind.True); + values["scope"].As().ValueKind.Should().Be(JsonValueKind.String); values["scope"].ToString().Should().Be("api1"); } @@ -221,15 +222,15 @@ public async Task Response_data_with_user_authentication_should_be_valid_using_s var values = introspectionResponse.Json.ToObject>(); - values["aud"].GetType().Name.Should().Be("String"); - values["iss"].GetType().Name.Should().Be("String"); - values["nbf"].GetType().Name.Should().Be("Int64"); - values["exp"].GetType().Name.Should().Be("Int64"); - values["auth_time"].GetType().Name.Should().Be("Int64"); - values["client_id"].GetType().Name.Should().Be("String"); - values["sub"].GetType().Name.Should().Be("String"); - values["active"].GetType().Name.Should().Be("Boolean"); - values["scope"].GetType().Name.Should().Be("String"); + values["aud"].As().ValueKind.Should().Be(JsonValueKind.String); + values["iss"].As().ValueKind.Should().Be(JsonValueKind.String); + values["nbf"].As().ValueKind.Should().Be(JsonValueKind.Number); + values["exp"].As().ValueKind.Should().Be(JsonValueKind.Number); + values["auth_time"].As().ValueKind.Should().Be(JsonValueKind.Number); + values["client_id"].As().ValueKind.Should().Be(JsonValueKind.String); + values["sub"].As().ValueKind.Should().Be(JsonValueKind.String); + values["active"].As().ValueKind.Should().Be(JsonValueKind.True); + values["scope"].As().ValueKind.Should().Be(JsonValueKind.String); values["scope"].ToString().Should().Be("api1"); } @@ -260,20 +261,20 @@ public async Task Response_data_should_be_valid_using_multiple_scopes_multiple_a var values = introspectionResponse.Json.ToObject>(); - values["aud"].GetType().Name.Should().Be("JArray"); + values["aud"].GetType().Name.Should().Be("JsonElement"); - var audiences = ((JArray)values["aud"]); + var audiences = ((JsonElement)values["aud"]).EnumerateArray(); foreach (var aud in audiences) { - aud.Type.Should().Be(JTokenType.String); + aud.ValueKind.Should().Be(JsonValueKind.String); } - values["iss"].GetType().Name.Should().Be("String"); - values["nbf"].GetType().Name.Should().Be("Int64"); - values["exp"].GetType().Name.Should().Be("Int64"); - values["client_id"].GetType().Name.Should().Be("String"); - values["active"].GetType().Name.Should().Be("Boolean"); - values["scope"].GetType().Name.Should().Be("String"); + values["iss"].As().ValueKind.Should().Be(JsonValueKind.String); + values["nbf"].As().ValueKind.Should().Be(JsonValueKind.Number); + values["exp"].As().ValueKind.Should().Be(JsonValueKind.Number); + values["client_id"].As().ValueKind.Should().Be(JsonValueKind.String); + values["active"].As().ValueKind.Should().Be(JsonValueKind.True); + values["scope"].As().ValueKind.Should().Be(JsonValueKind.String); var scopes = values["scope"].ToString(); scopes.Should().Be("api3-a api3-b"); @@ -305,13 +306,12 @@ public async Task Response_data_should_be_valid_using_multiple_scopes_single_aud var values = introspectionResponse.Json.ToObject>(); - values["aud"].GetType().Name.Should().Be("String"); - values["iss"].GetType().Name.Should().Be("String"); - values["nbf"].GetType().Name.Should().Be("Int64"); - values["exp"].GetType().Name.Should().Be("Int64"); - values["client_id"].GetType().Name.Should().Be("String"); - values["active"].GetType().Name.Should().Be("Boolean"); - values["scope"].GetType().Name.Should().Be("String"); + values["iss"].As().ValueKind.Should().Be(JsonValueKind.String); + values["nbf"].As().ValueKind.Should().Be(JsonValueKind.Number); + values["exp"].As().ValueKind.Should().Be(JsonValueKind.Number); + values["client_id"].As().ValueKind.Should().Be(JsonValueKind.String); + values["active"].As().ValueKind.Should().Be(JsonValueKind.True); + values["scope"].As().ValueKind.Should().Be(JsonValueKind.String); var scopes = values["scope"].ToString(); scopes.Should().Be("api3-a api3-b"); diff --git a/src/IdentityServer4/test/IdentityServer.IntegrationTests/IdentityServer.IntegrationTests.csproj b/src/IdentityServer4/test/IdentityServer.IntegrationTests/IdentityServer.IntegrationTests.csproj index aae8626619..03862c57aa 100644 --- a/src/IdentityServer4/test/IdentityServer.IntegrationTests/IdentityServer.IntegrationTests.csproj +++ b/src/IdentityServer4/test/IdentityServer.IntegrationTests/IdentityServer.IntegrationTests.csproj @@ -1,43 +1,41 @@  - - net6.0 - + + net6.0;net7.0;net8.0 + - - ../../key.snk - true - true - + + ../../key.snk + true + true + - - - + + + - - - - - - - - - + + + + + + + - - - Always - - - Always - - - PreserveNewest - - + + + Always + + + Always + + + PreserveNewest + + - - - + + + \ No newline at end of file diff --git a/src/IdentityServer4/test/IdentityServer.IntegrationTests/JsonExtensions.cs b/src/IdentityServer4/test/IdentityServer.IntegrationTests/JsonExtensions.cs new file mode 100644 index 0000000000..bd7cc8a0d9 --- /dev/null +++ b/src/IdentityServer4/test/IdentityServer.IntegrationTests/JsonExtensions.cs @@ -0,0 +1,17 @@ +using System.Text.Json; + +namespace IdentityServer.IntegrationTests; + +public static class JsonExtensions +{ + public static T ToObject(this JsonElement element) + { + var json = element.GetRawText(); + return JsonSerializer.Deserialize(json); + } + public static T ToObject(this JsonDocument document) + { + var json = document.RootElement.GetRawText(); + return JsonSerializer.Deserialize(json); + } +} \ No newline at end of file diff --git a/src/IdentityServer4/test/IdentityServer.UnitTests/IdentityServer.UnitTests.csproj b/src/IdentityServer4/test/IdentityServer.UnitTests/IdentityServer.UnitTests.csproj index f6308aff41..432ecf0e7e 100644 --- a/src/IdentityServer4/test/IdentityServer.UnitTests/IdentityServer.UnitTests.csproj +++ b/src/IdentityServer4/test/IdentityServer.UnitTests/IdentityServer.UnitTests.csproj @@ -1,7 +1,7 @@  - net6.0 + net6.0;net7.0;net8.0 @@ -32,6 +32,6 @@ - + diff --git a/src/Storage/src/IdentityServer4.Storage.csproj b/src/Storage/src/IdentityServer4.Storage.csproj index dbc2a6fe94..9dc0980b28 100644 --- a/src/Storage/src/IdentityServer4.Storage.csproj +++ b/src/Storage/src/IdentityServer4.Storage.csproj @@ -1,41 +1,42 @@  - - netstandard2.0 - - IdentityServer4.Storage - Storage interfaces and models for IdentityServer4 - Brock Allen;Dominick Baier - - OAuth2;OAuth 2.0;OpenID Connect;Security;Identity;IdentityServer - icon.jpg - https://github.com/IdentityServer/IdentityServer4 - Apache-2.0 - https://github.com/IdentityServer/IdentityServer4/releases - - true - true - $(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb - - ../../../key.snk - true - true - - true - - - - True - True - - - - - - - - - - + + net6.0;net7.0;net8.0 + + IdentityServer4.Storage + Storage interfaces and models for IdentityServer4 + Brock Allen;Dominick Baier + + OAuth2;OAuth 2.0;OpenID Connect;Security;Identity;IdentityServer + icon.jpg + https://github.com/IdentityServer/IdentityServer4 + Apache-2.0 + https://github.com/IdentityServer/IdentityServer4/releases + + true + true + $(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb + + ../../../key.snk + true + true + + true + + + + True + True + + + + + + + + + + + \ No newline at end of file