duendesoftware/duende-skills/identityserver-duende-storage

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.

Duende Storage (preview) persistence provider for IdentityServer: AddStorage with SQL Server/PostgreSQL/Oracle/SQLite, AddConfigurationStorage/AddOperationalStorage, multiple storage instances, configuration admin APIs (IClientAdmin etc.), data extension schemas, schema migration/CLI, purge options, sharing with User Management, and migrating from Entity Framework Core.

Install

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

SKILL.md

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

Duende Storage (Preview)

When to Use This Skill

  • Choosing Duende Storage vs Entity Framework Core vs in-memory vs custom stores
  • Registering AddStorage(...), AddConfigurationStorage(), AddOperationalStorage()
  • Creating/updating clients, scopes, resources and dynamic providers through admin service APIs
  • Adding schema-validated custom properties (data extension schemas) to clients/resources/providers
  • Routing configuration / operational / User Management data to separate databases (storage instances)
  • Deploying/migrating the Duende Storage schema (including the Duende CLI)
  • Planning a migration from EF Core stores

Core Principles

  • Preview: packages (--prerelease), APIs, schemas and behavior may change before GA. Introduced with IdentityServer 8.1 previews.
  • Opt-in, does not replace EF Core. The EF Core provider (classic tables) stays fully supported. Adopt Duende Storage only for what it adds: supported admin APIs, schema-validated custom properties, consistent querying + optimistic concurrency across databases, storage pools (for Spaces), shared persistence across Duende products (e.g. User Management).
  • `AddStorage(...)` only selects a database provider for an instance. It does not store anything by itself. Call AddConfigurationStorage() and AddOperationalStorage() to route data categories to it.
  • Store interfaces (IClientStore, IResourceStore, …) are unchanged: the runtime keeps using the same abstractions.
  • Docs: https://docs.duendesoftware.com/identityserver/data/providers/duende-storage/

Packages

DatabasePackageRegistration
SQL ServerDuende.Storage.MsSqlAddMsSql
PostgreSQLDuende.Storage.PostgreSqlAddPostgreSql
OracleDuende.Storage.OracleAddOracle
SQLiteDuende.Storage.SqliteAddSqlite (AddSqliteInMemory for tests)
bash
dotnet add package Duende.IdentityServer --prerelease
dotnet add package Duende.Storage.Sqlite --prerelease

Registration

csharp
// Program.cs
using Duende.IdentityServer;
using Duende.Storage.Schema;
using Duende.Storage.Sqlite;
builder.Services
.AddIdentityServer()
.AddStorage(storage =>
storage.AddSqlite(options =>
options.ConnectionString =
builder.Configuration.GetConnectionString("IdentityServer")
?? throw new InvalidOperationException("IdentityServer connection string is missing.")))
.AddConfigurationStorage()
.AddOperationalStorage();
var app = builder.Build();
if (app.Environment.IsDevelopment())
{
await app.Services.GetRequiredService<IStorageInstanceSchema>().MigrateAsync(CancellationToken.None);
}
app.UseIdentityServer();
  • AddConfigurationStorage() registers IClientStore, IResourceStore, IIdentityProviderStore, ISamlServiceProviderStore, ICorsPolicyService and the configuration admin APIs.
  • AddOperationalStorage() registers IPersistedGrantStore, IDeviceFlowStore, IPushedAuthorizationRequestStore, IServerSideSessionStore, ISigningKeyStore, ISamlSigninStateStore, ISamlLogoutSessionStore. Still call AddServerSideSessions() separately to enable server-side sessions.
  • Override a single store by registering it after: .AddConfigurationStorage().AddOperationalStorage().AddInMemoryClients(clients) replaces only the client store.
  • SQL Server/PostgreSQL/Oracle use provider-native connection factory / data source registrations (e.g. NpgsqlDataSource, CreateSqlConnection). Keep credentials in a secret store.
Purge

A background purge service runs against every registered storage instance: enabled by default, hourly, BatchSize 100, fuzzed start. Configure StoragePurgeOptions (PurgeInterval, BatchSize, EnablePurge = false when an external job owns cleanup) via builder.Services.Configure<StoragePurgeOptions>(...) before AddOperationalStorage().

Schema Deployment

  • IStorageInstanceSchema.MigrateAsync creates/upgrades the common schema; needs DDL permissions. Fine in development; in production run it as a controlled deployment step so the runtime identity can have narrower permissions. Run only one migration process at a time; after migrating it verifies the DB matches the expected schema.
  • Duende.Cli (preview): dotnet tool install --global Duende.Cli --prerelease, then duende storage migrate --provider mssql --dry-run then without --dry-run. Connection string via DUENDE_STORAGE_CONNECTION_STRING. Providers: mssql, postgresql, sqlite (add --schema for non-default SQL Server/PostgreSQL schema). It downloads/caches Duende.Storage.CliPlugin from NuGet on first use. Oracle is not supported by the CLI: use IStorageInstanceSchema.BuildMigrationScript and have a DBA apply the SQL.
  • Never hide a missing connection string or continue after a migration failure.

Multiple Storage Instances

A data category (configuration, operational, dynamic-schemas, user-management) maps to a storage instance (StorageInstanceId) via IStorageInstanceRouter. Unmapped categories fall back to StorageInstanceId.Default.

