agentleFS
Jeff-TianJeff-Tian/agent-skills/skoruba-adminui-on-duende/SKILL.md

skoruba-adminui-on-duende

Skill1 starsChanged 7 months agoMITView on GitHub

Add the Skoruba Duende IdentityServer Admin UI (AdminUI + Admin.Api) to an existing Duende IdentityServer application, running locally first and deploying second. Covers the two-database split (reuse the app's existing IdentityServer DB, add a separate admin DB), one-off bootstrap vs runtime migration/seed gating, wiring the OIDC api resource / api scope / admin UI client into the host IdP, seeding the admin user and administration role, Caddy/TLS + forwarded-header host rewrite so OIDC redirect URIs match, and — most importantly — resolving ASP.NET Identity table-name schema drift (`Users`/`Roles`/`UserClaims`/`UserRoles`/`UserLogins` vs `AspNet*`) and missing newer Duende `Clients` columns through EF migrations (compatibility views + idempotent ALTER) instead of manual SQL. Use when the user mentions "Skoruba", "Skoruba.Duende.IdentityServer.Admin", "Duende admin UI", "IdentityServer admin panel", "add admin UI to IdentityServer", "identity-server-admin-api", "skoruba_identity_admin_api", "relation Users / Roles / UserClaims / UserRoles / UserLogins does not exist", "42P01" from the admin API, "column PushedAuthorizationLifetime does not exist", snake_case vs PascalCase table/column drift, "PendingModelChangesWarning" / "AdminIdentityDbContext has pending changes" from Skoruba's own bootstrap, "invalid_scope" on the admin login, a login that loops back to the login page, a "SameSite=None ... must also set Secure" cookie warning, a `/{culture}/login` 404, or is standing up a management UI in front of Duende IdentityServer.

The file

We split this skill into the rules it gives an agent

1 rule. About 0 are common, 1 is distinctive, and 0 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈1

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    When an admin-API endpoint 500s, do this before writing anything:

    line 128

≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Skoruba AdminUI on Duende IdentityServer

Overview

Skoruba's Duende.IdentityServer.Admin gives you a management UI for an existing Duende IdentityServer instance. It is three cooperating services, not one app:

ServiceRoleTalks to
Admin.ApiREST backend the UI callsyour DBs + your IdP (OIDC/JWT)
Admin (AdminUI)Blazor/MVC front-end (BFF)Admin.Api + your IdP (OIDC login)
your existing IdPissues tokens, owns the dataits own DBs

Core principle: you do not stand up a new IdentityServer. You point Skoruba at your existing Duende IdP and its existing database, add one small admin-only database, and reconcile the schema differences with EF migrations.

This skill is local-run-first. Get it working under Docker Compose against localhost, then port the same wiring to your deployment. Deployment specifics are in references/deployment.md.

When to Use

  • Adding Skoruba AdminUI in front of an existing Duende IdentityServer app.
  • The admin API returns 500 with 42P01: relation "X" does not exist or 42703: column ... does not exist.
  • You need the OIDC client/scope/role wiring to let the admin UI log in.

Skip / adapt: greenfield IdentityServer where you control every table name from day one (drift may not exist), or non-PostgreSQL stores (the compatibility views still apply, dialect differs).

The 6 moving parts (checklist)

Work top-to-bottom. Each links to a reference when it needs detail.

  1. Compose topology — postgres, an admin-DB init one-off, Admin.Api, Admin, and a TLS reverse proxy. See references/docker-compose.md.
  2. Two-database split — reuse existing IdP DB for Configuration / PersistedGrant / Identity; a new *_admin DB for AdminLog / AdminAuditLog / AdminConfiguration / DataProtection. See references/docker-compose.md.
  3. Bootstrap the admin DB WITHOUT Skoruba's auto-migration — Skoruba's startup migration is unreliable (its shipped EF model drifts ahead of its committed migrations → PendingModelChangesWarning on AdminIdentityDbContext, and it tries to migrate the contexts pointed at your real DB). Create the few admin-only tables via explicit SQL in a one-off init, and keep every long-running service on ApplyDatabaseMigrations=false / ApplySeed=false. See references/docker-compose.md.
  4. IdP OIDC wiring — register the skoruba_identity_admin_api api resource + api scope, the admin UI client, and seed the admin user + administration role. See references/idp-wiring.md.
  5. Host rewrite / forwarded headers — the UI sits behind TLS on a fixed host:port; redirect URIs must match exactly, so forward X-Forwarded-Proto/Host and have the IdP honor them. See references/idp-wiring.md.
  6. Schema-drift compatibility migrations — this is where most time is lost. See references/database-compatibility.md.

Interactive login has its own three blockers (login-URL 404 when the IdP's login frontend isn't hosted locally; a redirect loop from a SameSite=None auth cookie dropped over HTTP; a 500 right after auth from an under-seeded admin user). They are covered in references/idp-wiring.md §6.

The schema-drift trap (read this before debugging 500s)

Skoruba's EF models assume default IdentityServer / ASP.NET Identity table names: Users, Roles, UserClaims, UserRoles, UserLogins, and a Clients table with whatever columns Skoruba's Duende version expects.

Two common divergences (often combined):

  • Renamed Identity tables (AspNetUsers, AspNetRoles, …) and/or an older Duende schema (missing newer Clients columns).
  • A snake_case naming convention (EFCore.NamingConventions / UseSnakeCaseNamingConvention): every table and column is snake_case (clients.client_id, users.normalized_user_name), but Skoruba selects PascalCase (Clients.ClientId). This drifts every table across all three contexts at once — expect ~20+ config views, plus persisted-grant and identity views — each projecting snake_col AS "PascalCol".

Each mismatch surfaces one at a time as the admin API hits a new endpoint:

Symptom (admin API log)CauseFix
42P01: relation "Users" does not existtable renamed to AspNetUserscompatibility VIEW via migration
42P01: relation "Roles" / "UserClaims" / "UserRoles" / "UserLogins" does not existsame, for that tablecompatibility VIEW via migration
42703: column c."PushedAuthorizationLifetime" does not existolder Duende Clients schemaidempotent ALTER TABLE ADD COLUMN IF NOT EXISTS via migration
400 "Persisted Grant for this subject id ... doesn't exist"data absence, not driftnone — user simply has no grants

Non-negotiable rule: persist every schema change through an EF migration committed to source, never hand-run psql. Manual SQL works on your laptop and then the deployed DB 500s. This is the single most important lesson.

Full patterns, exact SQL, and the build→ef→psql validation loop are in references/database-compatibility.md.

Fast diagnostic loop

When an admin-API endpoint 500s, do this before writing anything:

# 1. read the real Postgres error from the admin API container logs
docker compose logs --tail=50 skoruba-admin-api

# 2. confirm the drift directly — is the relation missing, and does the
#    AspNet* equivalent exist?
docker compose exec -T postgres psql -U postgres -d <idp_db> -c \
  "SELECT to_regclass('\"Users\"'), to_regclass('\"AspNetUsers\"');"

42P01 / 42703 → schema drift → add a migration. 400 ... doesn't exist in a JSON validation body → data absence, not a bug.

Validation (definition of done, local)

  1. dotnet build the migrations project succeeds.
  2. dotnet ef migrations list --context <Context> shows your new migration.
  3. dotnet ef migrations script <prev> <new> --context <Context> emits the expected DDL.
  4. dotnet ef database update <new> --context <Context> applies it.
  5. psql confirms the view/column exists and a representative query runs.
  6. The failing admin-UI page now loads (or returns an empty list, not a 500).

Repeat per endpoint until the UI is clean. Then move the same migrations and env wiring into the deployment path (references/deployment.md).

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.