duendesoftware/duende-skills/identityserver4-migration

Claude Code and agent skill by duendesoftware/duende-skills

Trust tier 3
  • community
Source check pending

Checking that the SKILL.md file is still in the repository.

Migrating from IdentityServer4 to Duende IdentityServer v8. Covers NuGet package replacement, namespace changes, API surface changes, EF Core database schema migrations, .NET target framework upgrade, license configuration, signing key migration, data protection, and UI template updates.

Install

npx vskill@latest install duendesoftware/duende-skills/identityserver4-migration

SKILL.md

The same SKILL.md was published earlier as duendesoftware/duende-skills/identityserver4-migration.

Migrating from IdentityServer4 to Duende IdentityServer

Scope: IdentityServer4 only. This skill covers migrating from IdentityServer4 (v3.x and v4.x) to Duende IdentityServer. It does not cover migrating from IdentityServer3 (the older Thinktecture/IdentityServer3 NuGet package that ran on OWIN/Katana and .NET Framework). IdentityServer3 is a fundamentally different product with a different API surface, configuration model, and hosting stack. If you are on IdentityServer3, you must first port to IdentityServer4 on ASP.NET Core before using this guide.

When to Use This Skill

  • Planning a migration from IdentityServer4 to Duende IdentityServer — running the migration analysis tool
  • Upgrading a project from IdentityServer4 (v3.x or v4.x) to Duende IdentityServer v8
  • Replacing IdentityServer4 NuGet packages with Duende equivalents
  • Updating IdentityServer4.* namespaces to Duende.IdentityServer.*
  • Migrating EF Core database schemas from IdentityServer4 to Duende IdentityServer
  • Upgrading the .NET target framework from netcoreapp3.1 or net5.0 to a current LTS version
  • Resolving breaking API changes between IdentityServer4 and Duende IdentityServer
  • Converting Startup.cs/Program.cs hosting patterns from Generic Host to minimal hosting
  • Configuring the Duende IdentityServer license key after migration
  • Determining the right Duende license edition based on client inventory (interactive vs. non-interactive)
  • Preserving the issuer URI to maintain token and client trust continuity
  • Migrating signing keys from IdentityServer4 developer signing credential to Duende automatic key management
  • Verifying third-party authentication scheme compatibility with the new .NET version
  • Updating UI templates (login, logout, consent) from IdentityServer4 Quickstart UI to Duende templates

Core Principles

Migration has two stages if starting from v3.x. IdentityServer4 v3 → v4 introduced breaking changes in the ApiResource/ApiScope relationship (parent-child to many-to-many). If you are on v3, first migrate to v4 semantics, then migrate from v4 to Duende. If you are already on IdentityServer4 v4.x, you can go directly to Duende.

Duende IdentityServer is the direct successor to IdentityServer4. The API surface is intentionally similar — most code changes are namespace and package renames. Behavioral changes are minimal, but the database schema has new tables and columns for features like automatic key management, server-side sessions, DPoP, and PAR.

The .NET target framework must be upgraded alongside the IdentityServer migration. IdentityServer4 ran on netcoreapp3.1 or net5.0. Duende IdentityServer v8 requires net10.0. You must follow Microsoft's ASP.NET Core migration guides for each major version jump.

Database migrations require careful handling to avoid data loss. The v3 → v4 schema change renames tables and restructures relationships. A naive EF Core migration will drop and recreate tables, losing data. Use the provided delta SQL scripts or manually craft migrations that preserve data.

Licensing is required for production use. Duende IdentityServer requires a valid license key for production. Without one, it runs in community/trial mode and logs a warning on startup.

Docs: https://docs.duendesoftware.com/identityserver/upgrades


Migration Path Overview

IdentityServer4 v3.x or v4.x
│
▼ (Step 0: Run Migration Analysis Tool against running instance)
│
▼ (Stage 1: v3 → v4 API changes + DB migration — skip if already on v4)
IdentityServer4 v4.x
│
▼ (Stage 2: packages + namespaces + .NET upgrade + DB migration)
Duende IdentityServer v8.x

If already on IdentityServer4 v4.x, skip directly to Stage 2.


Step 0: Run the Migration Analysis Tool (Recommended)

Before making any code changes, run the Migration Analysis Tool against your running IdentityServer4 instance. This tool inspects your live configuration and produces a report with specific recommendations.

The tool is a single file, `MigrationAnalysisController.cs`, that you drop into your existing IdentityServer4 project. It does not require additional NuGet packages.

