From 81eeeb9fed900b899c9ca9f5fd790a54e9dbe78e Mon Sep 17 00:00:00 2001 From: Bruno Brito Date: Tue, 17 Nov 2026 22:23:28 -0300 Subject: [PATCH] chore: drop the deprecated IdentityServer4 package IdentityServer4 4.1.2 is EOL, built for .NET Core 3.1 and has advisories that will never be fixed. 11.0.0 is the last version of NetDevPack.Security.Jwt.IdentityServer4; it will be marked as deprecated on nuget.org. Removes the project and samples/3_IdentityServer4, and with them the only NU1902 suppression, the CI vulnerability exception and the Dependabot ignore rule. ADR-006 supersedes ADR-002. --- .github/dependabot.yml | 2 - .github/workflows/pull-request.yml | 3 +- AGENTS.md | 2 +- CLAUDE.md | 2 +- Directory.Packages.props | 2 - README.md | 41 +---------- docs/00-Index.md | 1 + docs/Architecture/Overview.md | 3 +- .../ADR-002-identityserver4-deprecated.md | 4 +- .../Decisions/ADR-006-drop-identityserver4.md | 20 ++++++ docs/Dependencies/Known-Issues.md | 5 +- docs/Dependencies/Policy.md | 4 +- docs/Samples.md | 3 +- docs/Workflows/Build-Test.md | 4 +- .../AspNet.IdentityServer4.csproj | 19 ----- samples/3_IdentityServer4/Config.cs | 26 ------- samples/3_IdentityServer4/Program.cs | 20 ------ .../Properties/launchSettings.json | 28 -------- samples/3_IdentityServer4/Startup.cs | 69 ------------------- .../appsettings.Development.json | 9 --- samples/3_IdentityServer4/appsettings.json | 10 --- .../IdentityServer4KeyStore.cs | 54 --------------- .../IdentityServerBuilderKeysExtensions.cs | 24 ------- ...evPack.Security.Jwt.IdentityServer4.csproj | 30 -------- src/NetDevPack.Security.Jwt.sln | 13 ---- 25 files changed, 39 insertions(+), 359 deletions(-) create mode 100644 docs/Decisions/ADR-006-drop-identityserver4.md delete mode 100644 samples/3_IdentityServer4/AspNet.IdentityServer4.csproj delete mode 100644 samples/3_IdentityServer4/Config.cs delete mode 100644 samples/3_IdentityServer4/Program.cs delete mode 100644 samples/3_IdentityServer4/Properties/launchSettings.json delete mode 100644 samples/3_IdentityServer4/Startup.cs delete mode 100644 samples/3_IdentityServer4/appsettings.Development.json delete mode 100644 samples/3_IdentityServer4/appsettings.json delete mode 100644 src/NetDevPack.Security.Jwt.IdentityServer4/IdentityServer4KeyStore.cs delete mode 100644 src/NetDevPack.Security.Jwt.IdentityServer4/IdentityServerBuilderKeysExtensions.cs delete mode 100644 src/NetDevPack.Security.Jwt.IdentityServer4/NetDevPack.Security.Jwt.IdentityServer4.csproj diff --git a/.github/dependabot.yml b/.github/dependabot.yml index af43178..0c10ce4 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -19,8 +19,6 @@ updates: update-types: ["version-update:semver-major"] - dependency-name: "System.Security.Cryptography.Xml" update-types: ["version-update:semver-major"] - # IdentityServer4 is EOL, see docs/Decisions/ADR-002-identityserver4-deprecated.md - - dependency-name: "IdentityServer4" # Never reintroduce FluentAssertions (commercial license since v8), see docs/Dependencies/Known-Issues.md - dependency-name: "FluentAssertions" diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 986593b..e1f4d37 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -36,5 +36,4 @@ jobs: - name: Check vulnerable packages run: | dotnet list package --vulnerable --include-transitive 2>&1 | tee vulnerable.txt - # IdentityServer4 is EOL with known advisories and is accepted on purpose (docs/Decisions/ADR-002) - ! grep -E '^\s+>' vulnerable.txt | grep -v ' IdentityServer4 ' + ! grep -E '^\s+>' vulnerable.txt diff --git a/AGENTS.md b/AGENTS.md index e25bd58..865b96a 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -13,7 +13,7 @@ dotnet list NetDevPack.Security.Jwt.sln package --vulnerable --include-transitiv ## Rules - Package versions only in `Directory.Packages.props` (Central Package Management). Never add `Version=` to a csproj. Microsoft.* packages follow the TFM (10.0.x). See `docs/Dependencies/Policy.md`. -- NuGet Audit warnings NU1901-NU1904 are build errors. IdentityServer4 is the only deliberate exception (deprecated, ADR-002). +- NuGet Audit warnings NU1901-NU1904 are build errors, with no exceptions (IdentityServer4 was dropped, ADR-006). - Commits: Conventional Commits (no local hook enforces it; semantic-release reads the messages). Use `chore(deps)` for dependency bumps. Breaking change = `feat!:` + `BREAKING CHANGE:` footer. semantic-release owns `CHANGELOG.md` and versions. - Public API in `src/` is a NuGet contract. Treat changes to it as breaking. - Encoding: UTF-8 with BOM + CRLF for C#/MSBuild files (enforced by `.editorconfig`). Never save files as UTF-16. diff --git a/CLAUDE.md b/CLAUDE.md index e25bd58..865b96a 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -13,7 +13,7 @@ dotnet list NetDevPack.Security.Jwt.sln package --vulnerable --include-transitiv ## Rules - Package versions only in `Directory.Packages.props` (Central Package Management). Never add `Version=` to a csproj. Microsoft.* packages follow the TFM (10.0.x). See `docs/Dependencies/Policy.md`. -- NuGet Audit warnings NU1901-NU1904 are build errors. IdentityServer4 is the only deliberate exception (deprecated, ADR-002). +- NuGet Audit warnings NU1901-NU1904 are build errors, with no exceptions (IdentityServer4 was dropped, ADR-006). - Commits: Conventional Commits (no local hook enforces it; semantic-release reads the messages). Use `chore(deps)` for dependency bumps. Breaking change = `feat!:` + `BREAKING CHANGE:` footer. semantic-release owns `CHANGELOG.md` and versions. - Public API in `src/` is a NuGet contract. Treat changes to it as breaking. - Encoding: UTF-8 with BOM + CRLF for C#/MSBuild files (enforced by `.editorconfig`). Never save files as UTF-16. diff --git a/Directory.Packages.props b/Directory.Packages.props index 38c4abc..1451b6a 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -12,8 +12,6 @@ - - diff --git a/README.md b/README.md index d8ecefb..c15e58c 100644 --- a/README.md +++ b/README.md @@ -43,7 +43,8 @@ It generates keys with RSA and ECDsa algorithms, which are the most recommended | `NetDevPack.Security.Jwt.AspNetCore` | [![Nuget](https://img.shields.io/nuget/v/NetDevPack.Security.Jwt.AspNetCore)](https://www.nuget.org/packages/NetDevPack.Security.Jwt.AspNetCore) | `/jwks` endpoint and `JwtBearer` validation integration | | `NetDevPack.Security.Jwt.Store.EntityFrameworkCore` | [![Nuget](https://img.shields.io/nuget/v/NetDevPack.Security.Jwt.Store.EntityFrameworkCore)](https://www.nuget.org/packages/NetDevPack.Security.Jwt.Store.EntityFrameworkCore) | Persist keys in a database | | `NetDevPack.Security.Jwt.Store.FileSystem` | [![Nuget](https://img.shields.io/nuget/v/NetDevPack.Security.Jwt.Store.FileSystem)](https://www.nuget.org/packages/NetDevPack.Security.Jwt.Store.FileSystem) | Persist keys in a folder | -| `NetDevPack.Security.Jwt.IdentityServer4` | [![Nuget](https://img.shields.io/nuget/v/NetDevPack.Security.Jwt.IdentityServer4)](https://www.nuget.org/packages/NetDevPack.Security.Jwt.IdentityServer4) | ⚠️ **Deprecated** - IdentityServer4 key material | + +> `NetDevPack.Security.Jwt.IdentityServer4` is **deprecated and no longer published**. IdentityServer4 reached end of life in 2022 and has known vulnerabilities. 11.0.0 was the last version; migrate to [Duende IdentityServer](https://duendesoftware.com/products/identityserver) or [OpenIddict](https://github.com/openiddict/openiddict-core). ### Supported frameworks @@ -129,7 +130,6 @@ app.MapGet("/token", async (IJwtService jwtService) => - [Changing Algorithm](#changing-algorithm) - [Jws](#jws) - [Jwe](#jwe) -- [IdentityServer4 - Auto jwks\_uri Management](#identityserver4---auto-jwks_uri-management) - [Why](#why) - [Load Balance scenarios](#load-balance-scenarios) - [Best practices](#best-practices) @@ -141,7 +141,7 @@ app.MapGet("/token", async (IJwtService jwtService) => # 🛡️ What is -The JSON Web Key Set (JWKS) is a collection of public keys used for verifying JSON Web Tokens (JWTs) issued by an authorization server. This component's primary objective is to provide a centralized storage and key rotation for your JWKs while adhering to best practices in JWK generation. It features a plugin for IdentityServer4, enabling automatic rotation of the jwks_uri every 90 days and seamless management of your jwks_uri. +The JSON Web Key Set (JWKS) is a collection of public keys used for verifying JSON Web Tokens (JWTs) issued by an authorization server. This component's primary objective is to provide a centralized storage and key rotation for your JWKs while adhering to best practices in JWK generation. If your API or OAuth 2.0 is deployed under a Load Balancer in Kubernetes or Docker Swarm, this component is essential. Its functionality is similar to the DataProtection Key in ASP.NET Core. @@ -391,7 +391,6 @@ You can find several examples [here](samples): | ------ | ------------- | | [1_AspNet.Default](samples/1_AspNet.Default) | Minimal API generating/validating JWS and JWE with the default (DataProtection) store | | [2_AspNet.Store.EntityFramework](samples/2_AspNet.Store.EntityFramework) | Same as above, persisting keys with EF Core | -| [3_IdentityServer4](samples/3_IdentityServer4) | ⚠️ Deprecated IdentityServer4 integration | | [Microservice.Sample](samples/Microservice.Sample) | Identity API exposing `/jwks` + client API validating through `NetDevPack.Security.JwtExtensions` | # Changing Algorithm @@ -456,40 +455,6 @@ Encryption options | Aes256CbcHmacSha512 | A256CBC-HS512 | -# IdentityServer4 - Auto jwks_uri Management - -> ⚠️ **Deprecated.** IdentityServer4 reached end of life in 2022 and has known vulnerabilities ([GHSA-55p7-v223-x366](https://github.com/advisories/GHSA-55p7-v223-x366), [GHSA-ff4q-64jc-gx98](https://github.com/advisories/GHSA-ff4q-64jc-gx98)). The package is kept only for backward compatibility and will not receive new features. Consider migrating to [Duende IdentityServer](https://duendesoftware.com/products/identityserver) or [OpenIddict](https://github.com/openiddict/openiddict-core). - -`NetDevPack.Security.Jwt` provides `IdentityServer4` key material. It auto generates and rotates the key. - - -First install -``` -Install-Package NetDevPack.Security.Jwt.IdentityServer4 -``` - -Or via the .NET command line interface: - -``` -dotnet add package NetDevPack.Security.Jwt.IdentityServer4 -``` - -Go to `Startup.cs` - -``` c# -public void ConfigureServices(IServiceCollection services) -{ - var builder = services.AddIdentityServer() - .AddInMemoryIdentityResources(Config.GetIdentityResources()) - .AddInMemoryApiResources(Config.GetApis()) - .AddInMemoryClients(Config.GetClients()); - - services.AddJwksManager().IdentityServer4AutoJwksManager(); -} -``` - -If you want to use a database, follow the [Database](#database) instructions instead. - # Why When developing applications and APIs using OAuth 2.0 or simply signing a JWT, various algorithms are supported. Among these algorithms, some are considered best practices and superior to others, such as RSA-PSS (PS256) or Elliptic Curve (ES256). Certain Auth servers operate with deterministic algorithms, while others use probabilistic ones. Some servers, like Auth0, do not support multiple JWKs, but IdentityServer4 supports as many as you configure. This component is designed to abstract this layer and offer your application the current best practices for JWK management. diff --git a/docs/00-Index.md b/docs/00-Index.md index ca0ff27..aecf797 100644 --- a/docs/00-Index.md +++ b/docs/00-Index.md @@ -30,3 +30,4 @@ Open the `docs/` folder as an Obsidian vault, or just read the Markdown on GitHu - [[ADR-003-central-package-management]] - [[ADR-004-remove-legacy-asymmetric-sample]] - [[ADR-005-net10-only]] +- [[ADR-006-drop-identityserver4]] diff --git a/docs/Architecture/Overview.md b/docs/Architecture/Overview.md index dc615ba..6083008 100644 --- a/docs/Architecture/Overview.md +++ b/docs/Architecture/Overview.md @@ -1,6 +1,6 @@ --- tags: [architecture] -updated: 2026-11-17 +updated: 2026-11-18 --- # Overview @@ -14,7 +14,6 @@ Library that **generates, stores, rotates and publishes** the keys used to sign | `NetDevPack.Security.Jwt.AspNetCore` | `NetDevPack.Security.Jwt.AspNetCore` | `UseJwksDiscovery()` endpoint + `UseJwtValidation()` — see [[AspNetCore-Integration]] | | `NetDevPack.Security.Jwt.Store.EntityFrameworkCore` | same | `PersistKeysToDatabaseStore()` — see [[Stores]] | | `NetDevPack.Security.Jwt.Store.FileSystem` | same | `PersistKeysToFileSystem(DirectoryInfo)` | -| `NetDevPack.Security.Jwt.IdentityServer4` | same | **Deprecated**, see [[ADR-002-identityserver4-deprecated]] | Note: the Core *project* name differs from its *package id* (`NetDevPack.Security.Jwt`). diff --git a/docs/Decisions/ADR-002-identityserver4-deprecated.md b/docs/Decisions/ADR-002-identityserver4-deprecated.md index 3100cad..b0f6881 100644 --- a/docs/Decisions/ADR-002-identityserver4-deprecated.md +++ b/docs/Decisions/ADR-002-identityserver4-deprecated.md @@ -1,6 +1,6 @@ --- tags: [adr] -status: accepted +status: superseded date: 2026-10-01 --- # ADR-002 — Keep IdentityServer4 package as deprecated @@ -11,4 +11,6 @@ date: 2026-10-01 **Alternatives considered.** Removing it (breaks users). Migrating to Duende (commercial license, big scope). OpenIddict could get a future integration package. +**Superseded** by [[ADR-006-drop-identityserver4]] on 2026-11-18: the package is no longer built or published. + Related: [[Known-Issues]]. diff --git a/docs/Decisions/ADR-006-drop-identityserver4.md b/docs/Decisions/ADR-006-drop-identityserver4.md new file mode 100644 index 0000000..3295203 --- /dev/null +++ b/docs/Decisions/ADR-006-drop-identityserver4.md @@ -0,0 +1,20 @@ +--- +tags: [adr] +status: accepted +date: 2026-11-18 +--- +# ADR-006 — Stop publishing the IdentityServer4 package + +**Context.** [[ADR-002-identityserver4-deprecated]] kept `NetDevPack.Security.Jwt.IdentityServer4` building and publishing for backward compatibility. Since [[ADR-005-net10-only]] every package targets .NET 10. IdentityServer4 4.1.2 was built for .NET Core 3.1, has been EOL since 2022 and has advisories that will never be fixed (GHSA-55p7-v223-x366, GHSA-ff4q-64jc-gx98). Keeping it meant the only `NU1902` suppression in the repo, an exception in the CI vulnerability check and a Dependabot ignore rule. It also kept shipping a new version of a package nobody should adopt. + +**Decision.** +- Remove `src/NetDevPack.Security.Jwt.IdentityServer4` and `samples/3_IdentityServer4` from the repo and the solution. **11.0.0 is the last version.** +- Mark every version of the package as **deprecated** on nuget.org (reason: legacy, has critical bugs). Point users to `NetDevPack.Security.Jwt.AspNetCore` plus Duende IdentityServer or OpenIddict. +- NuGet Audit and the CI vulnerability check now run with no exceptions. + +**Consequences.** +- Existing consumers keep working on ≤ 11.0.0, and NuGet shows them the deprecation warning. +- Not a breaking change for the other packages: the public API of `NetDevPack.Security.Jwt*` doesn't change, so this ships with no release (`chore:`). +- An integration for a maintained server (OpenIddict) can be a new package in the future. + +Related: [[Known-Issues]], [[Policy]]. diff --git a/docs/Dependencies/Known-Issues.md b/docs/Dependencies/Known-Issues.md index 91d4e51..927e705 100644 --- a/docs/Dependencies/Known-Issues.md +++ b/docs/Dependencies/Known-Issues.md @@ -1,11 +1,11 @@ --- tags: [dependencies, tech-debt] -updated: 2026-11-17 +updated: 2026-11-18 --- # Known Issues / Tech Debt ## Dependencies -- **IdentityServer4 4.1.2**: EOL, moderate vulnerabilities (GHSA-55p7-v223-x366, GHSA-ff4q-64jc-gx98). `NU1902` is suppressed only in `NetDevPack.Security.Jwt.IdentityServer4` and `samples/3_IdentityServer4`. See [[ADR-002-identityserver4-deprecated]]. +- None known. NuGet Audit runs with no exceptions. ## Code - `JwtServiceValidationHandler` extends the legacy `JwtSecurityTokenHandler` and blocks on `Task.WaitAll(jwtService.GetLastKeys())`. Better: a `JsonWebTokenHandler` + async `IssuerSigningKeyResolver`, or set the keys in `OnMessageReceived`. @@ -16,6 +16,7 @@ updated: 2026-11-17 - The `DataProtectionStore` fallback exception message still mentions the old `JwtSigningCredentials` package names. ## Resolved +- 2026-11-18: removed `NetDevPack.Security.Jwt.IdentityServer4` and `samples/3_IdentityServer4` ([[ADR-006-drop-identityserver4]]). IdentityServer4 4.1.2 (EOL, GHSA-55p7-v223-x366, GHSA-ff4q-64jc-gx98) is no longer a dependency, so the `NU1902` suppression and the CI exception are gone. - 2026-11-17: dropped net8.0/net9.0 ([[ADR-005-net10-only]]). Migrated xunit 2 → **xunit.v3** on Microsoft.Testing.Platform; `Microsoft.NET.Test.Sdk`, `xunit.runner.visualstudio` and `coverlet.collector` removed. Fixed the xUnit1051 warnings in `AspNetCoreTests`. - 2026-10-01: migrated FluentAssertions 8.11 (Xceed commercial license) → **AwesomeAssertions 9.6** (Apache-2.0 fork, same API, namespace `AwesomeAssertions`). Do not reintroduce FluentAssertions. - 2026-10-01: 6 `.cs` files in UTF-16 LE (`CryptoService`, `IdentityServer4KeyStore`, `IdentityServerBuilderKeysExtensions`, `EFCoreServiceExtensions`, `ISecurityKeyContext`, `KeyMaterialMap`) were converted to UTF-8 BOM + CRLF. `.editorconfig` now enforces the encoding. diff --git a/docs/Dependencies/Policy.md b/docs/Dependencies/Policy.md index 68f4e9d..a8cdceb 100644 --- a/docs/Dependencies/Policy.md +++ b/docs/Dependencies/Policy.md @@ -1,6 +1,6 @@ --- tags: [dependencies, policy] -updated: 2026-11-17 +updated: 2026-11-18 --- # Dependency Policy @@ -23,7 +23,7 @@ dotnet list NetDevPack.Security.Jwt.sln package --vulnerable --include-transitiv 3. `dotnet build -c Release` + `dotnet test -c Release` (see [[Build-Test]]). 4. Commit as `chore(deps): ...` (see [[Release]]). -Dependabot (`.github/dependabot.yml`) runs weekly and ignores majors for `Microsoft.*` and also ignores `IdentityServer4`. +Dependabot (`.github/dependabot.yml`) runs weekly and ignores majors for `Microsoft.*`. ## Adding a new TFM (e.g. net11.0) 1. `src/Directory.Build.props` `TargetFramework` → `TargetFrameworks` + every test/sample csproj. diff --git a/docs/Samples.md b/docs/Samples.md index 2b73ccd..78f0d74 100644 --- a/docs/Samples.md +++ b/docs/Samples.md @@ -1,6 +1,6 @@ --- tags: [samples] -updated: 2026-11-17 +updated: 2026-11-18 --- # Samples (`samples/`) @@ -10,7 +10,6 @@ All samples are in `src/NetDevPack.Security.Jwt.sln`, target net10.0 and use pro | --- | --- | | `1_AspNet.Default` | Minimal API: generate/validate JWS & JWE, `[Authorize]` endpoint. **Also the host for `AspNetCoreTests`.** Changing it can break tests | | `2_AspNet.Store.EntityFramework` | Same, with `PersistKeysToDatabaseStore()` (SQLite/SQL Server) | -| `3_IdentityServer4` | Deprecated IdS4 integration ([[ADR-002-identityserver4-deprecated]]) | | `Microservice.Sample/Identity` | Token issuer exposing `/jwks` (EF Core store) | | `Microservice.Sample/Api.Sample` | Client API validating via NuGet `NetDevPack.Security.JwtExtensions` | diff --git a/docs/Workflows/Build-Test.md b/docs/Workflows/Build-Test.md index 297294a..d7dc684 100644 --- a/docs/Workflows/Build-Test.md +++ b/docs/Workflows/Build-Test.md @@ -1,6 +1,6 @@ --- tags: [workflow] -updated: 2026-11-17 +updated: 2026-11-18 --- # Build & Test @@ -20,4 +20,4 @@ dotnet pack -c Release -o ./out # 5 .nupkg + .snupkg, lib/net10.0 - Test projects: `NetDevPack.Security.Jwt.Tests` (about 514 tests) and `NetDevPack.Security.Jwt.AspNetCoreTests`. - A test can be flaky, see [[Known-Issues]]. -CI: `.github/workflows/pull-request.yml` runs restore, build, test and the vulnerability check (IdentityServer4 is the only accepted advisory, see [[ADR-002-identityserver4-deprecated]]). +CI: `.github/workflows/pull-request.yml` runs restore, build, test and the vulnerability check (no accepted advisories, see [[ADR-006-drop-identityserver4]]). diff --git a/samples/3_IdentityServer4/AspNet.IdentityServer4.csproj b/samples/3_IdentityServer4/AspNet.IdentityServer4.csproj deleted file mode 100644 index 9b52768..0000000 --- a/samples/3_IdentityServer4/AspNet.IdentityServer4.csproj +++ /dev/null @@ -1,19 +0,0 @@ - - - - net10.0 - false - - $(NoWarn);NU1902 - $(WarningsAsErrors.Replace('NU1902', '')) - - - - - - - - - - - diff --git a/samples/3_IdentityServer4/Config.cs b/samples/3_IdentityServer4/Config.cs deleted file mode 100644 index d27b5a5..0000000 --- a/samples/3_IdentityServer4/Config.cs +++ /dev/null @@ -1,26 +0,0 @@ -using System.Collections.Generic; -using IdentityServer4.Models; - -namespace NetDevPack.Security.Jwt.IdentityServer4.Tests -{ - public static class Config - { - public static IEnumerable GetIdentityResources() - { - return new IdentityResource[] - { - new IdentityResources.OpenId() - }; - } - - public static IEnumerable GetApis() - { - return new ApiResource[] { }; - } - - public static IEnumerable GetClients() - { - return new Client[] { }; - } - } -} diff --git a/samples/3_IdentityServer4/Program.cs b/samples/3_IdentityServer4/Program.cs deleted file mode 100644 index 249ec6f..0000000 --- a/samples/3_IdentityServer4/Program.cs +++ /dev/null @@ -1,20 +0,0 @@ -using Microsoft.AspNetCore.Hosting; -using Microsoft.Extensions.Hosting; - -namespace NetDevPack.Security.Jwt.IdentityServer4.Tests -{ - public class Program - { - public static void Main(string[] args) - { - CreateHostBuilder(args).Build().Run(); - } - - public static IHostBuilder CreateHostBuilder(string[] args) => - Host.CreateDefaultBuilder(args) - .ConfigureWebHostDefaults(webBuilder => - { - webBuilder.UseStartup(); - }); - } -} diff --git a/samples/3_IdentityServer4/Properties/launchSettings.json b/samples/3_IdentityServer4/Properties/launchSettings.json deleted file mode 100644 index aba22b1..0000000 --- a/samples/3_IdentityServer4/Properties/launchSettings.json +++ /dev/null @@ -1,28 +0,0 @@ -{ - "iisSettings": { - "windowsAuthentication": false, - "anonymousAuthentication": true, - "iisExpress": { - "applicationUrl": "http://localhost:46082", - "sslPort": 0 - } - }, - "profiles": { - "IIS Express": { - "commandName": "IISExpress", - "launchBrowser": true, - "environmentVariables": { - "ASPNETCORE_ENVIRONMENT": "Development" - } - }, - "NetDevPack.Security.JwtSigningCredentials.IdentityServer4.Tests": { - "commandName": "Project", - "launchBrowser": true, - "launchUrl": ".well-known/openid-configuration/jwks", - "applicationUrl": "http://localhost:5000", - "environmentVariables": { - "ASPNETCORE_ENVIRONMENT": "Development" - } - } - } -} diff --git a/samples/3_IdentityServer4/Startup.cs b/samples/3_IdentityServer4/Startup.cs deleted file mode 100644 index 600e9a7..0000000 --- a/samples/3_IdentityServer4/Startup.cs +++ /dev/null @@ -1,69 +0,0 @@ -using Microsoft.AspNetCore.Builder; -using Microsoft.AspNetCore.Hosting; -using Microsoft.Extensions.Configuration; -using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Hosting; -using Newtonsoft.Json; - -namespace NetDevPack.Security.Jwt.IdentityServer4.Tests -{ - public class Startup - { - private readonly IWebHostEnvironment _env; - - public Startup(IConfiguration configuration, IWebHostEnvironment env) - { - _env = env; - Configuration = configuration; - } - - public IConfiguration Configuration { get; } - - // This method gets called by the runtime. Use this method to add services to the container. - public void ConfigureServices(IServiceCollection services) - { - services.AddControllersWithViews() - .AddNewtonsoftJson(options => - { - options.SerializerSettings.NullValueHandling = NullValueHandling.Ignore; - options.AllowInputFormatterExceptionMessages = true; - }); ; - - services.AddMemoryCache(); - var builder = services.AddIdentityServer() - .AddInMemoryIdentityResources(Config.GetIdentityResources()) - .AddInMemoryApiResources(Config.GetApis()) - .AddInMemoryClients(Config.GetClients()); - - - services.AddJwksManager().IdentityServer4AutoJwksManager(); - } - - // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. - public void Configure(IApplicationBuilder app, IWebHostEnvironment env) - { - if (env.IsDevelopment()) - { - app.UseDeveloperExceptionPage(); - } - else - { - app.UseExceptionHandler("/Home/Error"); - } - app.UseStaticFiles(); - - app.UseRouting(); - - app.UseAuthorization(); - app.UseIdentityServer(); - app.UseJwksDiscovery(); - app.UseEndpoints(endpoints => - { - endpoints.MapControllerRoute( - name: "default", - pattern: "{controller=Home}/{action=Index}/{id?}"); - }); - - } - } -} diff --git a/samples/3_IdentityServer4/appsettings.Development.json b/samples/3_IdentityServer4/appsettings.Development.json deleted file mode 100644 index 8983e0f..0000000 --- a/samples/3_IdentityServer4/appsettings.Development.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "Logging": { - "LogLevel": { - "Default": "Information", - "Microsoft": "Warning", - "Microsoft.Hosting.Lifetime": "Information" - } - } -} diff --git a/samples/3_IdentityServer4/appsettings.json b/samples/3_IdentityServer4/appsettings.json deleted file mode 100644 index d9d9a9b..0000000 --- a/samples/3_IdentityServer4/appsettings.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "Logging": { - "LogLevel": { - "Default": "Information", - "Microsoft": "Warning", - "Microsoft.Hosting.Lifetime": "Information" - } - }, - "AllowedHosts": "*" -} diff --git a/src/NetDevPack.Security.Jwt.IdentityServer4/IdentityServer4KeyStore.cs b/src/NetDevPack.Security.Jwt.IdentityServer4/IdentityServer4KeyStore.cs deleted file mode 100644 index d7a8684..0000000 --- a/src/NetDevPack.Security.Jwt.IdentityServer4/IdentityServer4KeyStore.cs +++ /dev/null @@ -1,54 +0,0 @@ -using IdentityServer4.Models; -using IdentityServer4.Stores; -using Microsoft.Extensions.Caching.Memory; -using Microsoft.Extensions.Options; -using Microsoft.IdentityModel.Tokens; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using NetDevPack.Security.Jwt.Core; -using NetDevPack.Security.Jwt.Core.Interfaces; - -namespace NetDevPack.Security.Jwt.IdentityServer4; - -internal class IdentityServer4KeyStore : IValidationKeysStore, ISigningCredentialStore -{ - private readonly IJwtService _keyService; - private readonly IMemoryCache _memoryCache; - private readonly IOptions _options; - - /// Constructor for IdentityServer4KeyStore. - /// - /// - /// - public IdentityServer4KeyStore(IJwtService keyService, IMemoryCache memoryCache, IOptions options) - { - _keyService = keyService; - _memoryCache = memoryCache; - _options = options; - } - - /// Returns the current signing key. - /// - public Task GetSigningCredentialsAsync() - { - return _keyService.GetCurrentSigningCredentials(); - } - - /// Returns all the validation keys. - /// - public async Task> GetValidationKeysAsync() - { - var keys = await _keyService.GetLastKeys(_options.Value.AlgorithmsToKeep); - if (!keys.Any()) - await _keyService.GenerateKey(); - - keys = await _keyService.GetLastKeys(_options.Value.AlgorithmsToKeep); - - return keys.Select(s => new SecurityKeyInfo() - { - Key = s, - SigningAlgorithm = _options.Value.Jws - }); - } -} \ No newline at end of file diff --git a/src/NetDevPack.Security.Jwt.IdentityServer4/IdentityServerBuilderKeysExtensions.cs b/src/NetDevPack.Security.Jwt.IdentityServer4/IdentityServerBuilderKeysExtensions.cs deleted file mode 100644 index 226f3f5..0000000 --- a/src/NetDevPack.Security.Jwt.IdentityServer4/IdentityServerBuilderKeysExtensions.cs +++ /dev/null @@ -1,24 +0,0 @@ -using IdentityServer4.Stores; -using Microsoft.Extensions.DependencyInjection; -using NetDevPack.Security.Jwt.Core.Interfaces; -using NetDevPack.Security.Jwt.IdentityServer4; - -namespace Microsoft.Extensions.DependencyInjection; - -/// -/// Builder extension methods for registering crypto services -/// -public static class IdentityServerBuilderKeysExtensions -{ - /// - /// Sets the signing credential. - /// - /// - public static IJwksBuilder IdentityServer4AutoJwksManager(this IJwksBuilder builder) - { - builder.Services.AddScoped(); - builder.Services.AddScoped(); - builder.Services.AddMemoryCache(); - return builder; - } -} \ No newline at end of file diff --git a/src/NetDevPack.Security.Jwt.IdentityServer4/NetDevPack.Security.Jwt.IdentityServer4.csproj b/src/NetDevPack.Security.Jwt.IdentityServer4/NetDevPack.Security.Jwt.IdentityServer4.csproj deleted file mode 100644 index 7e0c74d..0000000 --- a/src/NetDevPack.Security.Jwt.IdentityServer4/NetDevPack.Security.Jwt.IdentityServer4.csproj +++ /dev/null @@ -1,30 +0,0 @@ - - - - NetDevPack.Security.Jwt.IdentityServer4 - [DEPRECATED] JWT Signing Credentials - IdentityServer4 Support - - DEPRECATED: IdentityServer4 reached end of life and has known vulnerabilities. Prefer Duende IdentityServer or OpenIddict. - Integration package for IdentityServer4 to manage JWK/JWKS with automatic key rotation (RSA, ECDSA, HMAC). - - deprecated;jwt;jwks;jwk;identityserver4;rsa;ecdsa;hmac;oauth2;openid;key-rotation;security;cryptography - - v10.0.0: - - Package is deprecated: IdentityServer4 is EOL (see GHSA-55p7-v223-x366 / GHSA-ff4q-64jc-gx98) - - IdentityServer4 integration for JWK/JWKS management and automatic key rotation support - - - $(NoWarn);NU1902 - $(WarningsAsErrors.Replace('NU1902', '')) - - - - - - - - - - - - diff --git a/src/NetDevPack.Security.Jwt.sln b/src/NetDevPack.Security.Jwt.sln index c5b0b37..c5608bb 100644 --- a/src/NetDevPack.Security.Jwt.sln +++ b/src/NetDevPack.Security.Jwt.sln @@ -15,8 +15,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NetDevPack.Security.Jwt.Sto EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NetDevPack.Security.Jwt.Store.EntityFrameworkCore", "NetDevPack.Security.Jwt.Store.EntityFrameworkCore\NetDevPack.Security.Jwt.Store.EntityFrameworkCore.csproj", "{22720E4B-1668-4C1E-81E4-45A40F95DEEA}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NetDevPack.Security.Jwt.IdentityServer4", "NetDevPack.Security.Jwt.IdentityServer4\NetDevPack.Security.Jwt.IdentityServer4.csproj", "{042A314A-9BCE-4937-9C05-25BBEE2701A3}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NetDevPack.Security.Jwt.AspNetCore", "NetDevPack.Security.Jwt.AspNetCore\NetDevPack.Security.Jwt.AspNetCore.csproj", "{6D7E0BD7-0AB9-4834-A536-28A0741CCB3C}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AspNet.Default", "..\samples\1_AspNet.Default\AspNet.Default.csproj", "{843673CF-96A7-412F-8CA5-76357A47444D}" @@ -25,8 +23,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AspNet.Store.EntityFramewor EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Microservice.Sample", "Microservice.Sample", "{1E9A6B9E-DC4A-4B17-A252-3578BC5BE853}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AspNet.IdentityServer4", "..\samples\3_IdentityServer4\AspNet.IdentityServer4.csproj", "{7EE1F124-DD0E-452D-8B13-D108FF9DF277}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Identity", "..\samples\Microservice.Sample\Identity\Identity.csproj", "{B96A31FB-827A-43C8-AC4B-BAC66AB528CB}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Api.Sample", "..\samples\Microservice.Sample\Api.Sample\Api.Sample.csproj", "{F7877CF4-6ADF-456F-BC27-B1BB935366FD}" @@ -55,10 +51,6 @@ Global {22720E4B-1668-4C1E-81E4-45A40F95DEEA}.Debug|Any CPU.Build.0 = Debug|Any CPU {22720E4B-1668-4C1E-81E4-45A40F95DEEA}.Release|Any CPU.ActiveCfg = Release|Any CPU {22720E4B-1668-4C1E-81E4-45A40F95DEEA}.Release|Any CPU.Build.0 = Release|Any CPU - {042A314A-9BCE-4937-9C05-25BBEE2701A3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {042A314A-9BCE-4937-9C05-25BBEE2701A3}.Debug|Any CPU.Build.0 = Debug|Any CPU - {042A314A-9BCE-4937-9C05-25BBEE2701A3}.Release|Any CPU.ActiveCfg = Release|Any CPU - {042A314A-9BCE-4937-9C05-25BBEE2701A3}.Release|Any CPU.Build.0 = Release|Any CPU {6D7E0BD7-0AB9-4834-A536-28A0741CCB3C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {6D7E0BD7-0AB9-4834-A536-28A0741CCB3C}.Debug|Any CPU.Build.0 = Debug|Any CPU {6D7E0BD7-0AB9-4834-A536-28A0741CCB3C}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -71,10 +63,6 @@ Global {78D4D49E-6600-4545-A727-363ADF6B56EA}.Debug|Any CPU.Build.0 = Debug|Any CPU {78D4D49E-6600-4545-A727-363ADF6B56EA}.Release|Any CPU.ActiveCfg = Release|Any CPU {78D4D49E-6600-4545-A727-363ADF6B56EA}.Release|Any CPU.Build.0 = Release|Any CPU - {7EE1F124-DD0E-452D-8B13-D108FF9DF277}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {7EE1F124-DD0E-452D-8B13-D108FF9DF277}.Debug|Any CPU.Build.0 = Debug|Any CPU - {7EE1F124-DD0E-452D-8B13-D108FF9DF277}.Release|Any CPU.ActiveCfg = Release|Any CPU - {7EE1F124-DD0E-452D-8B13-D108FF9DF277}.Release|Any CPU.Build.0 = Release|Any CPU {B96A31FB-827A-43C8-AC4B-BAC66AB528CB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {B96A31FB-827A-43C8-AC4B-BAC66AB528CB}.Debug|Any CPU.Build.0 = Debug|Any CPU {B96A31FB-827A-43C8-AC4B-BAC66AB528CB}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -96,7 +84,6 @@ Global {843673CF-96A7-412F-8CA5-76357A47444D} = {BF65DEED-7A2D-44FF-B1F5-9F317FE93ADC} {78D4D49E-6600-4545-A727-363ADF6B56EA} = {BF65DEED-7A2D-44FF-B1F5-9F317FE93ADC} {1E9A6B9E-DC4A-4B17-A252-3578BC5BE853} = {BF65DEED-7A2D-44FF-B1F5-9F317FE93ADC} - {7EE1F124-DD0E-452D-8B13-D108FF9DF277} = {BF65DEED-7A2D-44FF-B1F5-9F317FE93ADC} {B96A31FB-827A-43C8-AC4B-BAC66AB528CB} = {1E9A6B9E-DC4A-4B17-A252-3578BC5BE853} {F7877CF4-6ADF-456F-BC27-B1BB935366FD} = {1E9A6B9E-DC4A-4B17-A252-3578BC5BE853} {5BC8EC00-578F-41F8-ACB8-D95D3F0EA589} = {CEA99B61-BEF7-4CE5-A68A-0784625A6B43}