duendesoftware/duende-skills/identityserver-configuration

Claude Code and agent skill by duendesoftware/duende-skills

Trust tier 2
  • community
LLM review pending
Source check pending

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

Configure Duende IdentityServer including client definitions, API resources, identity resources, scopes, signing credentials, and server-side sessions. Covers client types (M2M, interactive, SPA), grant types, API Scopes vs API Resources vs Identity Resources, secret management, and client authentication methods. Includes both in-memory and database-backed configuration.

Install

npx vskill@latest install duendesoftware/duende-skills/identityserver-configuration

SKILL.md

The same SKILL.md was published earlier as duendesoftware/duende-skills/identityserver-configuration.

Duende IdentityServer Configuration

When to Use This Skill

Use this skill when:

  • Setting up a new Duende IdentityServer host
  • Defining or modifying client registrations
  • Configuring API resources, API scopes, or identity resources
  • Setting up signing key management (automatic or static)
  • Enabling server-side sessions
  • Tuning IdentityServerOptions for production deployments
  • Migrating from IdentityServer4 to Duende IdentityServer

Core Principles

  1. Authorization Code + PKCE by Default — Use GrantTypes.Code for all interactive clients. Never use implicit flow for new applications.
  2. Least Privilege Scopes — Grant clients only the scopes they need. Avoid wildcard or overly broad scope assignments.
  3. Automatic Key Management — Prefer the built-in automatic key rotation over static key configuration in production.
  4. API Resources for Audience Isolation — Use ApiResource to control the aud claim and isolate API boundaries. Use ApiScope for fine-grained permission modeling within those boundaries.
  5. Server-Side Sessions for Enterprise — Enable server-side sessions when you need centralized session management, back-channel logout, or session queries.

Related Skills

  • identityserver-duende-storage — opt-in Duende Storage provider (preview), admin APIs for clients/resources
  • identityserver-spaces — multi-tenancy with isolated data per space (preview)
  • identityserver-stores — EF Core persistence for configuration and operational data
  • oauth-oidc-protocols — Protocol fundamentals that underpin these configuration choices
  • identity-security-hardening — Production hardening of IdentityServer deployments
  • token-management — Client-side token lifecycle with Duende.AccessTokenManagement
  • aspnetcore-authentication — Configuring OIDC authentication in client applications

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


Sub-Documents

Load these sub-documents when the user's question specifically targets one of these areas:

DocumentDescriptionWhen to Load
docs/client-types.mdGrant type selection matrix, client property reference tables, client authentication methods (shared secret, private_key_jwt, mTLS), secret rollover, and CORSprivate_key_jwt, mTLS, secret rotation, refresh token settings, client authentication, CORS origins
docs/resources-scopes.mdResource type decision matrix, identity resources, API scopes (including parameterized scopes), and API resources with audience isolationaud claim, audience isolation, parameterized scopes, IScopeParser, IResourceValidator, EmitStaticAudienceClaim, API Resources, Identity Resources

Pattern 1: Hosting and Basic Setup

Register Duende IdentityServer in Program.cs with AddIdentityServer. All configuration flows from the IdentityServerOptions lambda and the builder's fluent API.

csharp
var builder = WebApplication.CreateBuilder(args);
var idsvrBuilder = builder.Services.AddIdentityServer(options =>
{
// Let the issuer be inferred from the request URL (recommended)
// options.IssuerUri = "https://identity.example.com"; // Only set when behind a reverse proxy
// Enable events for diagnostics
options.Events.RaiseErrorEvents = true;
options.Events.RaiseInformationEvents = true;
options.Events.RaiseFailureEvents = true;
options.Events.RaiseSuccessEvents = true;
})
.AddInMemoryIdentityResources(Config.IdentityResources)
.AddInMemoryApiScopes(Config.ApiScopes)
.AddInMemoryClients(Config.Clients);
var app = builder.Build();
app.UseIdentityServer(); // Includes UseAuthentication()
app.UseAuthorization();
app.Run();
Important: Call UseIdentityServer() instead of UseAuthentication() — it registers both the IdentityServer middleware and the authentication middleware.

Pattern 2: Client Definitions

Clients represent applications that request tokens. The three most common configurations are:

Machine-to-Machine (Client Credentials)

For service-to-service communication with no interactive user:

csharp
new Client
{
ClientId = "service.worker",
ClientName = "Background Worker Service",
AllowedGrantTypes = GrantTypes.ClientCredentials,
ClientSecrets = { new Secret("secret".Sha256()) },
AllowedScopes = { "api1", "api2.read_only" }
}
Interactive Web Application (Authorization Code + PKCE)

For server-rendered web apps that authenticate users and call APIs:

csharp
new Client
{
ClientId = "web.app",
ClientName = "Web Application",
AllowedGrantTypes = GrantTypes.Code,
RequirePkce = true, // Default is true in Duende IS
ClientSecrets = { new Secret("secret".Sha256()) },
// Redirect URIs — must exactly match what the client sends
RedirectUris = { "https://app.example.com/signin-oidc" },
PostLogoutRedirectUris = { "https://app.example.com/signout-callback-oidc" },
FrontChannelLogoutUri = "https://app.example.com/signout-oidc",
// Enable offline access for refresh tokens
AllowOfflineAccess = true,
AllowedScopes =
{
IdentityServerConstants.StandardScopes.OpenId,
IdentityServerConstants.StandardScopes.Profile,
IdentityServerConstants.StandardScopes.Email,
"api1"
}
}
SPA with BFF Pattern

For JavaScript SPAs using the Backend-for-Frontend pattern (see duende-bff skill):

