duendesoftware/duende-skills/identityserver-sessions-providers
Claude Code and agent skill by duendesoftware/duende-skills
- community
Checking that the SKILL.md file is still in the repository.
Guide for configuring server-side sessions, session management and querying, inactivity timeout, dynamic identity providers, and CIBA (Client Initiated Backchannel Authentication) in Duende IdentityServer.
Install
npx vskill@latest install duendesoftware/duende-skills/identityserver-sessions-providersSKILL.md
The same SKILL.md was published earlier as duendesoftware/duende-skills/identityserver-sessions-providers.
IdentityServer Sessions, Dynamic Providers, and CIBA
When to Use This Skill
- Enabling and configuring server-side sessions for authentication state management
- Implementing session querying, revocation, and administrative tooling via
ISessionManagementService - Configuring inactivity timeout across IdentityServer and client applications
- Setting up the Entity Framework Core session store or implementing a custom
IServerSideSessionStore - Adding dynamic identity providers loaded from a database at runtime
- Implementing custom non-OIDC dynamic provider types (Google, SAML, etc.)
- Building a CIBA (Client Initiated Backchannel Authentication) flow
- Understanding edition requirements (Business vs Enterprise) for these features
Docs: https://docs.duendesoftware.com/identityserver/ui/server-side-sessions/
Server-Side Sessions
What Problem Do They Solve?
By default, ASP.NET Core stores all authentication session state in a self-contained cookie. This creates several challenges:
| Problem | Impact | |
|---|---|---|
| Cookie size growth | As clients are tracked, the cookie grows; large cookies can exceed browser limits | |
| No session visibility | Cannot query how many active sessions exist | |
| No administrative revocation | Cannot terminate a session from outside the user's browser | |
| No server-side coordination | Cannot detect inactivity or synchronize session expiration across clients |
Server-side sessions store authentication state on the server, keeping only a session reference in the cookie.
Edition Requirements
Server-side sessions are part of the Duende IdentityServer Business and Enterprise Edition.
Enabling Server-Side Sessions
Important: This call must come after any custom IRefreshTokenService implementation registration. Order matters in the ASP.NET Core service provider.
By default, sessions are stored in-memory. For production, use Entity Framework Core or a custom store.
Using Entity Framework Core Store
The EF Core implementation is included in the operational store and supports the IServerSideSessionStore interface automatically.
Custom Session Store
Implement IServerSideSessionStore and register it:
Data Stored Server-Side
The session stores the serialized ASP.NET Core AuthenticationTicket (all claims + AuthenticationProperties.Items). The data is protected using ASP.NET Core's Data Protection API.
Queryable indices extracted from the session:
| Index | Source | |
|---|---|---|
| Subject ID | sub claim value | |
| Session ID | sid claim value | |
| Display Name | Configurable claim type (e.g., name or email) |
Configure the display name claim. Note: UserDisplayNameClaimType is unset (null) by default due to PII concerns. You must explicitly set it if you want display names stored in the session index:
Session Management with ISessionManagementService
Querying Sessions
Paging Through Results
Performance Note on Querying
When listing sessions, prefer GetSessionsAsync over QuerySessionsAsync. The QuerySessionsAsync method performs a full-text search and may be slower. Use QuerySessionsAsync only when advanced filtering is needed.
Terminating Sessions
Terminate sessions and optionally revoke tokens, consents, and send back-channel logout notifications:
Selective revocation (filtering by SessionId or ClientIds is also supported):
What Gets Cleaned Up
| Flag | Effect | |
|---|---|---|
RemoveServerSideSession (default: true) | Deletes the session record from the store | |
RevokeTokens (default: true) | Revokes refresh tokens and reference access tokens | |
RevokeConsents (default: true) | Removes persisted consent grants | |
SendBackchannelLogoutNotification (default: true) | Sends back-channel logout to clients with BackChannelLogoutUri |
Internally, this uses IServerSideTicketStore, IPersistedGrantStore, and IBackChannelLogoutService.
What Logout Does and Doesn't Clean Up
SignOutAsync removes the IdentityServer cookie (and the server-side session record when enabled). By default it does not sign out of the external IdP, notify clients, or revoke tokens:
| Artifact | Default at logout | How to clean up | |
|---|---|---|---|
| IdentityServer cookie | Removed by SignOutAsync | - | |
| Server-side session record | Removed automatically when enabled | - | |
| External IdP session | Not signed out | External logout flow | |
| Client app sessions | Not cleaned unless notified | Front/back-channel notification | |
| Refresh tokens & reference access tokens | Kept | CoordinateLifetimeWithUserSession on the client, or global Authentication.CoordinateClientLifetimesWithUserSession (a client's own value wins; no server-side sessions required) | |
| JWT access tokens | Never revoked, expire on their own | Keep lifetime short | |
| Consents / other grants | Kept | ISessionManagementService / IPersistedGrantService (coordination does not revoke consents) | |
| BFF session + refresh token | Refresh token revoked by default on BFF logout | - |
When a server-side session expires (no explicit logout), clients with a coordinated lifetime have tokens revoked and get a back-channel logout; other clients are only notified when ExpiredSessionsTriggerBackchannelLogout = true (default false). ISessionManagementService.RemoveSessionsAsync (admin-initiated termination) removes the session, sends back-channel logout, revokes tokens and consents by default; each step can be turned off.
Server-Side Session Custom Metadata
Store per-sign-in metadata (device name, auth method, region) in the AuthenticationTicket's AuthenticationProperties.Items. It stays inside IdentityServer and is NOT issued as claims.
Writing Metadata
With ASP.NET Identity, pass properties to SignInWithClaimsAsync:
If you use PasswordSignInAsync (which does not accept properties), override SignInWithClaimsAsync in a custom SignInManager to inject the metadata.
Reading Metadata
Limitation: custom metadata is not indexed by the built-in store — you cannot filter SessionQuery by it. Query by subject id, session id, or display name first, then inspect the tickets.
Inactivity Timeout
The Challenge
OpenID Connect does not natively provide distributed session management based on user inactivity. Multiple artifacts (cookies, refresh tokens, access tokens) have independent lifetimes controlled by different entities. Coordinating their expiration is non-trivial.
Design: Centralized Session Tracking
Server-side sessions at IdentityServer provide the central record for monitoring user activity:
- Activity signals: As the user's client uses refresh tokens, introspection, or userinfo, these protocol calls extend the server-side session automatically via an internal
ISessionCoordinationService(this is an implementation detail, not a public API for consumers). - Inactivity detection: When no activity occurs within the session timeout, the session expires and cleanup is triggered (back-channel logout, token revocation).
Configuration at IdentityServer
Three features must be enabled:
Note: ExpiredSessionsTriggerBackchannelLogout defaults to false. When a server-side session expires, IdentityServer always revokes refresh/reference tokens and sends a back-channel logout notification to clients with a coordinated token lifetime (CoordinateLifetimeWithUserSession, or the global CoordinateClientLifetimesWithUserSession). Other clients in the session are only notified when you set the flag to true.
Alternatively, enable coordination per-client:
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
- SKILL.md in the repositoryCheckingskills/identityserver-sessions-providers/SKILL.md
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
[](https://verified-skill.com/skills/duendesoftware/duende-skills/identityserver-sessions-providers)