MethodCategory
AddConfigurationStorage(...)configuration
AddOperationalStorage(...)operational
AddDynamicSchemas(...)dynamic-schemas
AddUserManagement(...)user-management
csharp
var operationalInstanceId = StorageInstanceId.Create("operational");
builder.Services.AddIdentityServer()
.AddStorage(storage => storage.AddSqlite(o => o.ConnectionString = configConn)) // default instance
.AddConfigurationStorage()
.AddStorage(operationalInstanceId, storage => storage.AddSqlite(o => o.ConnectionString = opsConn))
.AddOperationalStorage(operationalInstanceId);
// Migrate EVERY instance
var factory = app.Services.GetRequiredService<IStorageInstanceSchemaFactory>();
await (await factory.GetStorageInstanceSchema(StorageInstanceId.Default, ct)).MigrateAsync(ct);
await (await factory.GetStorageInstanceSchema(operationalInstanceId, ct)).MigrateAsync(ct);

Rules:

  • Each category maps to one instance per application; mapping it twice to different instances (even from different products) throws InvalidOperationException. Selecting a second provider for the same instance also throws.
  • IStorageInstanceSchema.MigrateAsync only migrates the default instance; use IStorageInstanceSchemaFactory.GetStorageInstanceSchema(id, ct) for named instances. The CLI migrates one connection string at a time, so run it per instance.
  • Outbox processing and purge are registered once and discover every instance automatically.
  • With Spaces, every category resolves to its mapped instance first, then to the space's pool within that instance.

Configuration Admin APIs

AddConfigurationStorage() registers .NET service APIs (not HTTP endpoints). You expose them behind your own authenticated/authorized/audited admin app, CLI or deployment process.

ServiceManages
IClientAdminClients incl. secrets
IApiScopeAdminAPI scopes
IApiResourceAdminAPI resources, scope relationships, API secrets
IIdentityResourceAdminIdentity resources
IIdentityProviderAdminDynamic identity providers
ISamlServiceProviderAdminSAML service providers

Create referenced scopes before the resources/clients that use them.

csharp
using Duende.IdentityServer.Admin;
using Duende.IdentityServer.Admin.Clients;
SaveResult<Guid> result = await clientAdmin.CreateAsync(new CreateClient
{
ClientId = "inventory-worker",
ClientName = "Inventory worker",
AllowedGrantTypes = ["client_credentials"],
AllowedScopes = ["inventory.read"],
ClientSecrets = [ new CreateClientSecret { PlaintextValue = secretFromVault } ]
}, ct);

Other model types: ApiScopeConfiguration (Name, DisplayName), ApiResourceConfiguration (Scopes), IdentityResourceConfiguration (UserClaims), IdentityProviderConfiguration (Scheme, Type, Properties), SamlServiceProviderConfiguration (EntityId, AssertionConsumerServiceUrls of SamlIndexedEndpointConfiguration).

  • Results: create/update/delete return SaveResult<TId> (check IsSuccess; Id, Version, Errors); get returns GetResult<T> (Found, Item, Version).
  • Optimistic concurrency: UpdateAsync(id, item, expectedVersion, ct) requires the version from the preceding get/create. Handle validation, duplicate-name, not-found, version-conflict errors.
  • QueryAsync(QueryRequest.Create<ApiScopeFilter, ApiScopeSortField>(new ApiScopeFilter { Name = "inventory" }), ct) — filters can be contains matches, so compare business identifiers exactly; page via continuation tokens on QueryResult<T>. DeleteAsync(id, ct).
  • Client and API secrets are hashed on write (plaintext in, never returned). Dynamic identity provider properties (e.g. `ClientSecret`) are stored recoverably — not hashed, not field-encrypted. Use encrypted connections, encryption at rest, restricted DB access and protected backups. Do not grant direct read access to the configuration store as a substitute for an authorized admin API — go through the admin API (e.g. IIdentityProviderAdmin) with proper authorization.
  • Register the matching dynamic provider type (AddOidcDynamicProvider() / AddSamlDynamicProvider()) for IdPs you create.

Data Extension Schemas

Add typed custom properties (ExtendedProperties) to clients, API resources, API scopes, identity resources, dynamic IdPs and SAML SPs without DB schema changes.

No SQL migrations are needed when adding or changing extension schemas or attributes: values are stored as generic attribute-value data, so only the schema definition changes. Values that are unknown to the schema or of the wrong type are rejected on write.

Schema storeChoose when
In-memory: AddInMemoryDataExtensionSchemas([...])Schemas live in code, change via deployment, identical on all nodes (safer default)
Storage-backed: AddDynamicSchemas() (ISchemaStore + ISchemaAdmin)Admin system changes schemas at runtime
csharp
var department = new TypedAttributeDefinition<string>(AttributeCode.Create("department"), new ScalarAttributeType(ScalarDataType.String));
var schema = new SchemaConfiguration { SchemaId = SchemaId.Client, AttributeDefinitions = [department] };
builder.Services.AddIdentityServer().AddStorage(...).AddInMemoryDataExtensionSchemas([schema]);
var ext = new AttributeValueCollection();
ext.Set(department, "Sales");
await clientAdmin.CreateAsync(new CreateClient { ClientId = "sales", AllowedGrantTypes = ["client_credentials"], ExtendedProperties = ext }, ct);

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

Security

  • Security scanPassed, 90 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/identityserver-duende-storage/badge)](https://verified-skill.com/skills/duendesoftware/duende-skills/identityserver-duende-storage)

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