csharp
new Client
{
ClientId = "spa.bff",
ClientName = "SPA with BFF",
AllowedGrantTypes = GrantTypes.Code,
RequirePkce = true,
RequireClientSecret = true, // BFF host holds the secret
ClientSecrets = { new Secret("secret".Sha256()) },
RedirectUris = { "https://app.example.com/signin-oidc" },
PostLogoutRedirectUris = { "https://app.example.com/signout-callback-oidc" },
BackChannelLogoutUri = "https://app.example.com/bff/backchannel",
AllowOfflineAccess = true,
AllowedScopes =
{
IdentityServerConstants.StandardScopes.OpenId,
IdentityServerConstants.StandardScopes.Profile,
"api1"
}
}
Key Client Properties
PropertyPurposeDefault
RequirePkceEnforce PKCE for authorization code flowtrue
AllowOfflineAccessEnable refresh token issuancefalse
AccessTokenLifetimeAccess token duration in seconds3600 (1 hour)
IdentityTokenLifetimeIdentity token duration in seconds300 (5 min)
RefreshTokenUsageReUse or OneTimeOnlyReUse (recommend OneTimeOnly for security)
RefreshTokenExpirationAbsolute or SlidingAbsolute
AbsoluteRefreshTokenLifetimeMax refresh token lifetime in seconds2592000 (30 days)
AllowedCorsOriginsCORS origins for token endpoint callsempty
RequireConsentShow consent screenfalse
CoordinateLifetimeWithUserSessionTie token lifetimes to user sessionfalse
Defining Clients in appsettings.json

For scenarios where client configuration should be externalized:

json
{
"IdentityServer": {
"Clients": [
{
"Enabled": true,
"ClientId": "local-dev",
"ClientName": "Local Development",
"ClientSecrets": [
{
"Value": "<Insert Sha256 hash of the secret encoded as Base64 string>"
}
],
"AllowedGrantTypes": ["client_credentials"],
"AllowedScopes": ["api1"]
}
]
}
}
csharp
// Load clients from configuration
idsvrBuilder.AddInMemoryClients(
configuration.GetSection("IdentityServer:Clients"));

Pattern 3: Identity Resources

Identity resources define groups of claims about users, requested via the scope parameter. They map to claims in the identity token and the userinfo endpoint.

Standard Identity Resources
csharp
public static IEnumerable<IdentityResource> IdentityResources =>
new IdentityResource[]
{
new IdentityResources.OpenId(), // Required — maps to "sub" claim
new IdentityResources.Profile(), // name, family_name, given_name, etc.
new IdentityResources.Email(), // email, email_verified
new IdentityResources.Phone(), // phone_number, phone_number_verified
new IdentityResources.Address(), // address (JSON object)
};
Custom Identity Resources

Define custom identity resources for application-specific user claims:

csharp
// ✅ Custom identity resource for tenant membership
new IdentityResource(
name: "tenant",
displayName: "Your organization info",
userClaims: new[] { "tenant_id", "tenant_name", "tenant_role" })
{
Required = true // Do not show on consent screen as optional
}
Key concept: The openid scope is mandatory for any OpenID Connect request. It tells IdentityServer to return the sub (subject ID) claim.

Pattern 4: API Scopes and API Resources

API scopes and API resources work together to model your API surface area. Understanding the distinction is critical.

API Scopes — Permission Model

An ApiScope represents a permission or capability a client can request:

csharp
public static IEnumerable<ApiScope> ApiScopes =>
new ApiScope[]
{
// Simple scope — just a name
new ApiScope("api1", "Main API"),
// Granular scopes for fine-grained access
new ApiScope("catalog.read", "Read product catalog"),
new ApiScope("catalog.write", "Modify product catalog"),
new ApiScope("orders.manage", "Manage orders"),
// Scope that includes specific user claims in the access token
new ApiScope("invoicing", "Invoicing API")
{
UserClaims = { "department", "cost_center" }
}
};
API Resources — Logical API Boundaries

An ApiResource represents a logical API (typically a deployed service). It groups scopes and controls the aud (audience) claim in access tokens:

csharp
public static IEnumerable<ApiResource> ApiResources =>
new ApiResource[]
{
new ApiResource("catalog-api", "Product Catalog API")
{
Scopes = { "catalog.read", "catalog.write" },
// These claims are included when any scope in this resource is requested
UserClaims = { "role" }
},
new ApiResource("orders-api", "Order Management API")
{
Scopes = { "orders.manage" },
// API-specific secret for reference token introspection
ApiSecrets = { new Secret("orders-secret".Sha256()) }
}
};
When to Use ApiResource vs ApiScope
ScenarioUse ApiScope alone?Add ApiResource?
Single API, simple permissions✅ SufficientOptional
Multiple APIs sharing a scope❌✅ Required for audience isolation
Reference token introspection❌✅ Required for API secrets
Per-API signing algorithms❌✅ Use AllowedTokenSigningAlgorithms
Resource isolation (RFC 8707)❌✅ Required
Resource Isolation

When multiple APIs share scope names, resource isolation prevents a token issued for one API from being used at another:

csharp
// Two separate APIs that both have a "read" scope
new ApiResource("inventory-api") { Scopes = { "read", "write" } },
new ApiResource("reporting-api") { Scopes = { "read" } }

With resource isolation, the client specifies the target resource in the token request using the resource parameter (RFC 8707), and IdentityServer issues a token with a single audience.


Pattern 5: Automatic Key Management

Duende IdentityServer's automatic key management handles signing key creation, rotation, and retirement. This is the recommended approach for production.

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 reviewNot runA model review is scheduled for the next rescan.

Quality evaluation

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

Source

Popularity

Repository stars
9
Repository forks
3
7-day trend score
0

Stars and forks are for the whole GitHub repository, not this skill alone. 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/identityserver-configuration/badge)](https://verified-skill.com/skills/duendesoftware/duende-skills/identityserver-configuration)

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