What the tool inspects
Data PointWhy It Matters
.NET runtime versionFlags if you need to upgrade to .NET 10
IdentityServer4 versionDetermines if Stage 1 (v3 → v4) is needed before proceeding
Client inventoryCounts interactive (authorization code) vs. non-interactive (client credentials) clients — this determines which Duende license edition you need
Issuer URIReports the configured IssuerUri — must be preserved in Duende to avoid breaking existing tokens and client trust relationships
Signing credential store typeIdentifies custom signing stores that may need compatibility updates
Signing credential key IDRecords the current key ID for signing key migration planning
Data protection application nameFlags missing or path-based discriminators that will break after .NET upgrade
Data protection repository typeWarns if keys are stored ephemerally (lost on restart) instead of a persistent store
Authentication schemesLists all registered authentication handlers — third-party handlers (non-Microsoft, non-IdentityServer4) may need version updates for the new ASP.NET Core version
Usage
  1. Download MigrationAnalysisController.cs and add it to your IdentityServer4 project
  2. Update the authorization check in the Index() method — the default placeholder checks for username "scott" which you must replace with your own authorization logic
  3. Build, run, and navigate to /MigrationAnalysis while authenticated
  4. Review the report and use it to plan your migration

The tool loads clients from in-memory configuration or EF Core stores automatically. If you use a custom client store, you will need to modify the constructor to wire up your client retrieval.

Note: Duende also offers a free IdentityServer4 upgrade assessment to walk through your upgrade path.

Stage 1: IdentityServer4 v3.x → v4.x

Skip this section if you are already on IdentityServer4 v4.x.

Step 1.1: Update NuGet Packages to v4
xml
<!-- Old (v3) -->
<PackageReference Include="IdentityServer4" Version="3.1.4" />
<PackageReference Include="IdentityServer4.EntityFramework" Version="3.1.4" />
<PackageReference Include="IdentityServer4.AspNetIdentity" Version="3.1.4" />
<!-- New (v4) -->
<PackageReference Include="IdentityServer4" Version="4.1.2" />
<PackageReference Include="IdentityServer4.EntityFramework" Version="4.1.2" />
<PackageReference Include="IdentityServer4.AspNetIdentity" Version="4.1.2" />
Step 1.2: Register API Scopes Separately

In v3, ApiScope was a child of ApiResource. In v4, scopes are independent top-level objects with a many-to-many relationship to API resources. You must register them separately:

csharp
// v3: Scopes nested inside ApiResource
new ApiResource("api1", "My API")
{
Scopes = { new Scope("api1.read"), new Scope("api1.write") }
}
// v4: Scopes are independent; ApiResource references scope names
public static IEnumerable<ApiScope> ApiScopes => new[]
{
new ApiScope("api1.read", "Read access to API 1"),
new ApiScope("api1.write", "Write access to API 1")
};
public static IEnumerable<ApiResource> ApiResources => new[]
{
new ApiResource("api1", "My API")
{
Scopes = { "api1.read", "api1.write" } // string references, not Scope objects
}
};
// Register both:
services.AddIdentityServer()
.AddInMemoryApiScopes(Config.ApiScopes) // NEW in v4
.AddInMemoryApiResources(Config.ApiResources)
.AddInMemoryClients(Config.Clients);
Step 1.3: Fix Breaking API Changes (v3 → v4)

HttpContext.SignInAsync signature change:

csharp
// v3
await HttpContext.SignInAsync(user.SubjectId, user.Username, props);
// v4
var isuser = new IdentityServerUser(user.SubjectId)
{
DisplayName = user.Username
};
await HttpContext.SignInAsync(isuser, props);

AuthorizationRequest property changes:

csharp
// v3
var clientId = request.ClientId;
var scopes = request.ScopesRequested;
var isPkce = await _clientStore.IsPkceClientAsync(context.ClientId);
// v4
var clientId = request.Client.ClientId;
var scopes = request.ValidatedResources.RawScopeValues;
var isPkce = context.IsNativeClient();

Consent response changes:

csharp
// v3
var grantedConsent = new ConsentResponse
{
ScopesConsented = consentedScopes
};
// v4
var grantedConsent = new ConsentResponse
{
ScopesValuesConsented = consentedScopes // renamed property
};

Grant management method renames:

csharp
// v3
await _interaction.GetAllUserConsentsAsync();
// v4
await _interaction.GetAllUserGrantsAsync();

External provider callback consolidation:

csharp
// v3: separate methods per protocol
ProcessLoginCallbackForOidc();
ProcessLoginCallbackForWsFed();
ProcessLoginCallbackForSaml2p();
// v4: single unified method
ProcessLoginCallback();
Step 1.4: Migrate the Database (v3 → v4)

PersistedGrantDbContext — Standard EF migration:

bash
dotnet ef migrations add Grants_v4 -c PersistedGrantDbContext -o Migrations/PersistedGrantDb
dotnet ef database update -c PersistedGrantDbContext

New columns added: ConsumedTime, Description, SessionId on PersistedGrants and DeviceCodes.

ConfigurationDbContext — Requires custom SQL to preserve data:

The v3 → v4 schema change renames tables:

  • ApiClaims → ApiResourceClaims
  • ApiProperties → ApiResourceProperties
  • ApiSecrets → ApiResourceSecrets
  • IdentityClaims → IdentityResourceClaims
  • IdentityProperties → IdentityResourceProperties

And restructures the ApiScopes relationship (scopes become independent, linked via ApiResourceScopes join table).

Do not rely on auto-generated EF migrations for this step — they will drop and recreate tables, losing data. Instead:

  1. Create the migration scaffold:

``bash dotnet ef migrations add Config_v4 -c ConfigurationDbContext -o Migrations/ConfigurationDb ``

  1. Embed a custom delta SQL script that migrates data before dropping old tables:

```sql -- Move data from old tables to new tables INSERT INTO ApiResourceClaims (Id, [Type], ApiResourceId) SELECT Id, [Type], ApiResourceId FROM ApiClaims;

INSERT INTO ApiResourceProperties (Id, [Key], [Value], ApiResourceId) SELECT Id, [Key], [Value], ApiResourceId FROM ApiProperties;

INSERT INTO ApiResourceSecrets (Id, [Description], [Value], [Expiration], [Type], [Created], ApiResourceId) SELECT Id, [Description], [Value], [Expiration], [Type], [Created], ApiResourceId FROM ApiSecrets;

INSERT INTO IdentityResourceClaims (Id, [Type], IdentityResourceId) SELECT Id, [Type], IdentityResourceId FROM IdentityClaims;

INSERT INTO IdentityResourceProperties (Id, [Key], [Value], IdentityResourceId) SELECT Id, [Key], [Value], IdentityResourceId FROM IdentityProperties;

-- Migrate scope-resource relationship to join table INSERT INTO ApiResourceScopes ([Scope], [ApiResourceId]) SELECT [Name], [ApiResourceId] FROM ApiScopes;

-- Remove old foreign key column from ApiScopes -- (handled by EF migration after data is moved) ```

  1. Modify the generated migration to execute the SQL script before the destructive operations.
  1. Apply: dotnet ef database update -c ConfigurationDbContext

Reference implementation: UpgradeSample-IdentityServer4-v3


Stage 2: IdentityServer4 v4.x → Duende IdentityServer v8.x

Step 2.1: Update .NET Target Framework

This is the start of the file. Read the full SKILL.md on GitHub.

Security

  • Security scanPassed, 100 of 100Pattern checks on the skill's files.
  • Model reviewPassed

Quality evaluation

  • Task evaluationNot runNo evaluation yet. Run one in Skill Studio.

Source

Popularity

7-day trend score
0

Not refreshed yet.

Works with

Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.

  • Claude Code
  • Cursor
  • GitHub Copilot
  • Windsurf
  • Codex
  • Gemini CLI
  • Cline
  • Amp
  • Roo Code
  • Goose
  • Continue
  • Kilo Code
  • Junie
  • Trae
  • OpenHands
  • Qwen Code
  • AI Agent
  • Tabnine Chat
  • Sourcegraph Cody
  • Amazon Q
  • Firebase Genkit
  • Sweep
  • Devin
  • Phind
  • Mentat
  • Claude Desktop
  • Aider
  • GPT Pilot
  • Plandex
  • bolt.new
  • v0
  • Replit Agent
  • Anse
  • TypingMind
  • BetterChatGPT
  • LibreChat
  • Warp AI
  • Pieces
  • Fig AI
Embed badge
vskill VERIFIED badge
[![vskill VERIFIED](https://verified-skill.com/api/v1/skills/duendesoftware/duende-skills/identityserver4-migration/badge)](https://verified-skill.com/skills/duendesoftware/duende-skills/identityserver4-migration)

Something wrong with this skill or its page? Tell us.