Bundle: redb-identity / src/redb.Identity.Management (src.redb.Identity.Management.txt), 35 files Snapshot: development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages. License: Apache-2.0. Repository: https://github.com/redbase-app/redb-identity Index: https://redbase.app/src/dev-2026-12-06/redb-identity/_index.txt ==== Path: redb-identity/src/redb.Identity.Management/Controllers/AccountChangeEmailController.cs Snapshot: redb-identity, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages. License: Apache-2.0. Repository: https://github.com/redbase-app/redb-identity Page: https://redbase.app/src/dev-2026-12-06/redb-identity/src/redb.Identity.Management/Controllers/AccountChangeEmailController.cs ---- using redb.Identity.Contracts.Routes; using redb.Identity.Contracts.Users; using redb.Route.Controllers.Attributes; namespace redb.Identity.Management.Controllers; /// /// N-4 (Session E, N4-7): anonymous change-of-e-mail \u2014 confirm side. /// POST /api/v1/identity/account/change-email/confirm verifies + atomically /// consumes a confirmation token (issued by POST /me/change-email/request) and /// swaps the user's e-mail to the new address while flipping /// UserProps.EmailVerified=true. The swap is only applied when the user's /// current address still matches the snapshot captured at issue time \u2014 a race /// against another mutation path aborts the commit with a generic /// invalid_token response. /// All failures return invalid_token regardless of cause; granular reason is /// recorded only in audit logs. The route lives under /// /api/v1/identity/account/ so it can be whitelisted alongside /// /api/v1/identity/password/ without exposing other me/* endpoints /// anonymously. /// [Route("account/change-email")] public class AccountChangeEmailController : IdentityControllerBase { /// Verify and consume a change-of-e-mail token. Single-use. [HttpPost("confirm")] public async Task Confirm([FromBody] ChangeEmailConfirmRequest request) { return await Forward(IdentityEndpoints.ChangeEmailConfirm, "confirm", request); } } Path: redb-identity/src/redb.Identity.Management/Controllers/AccountEmailVerifyController.cs Snapshot: redb-identity, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages. License: Apache-2.0. Repository: https://github.com/redbase-app/redb-identity Page: https://redbase.app/src/dev-2026-12-06/redb-identity/src/redb.Identity.Management/Controllers/AccountEmailVerifyController.cs ---- using redb.Identity.Contracts.Routes; using redb.Identity.Contracts.Users; using redb.Route.Controllers.Attributes; namespace redb.Identity.Management.Controllers; /// /// N-4 (Session C, N4-6): anonymous e-mail-verification — confirm side. /// POST /api/v1/identity/account/verify-email/confirm verifies + atomically /// consumes a verification token (issued by POST /me/verify-email/send) and /// flips UserProps.EmailVerified=true when the bound e-mail still matches the /// user's current address (double-change race protection — a stale token never /// vouches for a freshly changed e-mail). Failures return generic /// invalid_token regardless of cause; granular reason is recorded only in /// audit logs to deny attackers a guessing signal. The route lives under /// /api/v1/identity/account/ so it can be whitelisted alongside /// /api/v1/identity/password/ without exposing other me/* endpoints /// anonymously. /// [Route("account/verify-email")] public class AccountEmailVerifyController : IdentityControllerBase { /// Verify and consume an e-mail verification token. Single-use. [HttpPost("confirm")] public async Task Confirm([FromBody] EmailVerifyConfirmRequest request) { return await Forward(IdentityEndpoints.EmailVerifyConfirm, "confirm", request); } } Path: redb-identity/src/redb.Identity.Management/Controllers/AccountRegistrationController.cs Snapshot: redb-identity, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages. License: Apache-2.0. Repository: https://github.com/redbase-app/redb-identity Page: https://redbase.app/src/dev-2026-12-06/redb-identity/src/redb.Identity.Management/Controllers/AccountRegistrationController.cs ---- using redb.Identity.Contracts.Routes; using redb.Identity.Contracts.Users; using redb.Route.Controllers.Attributes; namespace redb.Identity.Management.Controllers; /// /// N-3 (sub-step N3-7): anonymous self-service account-registration HTTP facade. /// /// POST /api/v1/identity/account/register \u2014 create a new account /// using a supplied login + e-mail + password. Returns the new user id on success; /// 409 duplicate on collision; 400 weak_password / validation_error /// on input violations; 404 not_found when the feature gate is off, because the /// route is then not bound at all and this deployment has no such endpoint /// (IdentityClient reads that back as registration_disabled). /// /// /// Requires NO bearer token \u2014 the route lives on the anonymous prefix /// /api/v1/identity/account/. Brute-force / enumeration is mitigated by the per-IP /// throttle processor sitting in front of the direct-vm route (configured in /// IdentityCoreRouteBuilder). /// [Route("account")] public class AccountRegistrationController : IdentityControllerBase { /// /// Register a new account. Unlike the password-recovery endpoints this is NOT an /// anti-enumeration surface \u2014 duplicate login / e-mail must be surfaced so the /// sign-up UI can render an actionable message ("this login is already taken"). /// [HttpPost("register")] public async Task Register([FromBody] RegisterAccountRequest request) { return await Forward(IdentityEndpoints.AccountRegister, "register", request); } } Path: redb-identity/src/redb.Identity.Management/Controllers/ApplicationsController.cs Snapshot: redb-identity, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages. License: Apache-2.0. Repository: https://github.com/redbase-app/redb-identity Page: https://redbase.app/src/dev-2026-12-06/redb-identity/src/redb.Identity.Management/Controllers/ApplicationsController.cs ---- using redb.Identity.Contracts.Applications; using redb.Identity.Contracts.Common; using redb.Identity.Contracts.Routes; using redb.Route.Controllers.Attributes; namespace redb.Identity.Management.Controllers; /// /// REST management API for OAuth 2.0 applications (clients). /// Forwards to direct-vm://identity-manage-apps route. /// [Route("applications")] public class ApplicationsController : IdentityControllerBase { [HttpGet] public async Task List( [FromQuery("offset")] int offset = 0, [FromQuery("count")] int count = 25) { return await Forward(IdentityEndpoints.ManageApps, "list", new ListRequest { Offset = offset, Count = count }); } [HttpGet("{id}")] public async Task Get([FromRoute("id")] string id) { return await Forward(IdentityEndpoints.ManageApps, "read", ParseIdBody(id, stringKey: "clientId")); } [HttpPost] public async Task Create([FromBody] CreateApplicationRequest request) { if (ValidateRequest(request) is { } problem) return problem; return await Forward(IdentityEndpoints.ManageApps, "create", request); } [HttpPut("{id}")] public async Task Update([FromRoute("id")] string id, [FromBody] UpdateApplicationRequest request) { request.Id = id; if (ValidateRequest(request) is { } problem) return problem; return await Forward(IdentityEndpoints.ManageApps, "update", request); } /// /// Rotates the client_secret of a confidential OAuth application. Returns the /// new plaintext secret once in the response body; subsequent reads will not /// expose it (only BCrypt hash is stored). The previous secret is invalidated /// immediately — any client_credentials/refresh flow holding the old value will get /// 401 from the next call onward. /// /// Declared before so that the literal rotate-secret /// segment cannot be swallowed by the {id} template (the id would /// otherwise contain the slash). ControllerRegistry also prefers literal /// over template during resolution; the ordering is belt-and-braces protection. /// /// [HttpPost("{id}/rotate-secret")] public async Task RotateSecret([FromRoute("id")] string id) { return await Forward(IdentityEndpoints.ManageApps, "rotate-secret", ParseIdBody(id)); } [HttpDelete("{id}")] public async Task Delete([FromRoute("id")] string id) { return await Forward(IdentityEndpoints.ManageApps, "delete", ParseIdBody(id, stringKey: "clientId")); } } Path: redb-identity/src/redb.Identity.Management/Controllers/AuditController.cs Snapshot: redb-identity, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages. License: Apache-2.0. Repository: https://github.com/redbase-app/redb-identity Page: https://redbase.app/src/dev-2026-12-06/redb-identity/src/redb.Identity.Management/Controllers/AuditController.cs ---- using redb.Identity.Contracts.Audit; using redb.Identity.Contracts.Routes; using redb.Route.Controllers.Attributes; namespace redb.Identity.Management.Controllers; /// /// H9 (v1.0 DoD): REST admin API for the identity audit log. /// Forwards to direct-vm://identity-manage-audit route. /// [Route("audit")] public class AuditController : IdentityControllerBase { /// /// Queries the audit log. All filters are optional and ANDed together. /// Results are ordered newest-first; page size is clamped to [1..500] server-side. /// [HttpGet] public async Task Query( [FromQuery("eventType")] string? eventType = null, [FromQuery("category")] string? category = null, [FromQuery("userId")] string? userId = null, [FromQuery("login")] string? login = null, [FromQuery("clientId")] string? clientId = null, [FromQuery("from")] string? from = null, [FromQuery("to")] string? to = null, [FromQuery("offset")] int offset = 0, [FromQuery("count")] int count = 50) { var request = new AuditQueryRequest { EventType = eventType, Category = category, UserId = userId, Login = login, ClientId = clientId, From = TryParseIso(from), To = TryParseIso(to), Offset = offset, Count = count }; return await Forward(IdentityEndpoints.ManageAudit, operation: "query", request); } private static DateTimeOffset? TryParseIso(string? s) { if (string.IsNullOrWhiteSpace(s)) return null; return DateTimeOffset.TryParse(s, out var dto) ? dto : null; } } Path: redb-identity/src/redb.Identity.Management/Controllers/ClaimDefinitionsController.cs Snapshot: redb-identity, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages. License: Apache-2.0. Repository: https://github.com/redbase-app/redb-identity Page: https://redbase.app/src/dev-2026-12-06/redb-identity/src/redb.Identity.Management/Controllers/ClaimDefinitionsController.cs ---- using redb.Identity.Contracts.ClaimDefinitions; using redb.Identity.Contracts.Common; using redb.Identity.Contracts.Routes; using redb.Route.Controllers.Attributes; namespace redb.Identity.Management.Controllers; /// /// S2 — admin CRUD for claim definitions /// (). /// [Route("claim-definitions")] public sealed class ClaimDefinitionsController : IdentityControllerBase { [HttpGet] public async Task List( [FromQuery("offset")] int offset = 0, [FromQuery("count")] int count = 50, [FromQuery("scope")] string? scope = null, [FromQuery("applicationId")] string? applicationId = null) { var body = new Dictionary { ["Offset"] = offset, ["Count"] = count, }; if (!string.IsNullOrEmpty(scope)) body["scope"] = scope; if (!string.IsNullOrEmpty(applicationId)) body["applicationId"] = applicationId; return await Forward(IdentityEndpoints.ManageClaimDefinitions, "list", body); } [HttpGet("{id}")] public async Task Get([FromRoute("id")] string id) { return await Forward(IdentityEndpoints.ManageClaimDefinitions, "get", new Dictionary { ["id"] = id }); } [HttpPost] public async Task Create([FromBody] CreateClaimDefinitionRequest request) { if (ValidateRequest(request) is { } problem) return problem; return await Forward(IdentityEndpoints.ManageClaimDefinitions, "create", request); } [HttpPut("{id}")] public async Task Update([FromRoute("id")] string id, [FromBody] UpdateClaimDefinitionRequest request) { if (long.TryParse(id, out var numericId)) request.Id = numericId; if (ValidateRequest(request) is { } problem) return problem; return await Forward(IdentityEndpoints.ManageClaimDefinitions, "update", request); } [HttpDelete("{id}")] public async Task Delete([FromRoute("id")] string id) { return await Forward(IdentityEndpoints.ManageClaimDefinitions, "delete", new Dictionary { ["id"] = id }); } } Path: redb-identity/src/redb.Identity.Management/Controllers/ClaimMappersController.cs Snapshot: redb-identity, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages. License: Apache-2.0. Repository: https://github.com/redbase-app/redb-identity Page: https://redbase.app/src/dev-2026-12-06/redb-identity/src/redb.Identity.Management/Controllers/ClaimMappersController.cs ---- using redb.Identity.Contracts.ClaimMappers; using redb.Identity.Contracts.Common; using redb.Identity.Contracts.Routes; using redb.Route.Controllers.Attributes; namespace redb.Identity.Management.Controllers; /// /// H5 (v1.0 DoD §5): REST admin API for declarative claim mapping rules. /// Forwards to direct-vm://identity-manage-claim-mappers. /// [Route("claim-mappers")] public class ClaimMappersController : IdentityControllerBase { /// /// Lists claim mappers. Optional owner filter: /// "global", "application:{id}", "scope:{id}"; omit for all. /// [HttpGet] public async Task List( [FromQuery("owner")] string? owner = null, [FromQuery("offset")] int offset = 0, [FromQuery("count")] int count = 25) { var body = new Dictionary { ["Offset"] = offset, ["Count"] = count, ["owner"] = owner, }; // ListRequest projection lives in body; processor reads owner from body too. var listReq = new ListRequest { Offset = offset, Count = count }; // Pass owner via body extra-field by sending a dict; processor handles both shapes. var compositeBody = new Dictionary { ["offset"] = listReq.Offset, ["count"] = listReq.Count, ["owner"] = owner, }; return await Forward(IdentityEndpoints.ManageClaimMappers, "list", compositeBody); } [HttpGet("{id}")] public async Task Get([FromRoute("id")] string id) => await Forward(IdentityEndpoints.ManageClaimMappers, "read", ParseIdBody(id)); [HttpPost] public async Task Create([FromBody] CreateClaimMapperRequest request) { if (ValidateRequest(request) is { } problem) return problem; return await Forward(IdentityEndpoints.ManageClaimMappers, "create", request); } [HttpPut("{id}")] public async Task Update([FromRoute("id")] string id, [FromBody] UpdateClaimMapperRequest request) { request.Id = id; if (ValidateRequest(request) is { } problem) return problem; return await Forward(IdentityEndpoints.ManageClaimMappers, "update", request); } [HttpDelete("{id}")] public async Task Delete([FromRoute("id")] string id) => await Forward(IdentityEndpoints.ManageClaimMappers, "delete", ParseIdBody(id)); } Path: redb-identity/src/redb.Identity.Management/Controllers/ClaimScopesController.cs Snapshot: redb-identity, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages. License: Apache-2.0. Repository: https://github.com/redbase-app/redb-identity Page: https://redbase.app/src/dev-2026-12-06/redb-identity/src/redb.Identity.Management/Controllers/ClaimScopesController.cs ---- using redb.Identity.Contracts.ClaimMappers; using redb.Identity.Contracts.Common; using redb.Identity.Contracts.Routes; using redb.Route.Controllers.Attributes; namespace redb.Identity.Management.Controllers; /// /// H5 (v1.0 DoD §5): REST admin API for reusable Client Scopes (mapper bundles) /// AND for Application↔Scope assignments. /// Forwards to direct-vm://identity-manage-claim-scopes. /// [Route("claim-scopes")] public class ClaimScopesController : IdentityControllerBase { [HttpGet] public async Task List( [FromQuery("offset")] int offset = 0, [FromQuery("count")] int count = 25) => await Forward(IdentityEndpoints.ManageClaimScopes, "list", new ListRequest { Offset = offset, Count = count }); [HttpGet("{id}")] public async Task Get([FromRoute("id")] string id) => await Forward(IdentityEndpoints.ManageClaimScopes, "read", ParseIdBody(id, stringKey: "name")); [HttpPost] public async Task Create([FromBody] CreateClaimScopeRequest request) { if (ValidateRequest(request) is { } problem) return problem; return await Forward(IdentityEndpoints.ManageClaimScopes, "create", request); } [HttpPut("{id}")] public async Task Update([FromRoute("id")] string id, [FromBody] UpdateClaimScopeRequest request) { request.Id = id; if (ValidateRequest(request) is { } problem) return problem; return await Forward(IdentityEndpoints.ManageClaimScopes, "update", request); } [HttpDelete("{id}")] public async Task Delete([FromRoute("id")] string id) => await Forward(IdentityEndpoints.ManageClaimScopes, "delete", ParseIdBody(id, stringKey: "name")); // ── Application ↔ Scope assignments ── /// Lists scopes assigned to a given Application. [HttpGet("assignments")] public async Task ListAssignments([FromQuery("applicationId")] string applicationId) { var body = new Dictionary { ["applicationId"] = applicationId }; return await Forward(IdentityEndpoints.ManageClaimScopes, "list-assignments", body); } /// Assigns a scope to an Application (idempotent; returns existing on duplicate). [HttpPost("assignments")] public async Task Assign([FromBody] AssignClaimScopeRequest request) { if (ValidateRequest(request) is { } problem) return problem; return await Forward(IdentityEndpoints.ManageClaimScopes, "assign", request); } /// Removes a scope assignment by composite key. [HttpDelete("assignments")] public async Task Unassign( [FromQuery("applicationId")] string applicationId, [FromQuery("scopeId")] string scopeId) { var body = new Dictionary { ["applicationId"] = applicationId, ["scopeId"] = scopeId, }; return await Forward(IdentityEndpoints.ManageClaimScopes, "unassign", body); } } Path: redb-identity/src/redb.Identity.Management/Controllers/ConsentsController.cs Snapshot: redb-identity, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages. License: Apache-2.0. Repository: https://github.com/redbase-app/redb-identity Page: https://redbase.app/src/dev-2026-12-06/redb-identity/src/redb.Identity.Management/Controllers/ConsentsController.cs ---- using redb.Identity.Contracts.Routes; using redb.Route.Controllers.Attributes; namespace redb.Identity.Management.Controllers; [Route("consents")] public class ConsentsController : IdentityControllerBase { [HttpGet] public async Task ListByUser([FromQuery("userId")] string userId) { return await Forward(IdentityEndpoints.ManageConsents, "list", new Dictionary { ["userId"] = long.TryParse(userId, out var id) ? id : 0 }); } [HttpDelete] public async Task Revoke( [FromQuery("userId")] string userId, [FromQuery("applicationId")] string applicationId) { return await Forward(IdentityEndpoints.ManageConsents, "revoke", new Dictionary { ["userId"] = long.TryParse(userId, out var uid) ? uid : 0, ["applicationId"] = long.TryParse(applicationId, out var aid) ? aid : 0 }); } [HttpDelete("all")] public async Task RevokeAll([FromQuery("userId")] string userId) { return await Forward(IdentityEndpoints.ManageConsents, "revoke-all", new Dictionary { ["userId"] = long.TryParse(userId, out var id) ? id : 0 }); } } Path: redb-identity/src/redb.Identity.Management/Controllers/FederationProvidersController.cs Snapshot: redb-identity, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages. License: Apache-2.0. Repository: https://github.com/redbase-app/redb-identity Page: https://redbase.app/src/dev-2026-12-06/redb-identity/src/redb.Identity.Management/Controllers/FederationProvidersController.cs ---- using redb.Identity.Contracts.Common; using redb.Identity.Contracts.Federation; using redb.Identity.Contracts.Routes; using redb.Route.Controllers.Attributes; namespace redb.Identity.Management.Controllers; /// /// H8 (v1.0 DoD §4 gap (e)): REST admin API for PROPS-stored federation providers. /// Forwards to direct-vm://identity-manage-federation-providers. Client secrets /// are encrypted at rest via DataProtection (purpose /// redb.identity.federation-provider-secret) and never returned in responses. /// [Route("federation-providers")] public class FederationProvidersController : IdentityControllerBase { [HttpGet] public async Task List( [FromQuery("offset")] int offset = 0, [FromQuery("count")] int count = 25) { var listReq = new ListRequest { Offset = offset, Count = count }; return await Forward(IdentityEndpoints.ManageFederationProviders, "list", listReq); } [HttpGet("{id}")] public async Task Get([FromRoute("id")] string id) => await Forward(IdentityEndpoints.ManageFederationProviders, "read", ParseIdBody(id)); [HttpPost] public async Task Create([FromBody] CreateFederationProviderRequest request) { if (ValidateRequest(request) is { } problem) return problem; return await Forward(IdentityEndpoints.ManageFederationProviders, "create", request); } [HttpPut("{id}")] public async Task Update( [FromRoute("id")] string id, [FromBody] UpdateFederationProviderRequest request) { request.Id = id; if (ValidateRequest(request) is { } problem) return problem; return await Forward(IdentityEndpoints.ManageFederationProviders, "update", request); } [HttpDelete("{id}")] public async Task Delete([FromRoute("id")] string id) => await Forward(IdentityEndpoints.ManageFederationProviders, "delete", ParseIdBody(id)); } Path: redb-identity/src/redb.Identity.Management/Controllers/GroupsController.cs Snapshot: redb-identity, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages. License: Apache-2.0. Repository: https://github.com/redbase-app/redb-identity Page: https://redbase.app/src/dev-2026-12-06/redb-identity/src/redb.Identity.Management/Controllers/GroupsController.cs ---- using redb.Identity.Contracts.Groups; using redb.Identity.Contracts.Routes; using redb.Route.Controllers.Attributes; namespace redb.Identity.Management.Controllers; /// /// REST management API for groups/organizations. /// Forwards to direct-vm://identity-manage-groups route. /// [Route("groups")] public class GroupsController : IdentityControllerBase { [HttpGet] public async Task List( [FromQuery("offset")] int offset = 0, [FromQuery("count")] int count = 25) { return await Forward(IdentityEndpoints.ManageGroups, "list", new Dictionary { ["offset"] = offset, ["count"] = count }); } /// /// B.2 — flat paginated search across ALL groups (root + nested), /// optionally filtered by name pattern and groupType. Each row carries a /// member-count badge resolved server-side in a single bulk query. /// [HttpGet("search")] public async Task Search( [FromQuery("query")] string? query = null, [FromQuery("groupType")] string? groupType = null, [FromQuery("offset")] int offset = 0, [FromQuery("count")] int count = 25) { var body = new Dictionary { ["query"] = query, ["groupType"] = groupType, ["offset"] = offset, ["count"] = count }; return await Forward(IdentityEndpoints.ManageGroups, "search", body); } [HttpGet("{id}")] public async Task Get([FromRoute("id")] string id) { return await Forward(IdentityEndpoints.ManageGroups, "read", ParseIdBody(id, numericKey: "groupId", stringKey: "groupId")); } [HttpPost] public async Task Create([FromBody] CreateGroupRequest request) { if (ValidateRequest(request) is { } problem) return problem; return await Forward(IdentityEndpoints.ManageGroups, "create", new Dictionary { ["name"] = request.Name, ["groupType"] = request.GroupType, ["description"] = request.Description, ["parentGroupId"] = request.ParentGroupId }); } [HttpPost("{id}/children")] public async Task CreateChild([FromRoute("id")] string id, [FromBody] CreateGroupRequest request) { if (ValidateRequest(request) is { } problem) return problem; var parentId = long.TryParse(id, out var pid) ? pid : 0L; return await Forward(IdentityEndpoints.ManageGroups, "create-child", new Dictionary { ["parentGroupId"] = parentId, ["name"] = request.Name, ["groupType"] = request.GroupType, ["description"] = request.Description }); } [HttpPut("{id}")] public async Task Update([FromRoute("id")] string id, [FromBody] UpdateGroupRequest request) { if (ValidateRequest(request) is { } problem) return problem; var numericId = long.TryParse(id, out var nid) ? nid : 0L; return await Forward(IdentityEndpoints.ManageGroups, "update", new Dictionary { ["groupId"] = numericId, ["name"] = request.Name, ["groupType"] = request.GroupType, ["description"] = request.Description }); } [HttpDelete("{id}")] public async Task Delete([FromRoute("id")] string id) { return await Forward(IdentityEndpoints.ManageGroups, "delete", ParseIdBody(id, numericKey: "groupId", stringKey: "groupId")); } [HttpPost("{id}/move")] public async Task Move([FromRoute("id")] string id, [FromBody] MoveGroupRequest request) { if (ValidateRequest(request) is { } problem) return problem; var numericId = long.TryParse(id, out var nid) ? nid : 0L; return await Forward(IdentityEndpoints.ManageGroups, "move", new Dictionary { ["groupId"] = numericId, ["newParentGroupId"] = request.NewParentGroupId }); } [HttpGet("{id}/tree")] public async Task Tree([FromRoute("id")] string id) { return await Forward(IdentityEndpoints.ManageGroups, "tree", ParseIdBody(id, numericKey: "groupId", stringKey: "groupId")); } [HttpGet("{id}/path")] public async Task Path([FromRoute("id")] string id) { return await Forward(IdentityEndpoints.ManageGroups, "path", ParseIdBody(id, numericKey: "groupId", stringKey: "groupId")); } [HttpGet("{id}/children")] public async Task Children([FromRoute("id")] string id) { return await Forward(IdentityEndpoints.ManageGroups, "children", ParseIdBody(id, numericKey: "groupId", stringKey: "groupId")); } [HttpGet("{id}/members")] public async Task ListMembers([FromRoute("id")] string id) { return await Forward(IdentityEndpoints.ManageGroups, "list-members", ParseIdBody(id, numericKey: "groupId", stringKey: "groupId")); } [HttpPost("{id}/members")] public async Task AddMember([FromRoute("id")] string id, [FromBody] AddMemberRequest request) { if (ValidateRequest(request) is { } problem) return problem; var numericId = long.TryParse(id, out var nid) ? nid : 0L; return await Forward(IdentityEndpoints.ManageGroups, "add-member", new Dictionary { ["groupId"] = numericId, ["userId"] = request.UserId, ["role"] = request.Role, ["expiresAt"] = request.ExpiresAt }); } [HttpPut("{id}/members/{userId}")] public async Task UpdateMember( [FromRoute("id")] string id, [FromRoute("userId")] string userId, [FromBody] UpdateMemberRequest request) { if (ValidateRequest(request) is { } problem) return problem; return await Forward(IdentityEndpoints.ManageGroups, "update-member", new Dictionary { ["groupId"] = long.TryParse(id, out var gid) ? gid : 0L, ["userId"] = long.TryParse(userId, out var uid) ? uid : 0L, ["role"] = request.Role }); } [HttpDelete("{id}/members/{userId}")] public async Task RemoveMember([FromRoute("id")] string id, [FromRoute("userId")] string userId) { return await Forward(IdentityEndpoints.ManageGroups, "remove-member", new Dictionary { ["groupId"] = long.TryParse(id, out var gid) ? gid : 0, ["userId"] = long.TryParse(userId, out var uid) ? uid : 0 }); } [HttpGet("users/{userId}/groups")] public async Task UserGroups([FromRoute("userId")] string userId) { return await Forward(IdentityEndpoints.ManageGroups, "user-groups", new Dictionary { ["userId"] = long.TryParse(userId, out var uid) ? uid : 0L }); } [HttpGet("{id}/members/{userId}/check")] public async Task IsMember([FromRoute("id")] string id, [FromRoute("userId")] string userId) { return await Forward(IdentityEndpoints.ManageGroups, "is-member", new Dictionary { ["groupId"] = long.TryParse(id, out var gid) ? gid : 0L, ["userId"] = long.TryParse(userId, out var uid) ? uid : 0L }); } } Path: redb-identity/src/redb.Identity.Management/Controllers/IdentityControllerBase.cs Snapshot: redb-identity, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages. License: Apache-2.0. Repository: https://github.com/redbase-app/redb-identity Page: https://redbase.app/src/dev-2026-12-06/redb-identity/src/redb.Identity.Management/Controllers/IdentityControllerBase.cs ---- using Microsoft.Extensions.DependencyInjection; using redb.Identity.Contracts.Common; using redb.Identity.Contracts.Routes; using redb.Identity.Contracts.Validation; using redb.Route.Abstractions; using redb.Route.Controllers; using redb.Route.Components; using redb.Route.Core; namespace redb.Identity.Management.Controllers; /// /// Base controller for Identity management API. Forwards operations to /// direct-vm://identity-manage-* routes via the route context, /// preserving WireTap (event dispatch), retry, and error handling. /// public abstract class IdentityControllerBase : RedbController { /// /// Parses a route ID parameter as either a numeric or string key. /// Numeric IDs are stored under , /// string IDs under . /// protected static object ParseIdBody(string id, string numericKey = "id", string stringKey = "id") => long.TryParse(id, out var numericId) ? new Dictionary { [numericKey] = numericId } : new Dictionary { [stringKey] = id }; /// /// Runs DataAnnotations validation on the request DTO. /// Returns null if valid; otherwise a problem object the controller method /// can return as-is — HttpIdentityProcessors in the HTTP facade /// maps the resulting error = "invalid_request" body to HTTP 400 (E6 / D5). /// protected static object? ValidateRequest(object? request) => RequestValidator.Validate(request); /// /// Sends an operation to a direct-vm://identity-manage-* route, /// preserving route-level cross-cutting concerns (WireTap event dispatch, /// OnException retry, error handling). Returns the response body. /// /// B8: propagates the authenticated caller's subject and granted scopes from the outer /// HTTP exchange (set by ManagementBearerAuthProcessor) into the inner direct-vm /// exchange so that RequireSelfOrAdminProcessor can enforce self-vs-admin /// authorization downstream. /// /// protected async Task Forward(string endpointUri, string operation, object? body = null) { var endpoint = Context.GetEndpoint(endpointUri); if (IsUnbound(endpointUri)) { return new ErrorResponse { Error = "not_found", ErrorDescription = "This deployment does not expose the requested endpoint." }; } var msg = new Message(); msg.Headers["operation"] = operation; if (body is not null) msg.Body = body; // E2 — propagate the Idempotency-Key header (RFC TBD, de-facto standard) from the // outer HTTP exchange into the inner direct-vm exchange so that // IdempotencyProcessor on the route can short-circuit duplicate retries with the // cached response. Also forward the HTTP method for audit metadata. if (Exchange?.In is { } httpIn) { var idemKey = httpIn.GetHeader("Idempotency-Key") ?? httpIn.GetHeader("idempotency-key"); if (!string.IsNullOrEmpty(idemKey)) msg.Headers["Idempotency-Key"] = idemKey; var method = httpIn.GetHeader("redbHttp.Method"); if (!string.IsNullOrEmpty(method)) msg.Headers["redbHttp.Method"] = method; // The caller's address (the transport's, set by the HTTP consumer and its proxy rules, never by the // caller) and User-Agent, so the audit row of the change says where it came from. var remote = httpIn.GetHeader("redbHttp.RemoteAddress"); if (!string.IsNullOrEmpty(remote)) msg.Headers["redbHttp.RemoteAddress"] = remote; var userAgent = httpIn.GetHeader("User-Agent"); if (!string.IsNullOrEmpty(userAgent)) msg.Headers["User-Agent"] = userAgent; } // CreateChild gives the inner exchange its own fresh DI scope inherited from the // outer HTTP exchange's scope factory. Without this the inner Exchange has a null // ServiceProvider and identity processors fall back to the captive root // IRedbService — single connection serialising all concurrent HTTP requests and // surfacing as NpgsqlOperationInProgressException under load. Falls back to a // bare Exchange when the outer Exchange is unavailable (unit tests). var exchange = Exchange?.CreateChild(msg) ?? new Exchange(msg); exchange.Pattern = ExchangePattern.InOut; // Propagate auth context (B8 — RequireSelfOrAdminProcessor depends on these). if (Exchange?.Properties is { } outerProps) { if (outerProps.TryGetValue("identity:management-principal", out var principal)) exchange.Properties["identity:management-principal"] = principal; if (outerProps.TryGetValue("identity:management-subject", out var subject)) exchange.Properties["identity:management-subject"] = subject; if (outerProps.TryGetValue("identity:management-scopes", out var scopes)) exchange.Properties["identity:management-scopes"] = scopes; // H3-SSO: the "sid" claim from the caller's access token (optional — only set // for OIDC session-backed tokens). Required by MeSessionsProcessor's // revoke-current operation. if (outerProps.TryGetValue("identity:management-sid", out var sid)) exchange.Properties["identity:management-sid"] = sid; } var producer = endpoint.CreateProducer(); try { await producer.Process(exchange).ConfigureAwait(false); // E2 — surface the Idempotency-Replayed marker to the HTTP response so callers can // tell when they were served from cache (debugging / metrics). Read from Out ?? In // (Identity convention: business processors answer in In). var idemSrc = exchange.Out ?? exchange.In; if (idemSrc?.Headers.TryGetValue("Idempotency-Replayed", out var replayed) == true && Exchange?.In is { } outHttp) { outHttp.Headers["Idempotency-Replayed"] = replayed; } // B2 — propagate response-meta from the inner direct-vm exchange to the outer HTTP // exchange. Without this, inner OnException handlers (which set e.g. // redbHttp.ResponseCode=503 on inner.Out) are silently discarded and the caller // sees HTTP 200 with an error body — a critical contract violation. PropagateInnerResponse(exchange); return exchange.Out?.Body ?? exchange.In.Body; } finally { // CRITICAL: dispose the inner exchange so its DI scope (and the scoped // NpgsqlConnection within) is released back to the pool. Without this each // SCIM/management HTTP call leaks one connection until MaxPoolSize is hit // and subsequent calls 503 with NpgsqlException("connection pool exhausted"). await exchange.DisposeAsync().ConfigureAwait(false); } } /// /// True when the operation's route is not bound in this deployment. /// /// Several Identity features bind their direct-vm:// routes only when enabled — /// self-service registration, e-mail verification, e-mail change, WebAuthn. The facades mount /// their controllers unconditionally, so a caller reaching a disabled feature used to arrive at /// a producer with nothing to call, and the resulting InvalidOperationException surfaced /// as a generic failure with an unhandled-exception stack trace in the log. What the caller /// asked for simply does not exist here, and that is what they are told: the standard /// not_found error document, which /// turns into 404 on every transport — the answer the client /// SDK already reads as "this feature is off" /// (IdentityClient.RegisterAccountAsync maps 404/403 to registration_disabled). /// /// /// The question is asked of the registry rather than of a feature flag on purpose. The flag /// lives in Core's options; the facade binds its own. Copying it across the boundary would put /// the answer in two places and let them disagree, whereas what is actually bound cannot /// disagree with itself. Non-direct-vm endpoints are left alone — their components /// decide reachability themselves. /// /// private bool IsUnbound(string endpointUri) { // Route's own parser, not a hand-rolled split: BaseKey has to be the exact string the // component keyed the registry with, and that is the parser's business, not this one's. var uri = EndpointUriParser.Parse(endpointUri); if (!string.Equals(uri.Scheme, "direct-vm", StringComparison.OrdinalIgnoreCase)) return false; var registry = Context.GetServiceProvider()?.GetService(); if (registry is null) return false; // The same lookup DirectVmProducer is about to perform. return registry.GetProcessor(uri.BaseKey) is null; } /// /// Mirrors response meta (HTTP status, content type, error envelopes) from the inner /// direct-vm exchange to the outer HTTP exchange's Out message. The kernel /// HttpControllerDispatcher.WriteResult respects pre-set headers, so after this /// call the dispatcher will not clobber the response code/content-type carried by inner /// route handlers (OnException, explicit redirects, 202 Accepted, etc.). /// protected void PropagateInnerResponse(IExchange innerExchange) { if (Exchange is null) return; // Identity pipeline convention: business processors write the response into // exchange.In. PipelineProcessor is // Camel-compliant and never synthesises Out from In, so transport-meta headers // (redbHttp.ResponseCode, Location, ETag, Idempotency-Replayed, ...) may live on // either side. Reading from Out ?? In keeps the whitelist below universal. var innerSrc = innerExchange.Out ?? innerExchange.In; if (innerSrc is null) return; Exchange.Out ??= Exchange.In.Clone(); var outerOut = Exchange.Out; // Headers that describe the HTTP response envelope and must survive across the // facade boundary. This list intentionally covers only transport-level meta; domain // headers (scim.*) are handled by domain-specific Forward overrides where needed. CopyHeader(innerSrc, outerOut, "redbHttp.ResponseCode"); CopyHeader(innerSrc, outerOut, "redbHttp.ResponseContentType"); CopyHeader(innerSrc, outerOut, "Content-Type"); CopyHeader(innerSrc, outerOut, "Location"); CopyHeader(innerSrc, outerOut, "ETag"); CopyHeader(innerSrc, outerOut, "Cache-Control"); CopyHeader(innerSrc, outerOut, "Retry-After"); } private static void CopyHeader(IMessage src, IMessage dst, string key) { if (src.Headers.TryGetValue(key, out var val) && val is not null && !dst.Headers.ContainsKey(key)) { dst.Headers[key] = val; } } } Path: redb-identity/src/redb.Identity.Management/Controllers/ImpersonationController.cs Snapshot: redb-identity, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages. License: Apache-2.0. Repository: https://github.com/redbase-app/redb-identity Page: https://redbase.app/src/dev-2026-12-06/redb-identity/src/redb.Identity.Management/Controllers/ImpersonationController.cs ---- using redb.Identity.Contracts.Routes; using redb.Route.Controllers.Attributes; using redb.Identity.Contracts.Common; namespace redb.Identity.Management.Controllers; /// /// N7-3 — admin impersonation overlay. Forwards to direct-vm://identity-manage-impersonation. /// /// Routes are mounted under /admin/impersonate; the granular scope guard /// (see GranularScopeGuardProcessor) requires the identity:impersonate /// scope (or master identity:manage) on the caller's bearer token. /// /// /// This endpoint does NOT mint a token. It validates the target user exists, then writes /// an audit event recording the admin's sub and the impersonated user id. The BFF /// maintains the actual impersonation state (session cookie) and routes subsequent admin /// calls accordingly. /// /// [Route("admin/impersonate")] public class ImpersonationController : IdentityControllerBase { /// /// Start an impersonation session. userId in the path is the target user id; /// optional reason in the body is persisted in the audit event payload. /// [HttpPost("start/{userId}")] public async Task Start([FromRoute("userId")] string userId, [FromBody] StartImpersonationRequest? body = null) { if (!long.TryParse(userId, out var id) || id <= 0) { return new ErrorResponse { Error = "invalid_request", ErrorDescription = "userId must be a positive integer" }; } return await Forward(IdentityEndpoints.ManageImpersonation, "start", new Dictionary { ["userId"] = id, ["reason"] = body?.Reason }); } /// /// Stop an active impersonation session. userId in the path is the target user id /// the admin was impersonating (used only for the audit record). /// [HttpPost("stop/{userId}")] public async Task Stop([FromRoute("userId")] string userId) { if (!long.TryParse(userId, out var id) || id <= 0) { return new ErrorResponse { Error = "invalid_request", ErrorDescription = "userId must be a positive integer" }; } return await Forward(IdentityEndpoints.ManageImpersonation, "stop", new Dictionary { ["userId"] = id }); } } /// Optional body for POST /admin/impersonate/start/{userId}. public sealed class StartImpersonationRequest { /// Free-form human-readable reason (e.g. "Customer ticket #12345"). Persisted in audit log. public string? Reason { get; set; } } Path: redb-identity/src/redb.Identity.Management/Controllers/MeChangeEmailController.cs Snapshot: redb-identity, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages. License: Apache-2.0. Repository: https://github.com/redbase-app/redb-identity Page: https://redbase.app/src/dev-2026-12-06/redb-identity/src/redb.Identity.Management/Controllers/MeChangeEmailController.cs ---- using redb.Identity.Contracts.Routes; using redb.Identity.Contracts.Users; using redb.Route.Controllers.Attributes; namespace redb.Identity.Management.Controllers; /// /// N-4 (Session E, N4-7): self-service strict change-of-e-mail \u2014 initiate side. /// POST /api/v1/identity/me/change-email/request issues a single-use /// confirmation token and dispatches an e-mail to the requested new address. /// The current address remains the canonical login until the user proves control of /// the new one by clicking the confirm link. Requires Bearer authentication /// (identity:manage or identity:account); the caller id is derived from /// the access-token subject. The confirm half of the flow lives on /// and is anonymous. /// Feature-gated server-side by RedbIdentityOptions.ChangeEmail.Enabled /// (default OFF) \u2014 when disabled the route is not registered and the controller /// surface returns 404 for the in-process route lookup. /// [Route("me/change-email")] public class MeChangeEmailController : IdentityControllerBase { /// /// Issue a fresh change-of-e-mail token bound to the user's current address and the /// requested new address, and deliver the confirmation link via the configured /// IEmailNotificationChannel. Returns { success = true } on success; /// failures (missing channel, non-whitelisted callerConfirmUrl, address taken) /// surface as standard error envelopes. /// [HttpPost("request")] public async Task Request([FromBody] ChangeEmailRequestRequest request) { return await Forward(IdentityEndpoints.MeChangeEmailRequest, "request", request); } } Path: redb-identity/src/redb.Identity.Management/Controllers/MeConsentsController.cs Snapshot: redb-identity, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages. License: Apache-2.0. Repository: https://github.com/redbase-app/redb-identity Page: https://redbase.app/src/dev-2026-12-06/redb-identity/src/redb.Identity.Management/Controllers/MeConsentsController.cs ---- using redb.Identity.Contracts.Consents; using redb.Identity.Contracts.Routes; using redb.Route.Controllers.Attributes; namespace redb.Identity.Management.Controllers; /// /// H3 (v1.0 DoD §6): self-service consent management at /// /api/v1/identity/me/consents. Returns / revokes the caller's own valid /// permanent OAuth/OIDC consent grants. Caller id is taken from the access-token /// subject; admins manage consents for other users via /users/{id}/consents. /// Auth: Bearer with identity:manage or identity:account scope. /// [Route("me/consents")] public class MeConsentsController : IdentityControllerBase { /// List the caller's valid permanent consent grants. [HttpGet] public async Task List() { return await Forward(IdentityEndpoints.MeConsents, "list", new Dictionary()); } /// Revoke the caller's permanent consent grant for a single client. [HttpDelete("{clientId}")] public async Task Revoke([FromRoute("clientId")] string clientId) { return await Forward(IdentityEndpoints.MeConsents, "revoke", new MeRevokeConsentRequest { ClientId = clientId }); } /// /// Grant or extend the caller's permanent consent for an application. Used by native /// consent UIs (e.g. the BFF Razor page) after the user approves a consent_required /// dialog raised by /connect/authorize. Existing valid permanent grants are /// merged (union of scopes) rather than replaced. /// [HttpPost] public async Task Grant([FromBody] GrantMyConsentRequest request) { return await Forward(IdentityEndpoints.MeConsents, "grant", request); } } Path: redb-identity/src/redb.Identity.Management/Controllers/MeController.cs Snapshot: redb-identity, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages. License: Apache-2.0. Repository: https://github.com/redbase-app/redb-identity Page: https://redbase.app/src/dev-2026-12-06/redb-identity/src/redb.Identity.Management/Controllers/MeController.cs ---- using redb.Identity.Contracts.Users; using redb.Identity.Contracts.Routes; using redb.Route.Controllers.Attributes; namespace redb.Identity.Management.Controllers; /// /// H3 (v1.0 DoD §6): self-service profile endpoint at /// /api/v1/identity/me. Caller identity is taken from the access-token subject; /// admin-only fields (Status, EmailVerified, PhoneNumberVerified) /// are intentionally absent from — users cannot /// flip their own verified flags or self-promote the account status. /// Auth: Bearer with identity:manage or identity:account scope. /// [Route("me")] public class MeController : IdentityControllerBase { /// Return the caller's own profile. [HttpGet] public async Task Read() { return await Forward(IdentityEndpoints.MeProfile, "read", null); } /// /// Patch the caller's own profile (display name, email, phone, OIDC extension /// claims). Verified flags and account status are not exposed and remain /// admin-only via UserManagementProcessor. /// [HttpPut] public async Task Update([FromBody] MeUpdateProfileRequest request) { return await Forward(IdentityEndpoints.MeProfile, "update", request); } /// /// Self-service account deletion. Cascade-revokes every session (and the OpenIddict /// authorizations + access/refresh tokens linked to them) and soft-deletes the /// caller's user row + OIDC props. Login STAYS occupied so re-registration with /// the same login is blocked while the soft-deleted row exists (matches the /// protect_system_users trigger contract that _login is immutable). /// Idempotent — repeat calls return { success: true, alreadyAbsent: true }. /// [HttpDelete] public async Task Delete() { return await Forward(IdentityEndpoints.MeProfile, "delete", null); } } Path: redb-identity/src/redb.Identity.Management/Controllers/MeEmailVerifyController.cs Snapshot: redb-identity, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages. License: Apache-2.0. Repository: https://github.com/redbase-app/redb-identity Page: https://redbase.app/src/dev-2026-12-06/redb-identity/src/redb.Identity.Management/Controllers/MeEmailVerifyController.cs ---- using redb.Identity.Contracts.Routes; using redb.Identity.Contracts.Users; using redb.Route.Controllers.Attributes; namespace redb.Identity.Management.Controllers; /// /// N-4 (Session C, N4-6): self-service e-mail verification — initiate side. /// POST /api/v1/identity/me/verify-email/send issues a single-use /// verification token and dispatches an e-mail to the caller's current address. /// Requires Bearer authentication (identity:manage or identity:account); /// the caller id is derived from the access-token subject. The confirm half of the /// flow lives on and is anonymous. /// Feature-gated server-side by RedbIdentityOptions.EmailVerification.Enabled /// (default OFF) — when disabled the route is not registered and the controller /// surface returns 404 for the in-process route lookup. /// [Route("me/verify-email")] public class MeEmailVerifyController : IdentityControllerBase { /// /// Issue a fresh verification token for the caller's e-mail and deliver it via /// the configured IEmailNotificationChannel. Always returns /// { success = true } on success; failures (missing channel, missing e-mail, /// non-whitelisted callerVerifyUrl) surface as standard error envelopes. /// [HttpPost("send")] public async Task Send([FromBody] EmailVerifySendRequest request) { return await Forward(IdentityEndpoints.MeEmailVerifySend, "send", request); } } Path: redb-identity/src/redb.Identity.Management/Controllers/MeFederatedIdentitiesController.cs Snapshot: redb-identity, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages. License: Apache-2.0. Repository: https://github.com/redbase-app/redb-identity Page: https://redbase.app/src/dev-2026-12-06/redb-identity/src/redb.Identity.Management/Controllers/MeFederatedIdentitiesController.cs ---- using Microsoft.Extensions.DependencyInjection; using redb.Identity.Contracts.Federation; using redb.Identity.Contracts.Routes; using redb.Route.Controllers.Attributes; namespace redb.Identity.Management.Controllers; /// /// H8 (DoD §4 gap (b)/(d)): self-service federated identity management at /// /api/v1/identity/me/federated-identities. Lets the authenticated user /// list, link (start a new IdP flow), or unlink one of their federated identities. /// Auth: Bearer with identity:account scope. /// [Route("me/federated-identities")] public class MeFederatedIdentitiesController : IdentityControllerBase { /// List all federated identities linked to the caller's account. [HttpGet] public async Task List() { return await Forward(IdentityEndpoints.MeFederatedIdentities, "list", new Dictionary()); } /// /// Start an OIDC link flow for an additional provider. Returns a redirect URL the /// front-end opens; on success the existing /connect/federation/callback /// detects the embedded LinkUserId and links the new identity instead of logging in. /// [HttpPost("link-challenge")] public async Task LinkChallenge([FromBody] LinkFederatedIdentityRequest request) { if (ValidateRequest(request) is { } problem) return problem; // The HTTP transport's standalone /connect/external-login route injects callbackUrl // automatically; this controller-driven endpoint must compute it explicitly from // the configured issuer + transport path so the generated state encodes the same // callback the IdP will redirect to. // callbackUrl is intentionally not computed here. The server-side processor // (MeFederatedIdentitiesProcessor.LinkChallenge) now falls back to its own // RedbIdentityOptions.Issuer + the standard /connect/federation/callback path // when the dict carries no callbackUrl, which is reliable across DI scopes. return await Forward(IdentityEndpoints.MeFederatedIdentities, "link-challenge", new Dictionary { ["providerId"] = request.ProviderId, ["returnUrl"] = request.ReturnUrl, }); } /// /// Remove a federated identity from the caller's account. Refuses with /// last_credential_method when the link is the user's only sign-in method /// (no other federated identities AND no local password). /// [HttpDelete("{providerId}")] public async Task Unlink([FromRoute("providerId")] string providerId) { return await Forward(IdentityEndpoints.MeFederatedIdentities, "unlink", new Dictionary { ["providerId"] = providerId }); } } Path: redb-identity/src/redb.Identity.Management/Controllers/MeMfaController.cs Snapshot: redb-identity, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages. License: Apache-2.0. Repository: https://github.com/redbase-app/redb-identity Page: https://redbase.app/src/dev-2026-12-06/redb-identity/src/redb.Identity.Management/Controllers/MeMfaController.cs ---- using redb.Identity.Contracts.Routes; using redb.Route.Controllers.Attributes; namespace redb.Identity.Management.Controllers; /// /// H3 (v1.0 DoD §6): self-service MFA management at /// /api/v1/identity/me/mfa/*. Mirrors the admin /mfa/* surface but /// always derives the user id from the access-token subject — under no circumstances /// may a caller setup, confirm, disable, or regenerate codes for someone else. /// Auth: Bearer with identity:manage or identity:account scope. /// [Route("me/mfa")] public class MeMfaController : IdentityControllerBase { /// Return MFA enrollment status for the caller. [HttpGet] public async Task Status() { return await Forward(IdentityEndpoints.MeMfa, "status", new Dictionary()); } /// /// Begin enrolment of an additional MFA method. Body is forwarded as-is /// (method, destination, …); the user id is supplied by the /// processor from the token subject and overrides any value sent by the client. /// [HttpPost("setup")] public async Task Setup([FromBody] Dictionary body) { return await Forward(IdentityEndpoints.MeMfa, "setup", body); } /// Confirm a pending MFA enrolment with the OTP code returned to the user. [HttpPost("confirm")] public async Task Confirm([FromBody] Dictionary body) { return await Forward(IdentityEndpoints.MeMfa, "confirm", body); } /// Disable a single MFA method registered to the caller. [HttpDelete("{method}")] public async Task Disable([FromRoute("method")] string method) { return await Forward(IdentityEndpoints.MeMfa, "disable", new Dictionary { ["method"] = method }); } /// Regenerate the caller's recovery codes (invalidates all previous codes). [HttpPost("recovery-codes")] public async Task RegenerateRecoveryCodes() { return await Forward(IdentityEndpoints.MeMfa, "regenerate-recovery", new Dictionary()); } /// /// MFA backup-codes download UX — regenerates the caller's recovery codes and returns /// them as a text/plain attachment with Content-Disposition: attachment; /// filename=redb-recovery-codes.txt. Mirrors GitHub / Google / Auth0 behaviour: /// downloading is destructive (atomically invalidates the prior batch) since recovery /// codes are stored only as salted hashes server-side and have no other moment of /// existing in plaintext. /// [HttpGet("recovery-codes/download")] public async Task DownloadRecoveryCodes() { return await Forward(IdentityEndpoints.MeMfa, "download-recovery", new Dictionary()); } } Path: redb-identity/src/redb.Identity.Management/Controllers/MePasswordController.cs Snapshot: redb-identity, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages. License: Apache-2.0. Repository: https://github.com/redbase-app/redb-identity Page: https://redbase.app/src/dev-2026-12-06/redb-identity/src/redb.Identity.Management/Controllers/MePasswordController.cs ---- using redb.Identity.Contracts.Users; using redb.Identity.Contracts.Routes; using redb.Route.Controllers.Attributes; namespace redb.Identity.Management.Controllers; /// /// H3 (v1.0 DoD §6): self-service password change at /// /api/v1/identity/me/password. Caller id is taken from the access-token /// subject. Enforces the configured password policy and revokes ALL the caller's /// sessions on success (OWASP Session Management C7) — the user must re-authenticate /// after a successful change. /// Auth: Bearer with identity:manage or identity:account scope. /// [Route("me/password")] public class MePasswordController : IdentityControllerBase { /// Change the caller's own password. Returns { success, sessionsRevoked }. [HttpPut] public async Task Change([FromBody] MeChangePasswordRequest request) { return await Forward(IdentityEndpoints.MePassword, "change", request); } } Path: redb-identity/src/redb.Identity.Management/Controllers/MeSessionsController.cs Snapshot: redb-identity, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages. License: Apache-2.0. Repository: https://github.com/redbase-app/redb-identity Page: https://redbase.app/src/dev-2026-12-06/redb-identity/src/redb.Identity.Management/Controllers/MeSessionsController.cs ---- using redb.Identity.Contracts.Routes; using redb.Route.Controllers.Attributes; namespace redb.Identity.Management.Controllers; /// /// H3-SSO (v1.0 DoD §6 scoped-subset): self-service session API at /// /api/v1/identity/me/sessions. Callers target only their own sessions — /// user id is derived from the authenticated access-token subject, never from the /// request body or query. /// /// Bearer auth is enforced by the shared management API gate /// (ManagementBearerAuthProcessor) which accepts either identity:manage /// or identity:account scope. The downstream MeSessionsProcessor uses /// the sub claim as the caller id; non-numeric subjects are rejected. /// /// [Route("me/sessions")] public class MeSessionsController : IdentityControllerBase { /// List the caller's own active sessions. [HttpGet] public async Task List() { return await Forward(IdentityEndpoints.MeSessions, "list", new Dictionary()); } /// /// Revoke the session bound to the caller's current access token. The session id is /// taken from the sid claim \u2014 no body is required. Returns 400 /// sid_unavailable for tokens without a session binding (e.g. client_credentials). /// Declared before so the literal current segment is /// registered first; ControllerRegistry also prefers literal over /// {sessionId} during resolution, making the ordering a belt-and-braces /// protection rather than a correctness requirement. /// [HttpDelete("current")] public async Task RevokeCurrent() { return await Forward(IdentityEndpoints.MeSessions, "revoke-current", new Dictionary()); } /// /// Revoke all sessions of the caller except the current one (identified by the /// sid claim of the access token). If the token carries no sid all /// sessions are revoked. Declared before so the literal /// others segment is registered first — same defensive ordering as /// . /// [HttpDelete("others")] public async Task RevokeOthers() { return await Forward(IdentityEndpoints.MeSessions, "revoke-others", new Dictionary()); } /// Revoke one of the caller's own sessions by id. 404 on any other session. [HttpDelete("{sessionId}")] public async Task Revoke([FromRoute("sessionId")] string sessionId) { return await Forward(IdentityEndpoints.MeSessions, "revoke", new Dictionary { ["sessionId"] = long.TryParse(sessionId, out var id) ? id : 0 }); } } Path: redb-identity/src/redb.Identity.Management/Controllers/MeWebAuthnController.cs Snapshot: redb-identity, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages. License: Apache-2.0. Repository: https://github.com/redbase-app/redb-identity Page: https://redbase.app/src/dev-2026-12-06/redb-identity/src/redb.Identity.Management/Controllers/MeWebAuthnController.cs ---- using redb.Identity.Contracts.Routes; using redb.Route.Controllers.Attributes; namespace redb.Identity.Management.Controllers; /// /// MFA-3: self-service WebAuthn (FIDO2 / Passkey) management at /// /api/v1/identity/me/webauthn/*. Mirrors the dispatch shape of /// \u2014 the user id is always derived from the access-token /// subject by ; under no circumstances may a caller /// register, rename, or delete credentials for someone else. /// Auth: Bearer with identity:manage or identity:account scope. /// [Route("me/webauthn")] public class MeWebAuthnController : IdentityControllerBase { /// Return WebAuthn enrollment status for the caller. [HttpGet] public async Task Status() { return await Forward(IdentityEndpoints.MeWebAuthn, "status", new Dictionary()); } /// /// Begin a WebAuthn registration ceremony. Body may carry username, /// display_name; returns options (CredentialCreateOptions) + an opaque /// setup_token the client must echo back at register/complete. /// [HttpPost("register/begin")] public async Task RegisterBegin([FromBody] Dictionary body) { return await Forward(IdentityEndpoints.MeWebAuthn, "register-begin", body); } /// Complete a WebAuthn registration with the browser's attestation. [HttpPost("register/complete")] public async Task RegisterComplete([FromBody] Dictionary body) { return await Forward(IdentityEndpoints.MeWebAuthn, "register-complete", body); } /// List the caller's registered WebAuthn credentials. [HttpGet("credentials")] public async Task Credentials() { return await Forward(IdentityEndpoints.MeWebAuthn, "credentials", new Dictionary()); } /// Rename a single credential. [HttpPatch("credentials/{key}")] public async Task Rename( [FromRoute("key")] string key, [FromBody] Dictionary body) { body["key"] = key; return await Forward(IdentityEndpoints.MeWebAuthn, "credential-rename", body); } /// Delete a single credential by key. [HttpDelete("credentials/{key}")] public async Task Delete([FromRoute("key")] string key) { return await Forward(IdentityEndpoints.MeWebAuthn, "credential-delete", new Dictionary { ["key"] = key }); } } Path: redb-identity/src/redb.Identity.Management/Controllers/MfaController.cs Snapshot: redb-identity, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages. License: Apache-2.0. Repository: https://github.com/redbase-app/redb-identity Page: https://redbase.app/src/dev-2026-12-06/redb-identity/src/redb.Identity.Management/Controllers/MfaController.cs ---- using redb.Identity.Contracts.Routes; using redb.Route.Controllers.Attributes; namespace redb.Identity.Management.Controllers; /// /// REST management API for MFA configuration. /// Forwards to direct-vm://identity-manage-mfa route. /// [Route("mfa")] public class MfaController : IdentityControllerBase { [HttpGet("status/{userId}")] public async Task GetStatus([FromRoute("userId")] string userId) { return await Forward(IdentityEndpoints.MfaManage, "status", new Dictionary { ["userId"] = ParseLong(userId) }); } [HttpPost("totp/setup")] public async Task SetupTotp([FromBody] MfaSetupRequest request) { if (ValidateRequest(request) is { } problem) return problem; return await Forward(IdentityEndpoints.MfaManage, "setup", new Dictionary { ["userId"] = request.UserId, ["method"] = "totp", ["username"] = request.Username }); } [HttpPost("totp/confirm")] public async Task ConfirmTotp([FromBody] MfaConfirmRequest request) { if (ValidateRequest(request) is { } problem) return problem; return await Forward(IdentityEndpoints.MfaManage, "confirm", new Dictionary { ["userId"] = request.UserId, ["method"] = "totp", ["code"] = request.Code, ["setup_token"] = request.SetupToken }); } [HttpDelete("totp/{userId}")] public async Task DisableTotp([FromRoute("userId")] string userId) { return await Forward(IdentityEndpoints.MfaManage, "disable", new Dictionary { ["userId"] = ParseLong(userId), ["method"] = "totp" }); } [HttpPost("recovery-codes/regenerate")] public async Task RegenerateRecoveryCodes([FromBody] MfaUserIdRequest request) { if (ValidateRequest(request) is { } problem) return problem; return await Forward(IdentityEndpoints.MfaManage, "regenerate-recovery", new Dictionary { ["userId"] = request.UserId }); } // ── SMS OTP ────────────────────────────────────────────────────────────── [HttpPost("sms/setup")] public async Task SetupSms([FromBody] MfaOtpSetupRequest request) { if (ValidateRequest(request) is { } problem) return problem; return await Forward(IdentityEndpoints.MfaManage, "setup", new Dictionary { ["userId"] = request.UserId, ["method"] = "sms", ["username"] = request.Username, ["destination"] = request.Destination }); } [HttpPost("sms/confirm")] public async Task ConfirmSms([FromBody] MfaOtpConfirmRequest request) { if (ValidateRequest(request) is { } problem) return problem; return await Forward(IdentityEndpoints.MfaManage, "confirm", new Dictionary { ["userId"] = request.UserId, ["method"] = "sms", ["code"] = request.Code, ["mfa_state"] = request.MfaState }); } [HttpDelete("sms/{userId}")] public async Task DisableSms([FromRoute("userId")] string userId) { return await Forward(IdentityEndpoints.MfaManage, "disable", new Dictionary { ["userId"] = ParseLong(userId), ["method"] = "sms" }); } // ── Email OTP ──────────────────────────────────────────────────────────── [HttpPost("email/setup")] public async Task SetupEmail([FromBody] MfaOtpSetupRequest request) { if (ValidateRequest(request) is { } problem) return problem; return await Forward(IdentityEndpoints.MfaManage, "setup", new Dictionary { ["userId"] = request.UserId, ["method"] = "email", ["username"] = request.Username, ["destination"] = request.Destination }); } [HttpPost("email/confirm")] public async Task ConfirmEmail([FromBody] MfaEmailConfirmRequest request) { if (ValidateRequest(request) is { } problem) return problem; return await Forward(IdentityEndpoints.MfaManage, "confirm", new Dictionary { ["userId"] = request.UserId, ["method"] = "email", ["code"] = request.Code, ["mfa_state"] = request.MfaState, ["setup_token"] = request.SetupToken }); } [HttpDelete("email/{userId}")] public async Task DisableEmail([FromRoute("userId")] string userId) { return await Forward(IdentityEndpoints.MfaManage, "disable", new Dictionary { ["userId"] = ParseLong(userId), ["method"] = "email" }); } private static long ParseLong(string value) => long.TryParse(value, out var id) ? id : 0; } Path: redb-identity/src/redb.Identity.Management/Controllers/MfaRequests.cs Snapshot: redb-identity, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages. License: Apache-2.0. Repository: https://github.com/redbase-app/redb-identity Page: https://redbase.app/src/dev-2026-12-06/redb-identity/src/redb.Identity.Management/Controllers/MfaRequests.cs ---- using System.ComponentModel.DataAnnotations; namespace redb.Identity.Management.Controllers; public class MfaSetupRequest { [Range(1, long.MaxValue, ErrorMessage = "userId must be a positive integer.")] public long UserId { get; set; } public string? Username { get; set; } } public class MfaConfirmRequest { [Range(1, long.MaxValue, ErrorMessage = "userId must be a positive integer.")] public long UserId { get; set; } [Required(AllowEmptyStrings = false, ErrorMessage = "code is required.")] public string Code { get; set; } = ""; /// The setup token of the setup answer (setup_token); confirm applies the enrollment it carries. [Required(AllowEmptyStrings = false, ErrorMessage = "setupToken is required.")] public string SetupToken { get; set; } = ""; } public class MfaUserIdRequest { [Range(1, long.MaxValue, ErrorMessage = "userId must be a positive integer.")] public long UserId { get; set; } } /// SMS / Email setup request: caller supplies destination (phone or email). public class MfaOtpSetupRequest { [Range(1, long.MaxValue, ErrorMessage = "userId must be a positive integer.")] public long UserId { get; set; } public string? Username { get; set; } [Required(AllowEmptyStrings = false, ErrorMessage = "destination is required.")] public string Destination { get; set; } = ""; } /// /// Confirm SMS/Email setup. Caller must supply both the user-entered Code and the /// encrypted MfaState returned by the prior /mfa/{method}/challenge call. /// public class MfaOtpConfirmRequest { [Range(1, long.MaxValue, ErrorMessage = "userId must be a positive integer.")] public long UserId { get; set; } [Required(AllowEmptyStrings = false, ErrorMessage = "code is required.")] public string Code { get; set; } = ""; [Required(AllowEmptyStrings = false, ErrorMessage = "mfaState is required.")] public string MfaState { get; set; } = ""; } /// /// Confirm e-mail setup: the code from the e-mail, the MfaState and the SetupToken that the /// e-mail setup call returned. /// public class MfaEmailConfirmRequest { [Range(1, long.MaxValue, ErrorMessage = "userId must be a positive integer.")] public long UserId { get; set; } [Required(AllowEmptyStrings = false, ErrorMessage = "code is required.")] public string Code { get; set; } = ""; [Required(AllowEmptyStrings = false, ErrorMessage = "mfaState is required.")] public string MfaState { get; set; } = ""; [Required(AllowEmptyStrings = false, ErrorMessage = "setupToken is required.")] public string SetupToken { get; set; } = ""; } Path: redb-identity/src/redb.Identity.Management/Controllers/PasswordRecoveryController.cs Snapshot: redb-identity, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages. License: Apache-2.0. Repository: https://github.com/redbase-app/redb-identity Page: https://redbase.app/src/dev-2026-12-06/redb-identity/src/redb.Identity.Management/Controllers/PasswordRecoveryController.cs ---- using redb.Identity.Contracts.Routes; using redb.Identity.Contracts.Users; using redb.Route.Controllers.Attributes; namespace redb.Identity.Management.Controllers; /// /// N-4 (Session C): anonymous password-recovery HTTP facade. /// /// POST /api/v1/identity/password/forgot — initiate recovery. /// Anti-enumeration: always 200 success, even when the e-mail does not match a user /// or the callerResetUrl is not whitelisted on the client. /// POST /api/v1/identity/password/reset — complete recovery by verifying /// the single-use token and setting the new password (revokes all sessions). /// /// Both endpoints require NO bearer token — they are reachable by any unauthenticated /// browser / SDK caller. Brute-force enumeration is mitigated by the per-IP throttle /// processor sitting in front of both direct-vm routes (configured in /// IdentityCoreRouteBuilder). /// [Route("password")] public class PasswordRecoveryController : IdentityControllerBase { /// /// Initiate password recovery for the supplied e-mail. Always returns /// { success = true } regardless of outcome to prevent account enumeration — /// the actual delivery decision is made server-side and recorded in the audit log. /// [HttpPost("forgot")] public async Task Forgot([FromBody] PasswordForgotRequest request) { return await Forward(IdentityEndpoints.PasswordForgot, "forgot", request); } /// /// Complete password recovery: verify + atomically consume the reset token, validate /// the new password against the policy, persist it, and revoke every active session. /// Failures return generic invalid_token regardless of the specific cause /// (bad / expired / consumed token, unknown user) — granular reason lives only in /// audit logs to deny attackers useful guessing signal. /// [HttpPost("reset")] public async Task Reset([FromBody] PasswordResetRequest request) { return await Forward(IdentityEndpoints.PasswordReset, "reset", request); } } Path: redb-identity/src/redb.Identity.Management/Controllers/RevokedSidsController.cs Snapshot: redb-identity, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages. License: Apache-2.0. Repository: https://github.com/redbase-app/redb-identity Page: https://redbase.app/src/dev-2026-12-06/redb-identity/src/redb.Identity.Management/Controllers/RevokedSidsController.cs ---- using redb.Identity.Contracts.Routes; using redb.Identity.Contracts.Sessions; using redb.Route.Controllers.Attributes; namespace redb.Identity.Management.Controllers; /// /// W6-0: Backchannel revoked-sids list. Consumed by Relying Parties (incl. our own /// Identity.Web) to invalidate cookie sessions across replicas where the /// OIDC backchannel logout (/bcl/sink) push alone is not sufficient. /// /// Both endpoints require the identity:manage scope (enforced by the same /// ManagementBearerAuth chain as /sessions). RPs configure their poller /// with a management token issued via client_credentials. /// /// [Route("revoked-sids")] public class RevokedSidsController : IdentityControllerBase { /// /// Publishes a new revocation entry (single sid, single sub, or both). Server clamps /// ExpiresAt to the configured RevokedSidsMaxRetention upper bound. /// [HttpPost] public async Task Add([FromBody] RevokedSidsAddRequest request) { var validation = ValidateRequest(request); if (validation is not null) return validation; return await Forward(IdentityEndpoints.RevokedSids, "add", new Dictionary { ["sid"] = request.Sid, ["sub"] = request.Sub, ["clientId"] = request.ClientId, ["expiresAt"] = request.ExpiresAt, }); } /// /// Incremental poll. is the NextCursor from the /// previous response (ISO-8601 timestamp). Omit on first call \u2014 server returns a /// baseline window covering the full retention period. /// [HttpGet("since")] public async Task Since([FromQuery("cursor")] string? cursor = null) { return await Forward(IdentityEndpoints.RevokedSids, "since", new Dictionary { ["cursor"] = cursor }); } } Path: redb-identity/src/redb.Identity.Management/Controllers/RolesController.cs Snapshot: redb-identity, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages. License: Apache-2.0. Repository: https://github.com/redbase-app/redb-identity Page: https://redbase.app/src/dev-2026-12-06/redb-identity/src/redb.Identity.Management/Controllers/RolesController.cs ---- using redb.Identity.Contracts.Roles; using redb.Identity.Contracts.Routes; using redb.Route.Controllers.Attributes; namespace redb.Identity.Management.Controllers; /// /// B.3 — REST admin API for the Roles registry. /// Forwards to direct-vm://identity-manage-roles. /// [Route("roles")] public class RolesController : IdentityControllerBase { [HttpGet] public async Task Search( [FromQuery("query")] string? query = null, [FromQuery("audience")] string? audience = null, [FromQuery("applicationId")] string? applicationId = null, [FromQuery("offset")] int offset = 0, [FromQuery("count")] int count = 25) { var body = new Dictionary { ["query"] = query, ["audience"] = audience, ["applicationId"] = applicationId, ["offset"] = offset, ["count"] = count }; return await Forward(IdentityEndpoints.ManageRoles, "search", body); } [HttpGet("{id}")] public async Task Get([FromRoute("id")] string id) { return await Forward(IdentityEndpoints.ManageRoles, "get", new Dictionary { ["id"] = id }); } [HttpPost] public async Task Create([FromBody] CreateRoleRequest request) { if (ValidateRequest(request) is { } problem) return problem; return await Forward(IdentityEndpoints.ManageRoles, "create", request); } [HttpPut("{id}")] public async Task Update([FromRoute("id")] string id, [FromBody] UpdateRoleRequest request) { var body = new Dictionary { ["id"] = id, ["displayName"] = request.DisplayName, ["description"] = request.Description, }; return await Forward(IdentityEndpoints.ManageRoles, "update", body); } [HttpDelete("{id}")] public async Task Delete([FromRoute("id")] string id) { return await Forward(IdentityEndpoints.ManageRoles, "delete", new Dictionary { ["id"] = id }); } [HttpGet("{id}/assignees")] public async Task ListAssignees([FromRoute("id")] string id) { return await Forward(IdentityEndpoints.ManageRoles, "list-assignees", new Dictionary { ["roleId"] = id }); } [HttpPost("{id}/users")] public async Task AssignUser([FromRoute("id")] string id, [FromBody] Dictionary body) { var dict = new Dictionary(body) { ["roleId"] = id }; return await Forward(IdentityEndpoints.ManageRoles, "assign-user", dict); } [HttpDelete("{id}/users/{userId}")] public async Task UnassignUser([FromRoute("id")] string id, [FromRoute("userId")] string userId) { return await Forward(IdentityEndpoints.ManageRoles, "unassign-user", new Dictionary { ["roleId"] = id, ["userId"] = userId }); } [HttpPost("{id}/groups")] public async Task AssignGroup([FromRoute("id")] string id, [FromBody] Dictionary body) { var dict = new Dictionary(body) { ["roleId"] = id }; return await Forward(IdentityEndpoints.ManageRoles, "assign-group", dict); } [HttpDelete("{id}/groups/{groupId}")] public async Task UnassignGroup([FromRoute("id")] string id, [FromRoute("groupId")] string groupId) { return await Forward(IdentityEndpoints.ManageRoles, "unassign-group", new Dictionary { ["roleId"] = id, ["groupId"] = groupId }); } [HttpGet("{id}/scopes")] public async Task ListScopes([FromRoute("id")] string id) { return await Forward(IdentityEndpoints.ManageRoles, "list-scopes", new Dictionary { ["roleId"] = id }); } [HttpPost("{id}/scopes")] public async Task AttachScope([FromRoute("id")] string id, [FromBody] Dictionary body) { var dict = new Dictionary(body) { ["roleId"] = id }; return await Forward(IdentityEndpoints.ManageRoles, "attach-scope", dict); } [HttpDelete("{id}/scopes/{scopeId}")] public async Task DetachScope([FromRoute("id")] string id, [FromRoute("scopeId")] string scopeId) { return await Forward(IdentityEndpoints.ManageRoles, "detach-scope", new Dictionary { ["roleId"] = id, ["scopeId"] = scopeId }); } } Path: redb-identity/src/redb.Identity.Management/Controllers/ScopesController.cs Snapshot: redb-identity, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages. License: Apache-2.0. Repository: https://github.com/redbase-app/redb-identity Page: https://redbase.app/src/dev-2026-12-06/redb-identity/src/redb.Identity.Management/Controllers/ScopesController.cs ---- using redb.Identity.Contracts.Common; using redb.Identity.Contracts.Scopes; using redb.Identity.Contracts.Routes; using redb.Route.Controllers.Attributes; namespace redb.Identity.Management.Controllers; /// /// REST management API for OAuth 2.0 scopes. /// Forwards to direct-vm://identity-manage-scopes route. /// [Route("scopes")] public class ScopesController : IdentityControllerBase { [HttpGet] public async Task List( [FromQuery("offset")] int offset = 0, [FromQuery("count")] int count = 25) { return await Forward(IdentityEndpoints.ManageScopes, "list", new ListRequest { Offset = offset, Count = count }); } [HttpGet("{id}")] public async Task Get([FromRoute("id")] string id) { return await Forward(IdentityEndpoints.ManageScopes, "read", ParseIdBody(id, stringKey: "name")); } [HttpPost] public async Task Create([FromBody] CreateScopeRequest request) { if (ValidateRequest(request) is { } problem) return problem; return await Forward(IdentityEndpoints.ManageScopes, "create", request); } [HttpPut("{id}")] public async Task Update([FromRoute("id")] string id, [FromBody] UpdateScopeRequest request) { request.Id = id; if (ValidateRequest(request) is { } problem) return problem; return await Forward(IdentityEndpoints.ManageScopes, "update", request); } [HttpDelete("{id}")] public async Task Delete([FromRoute("id")] string id) { return await Forward(IdentityEndpoints.ManageScopes, "delete", ParseIdBody(id, stringKey: "name")); } } Path: redb-identity/src/redb.Identity.Management/Controllers/SessionsController.cs Snapshot: redb-identity, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages. License: Apache-2.0. Repository: https://github.com/redbase-app/redb-identity Page: https://redbase.app/src/dev-2026-12-06/redb-identity/src/redb.Identity.Management/Controllers/SessionsController.cs ---- using redb.Identity.Contracts.Routes; using redb.Route.Controllers.Attributes; namespace redb.Identity.Management.Controllers; [Route("sessions")] public class SessionsController : IdentityControllerBase { [HttpGet] public async Task List( [FromQuery("userId")] string? userId = null, [FromQuery("offset")] string? offset = null, [FromQuery("count")] string? count = null) { // userId omitted → admin-wide browse of active sessions (WSO2-style // default view, paginated). userId present → targeted per-user list. if (string.IsNullOrEmpty(userId)) { return await Forward(IdentityEndpoints.ManageSessions, "list-all", new Dictionary { ["offset"] = long.TryParse(offset, out var o) ? o : 0, ["count"] = long.TryParse(count, out var c) ? c : 25 }); } return await Forward(IdentityEndpoints.ManageSessions, "list", new Dictionary { ["userId"] = long.TryParse(userId, out var id) ? id : 0 }); } [HttpDelete] public async Task Revoke([FromQuery("sessionId")] string sessionId) { return await Forward(IdentityEndpoints.ManageSessions, "revoke", new Dictionary { ["sessionId"] = long.TryParse(sessionId, out var id) ? id : 0 }); } [HttpDelete("all")] public async Task RevokeAll( [FromQuery("userId")] string userId, [FromQuery("dryRun")] string? dryRun = null) { var body = new Dictionary { ["userId"] = long.TryParse(userId, out var id) ? id : 0 }; if (bool.TryParse(dryRun, out var dr) && dr) body["dryRun"] = true; return await Forward(IdentityEndpoints.ManageSessions, "revoke-all", body); } [HttpPost("logout")] public async Task Logout([FromQuery("userId")] string userId) { return await Forward(IdentityEndpoints.ManageSessions, "logout", new Dictionary { ["userId"] = long.TryParse(userId, out var id) ? id : 0 }); } } Path: redb-identity/src/redb.Identity.Management/Controllers/SigningKeysController.cs Snapshot: redb-identity, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages. License: Apache-2.0. Repository: https://github.com/redbase-app/redb-identity Page: https://redbase.app/src/dev-2026-12-06/redb-identity/src/redb.Identity.Management/Controllers/SigningKeysController.cs ---- using redb.Identity.Contracts.Routes; using redb.Identity.Contracts.SigningKeys; using redb.Route.Controllers.Attributes; namespace redb.Identity.Management.Controllers; /// /// Admin signing-key lifecycle endpoint. Forwards to /// direct-vm://identity-manage-signing-keys. /// /// /// Routes: /// /// GET /signing-keys — list every key row (active + retired, full audit trail). /// POST /signing-keys/rotate — mint a fresh active key, demote previously-active /// keys of the same kind. Body: (omit to rotate the default /// "signing" kind). /// DELETE /signing-keys/{kid} — retire (set NotAfter=now) so the key drops out of /// the live JWKS on the next request and tokens signed under it stop validating. /// /// Gated by identity:applications.manage (or master identity:manage) — signing-key /// rotation is an application-layer concern from a least-privilege standpoint. /// [Route("signing-keys")] public class SigningKeysController : IdentityControllerBase { [HttpGet] public async Task List() { return await Forward(IdentityEndpoints.ManageSigningKeys, "list", null); } [HttpPost("rotate")] public async Task Rotate([FromBody] RotateSigningKeyRequest? request) { return await Forward(IdentityEndpoints.ManageSigningKeys, "rotate", request ?? new RotateSigningKeyRequest()); } [HttpDelete("{kid}")] public async Task Retire([FromRoute("kid")] string kid) { return await Forward(IdentityEndpoints.ManageSigningKeys, "retire", new Dictionary { ["kid"] = kid }); } } Path: redb-identity/src/redb.Identity.Management/Controllers/TokensController.cs Snapshot: redb-identity, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages. License: Apache-2.0. Repository: https://github.com/redbase-app/redb-identity Page: https://redbase.app/src/dev-2026-12-06/redb-identity/src/redb.Identity.Management/Controllers/TokensController.cs ---- using redb.Identity.Contracts.Routes; using redb.Route.Controllers.Attributes; namespace redb.Identity.Management.Controllers; /// /// REST management API for token administration: listing, revoking, pruning. /// Forwards to direct-vm://identity-manage-tokens route. /// [Route("tokens")] public class TokensController : IdentityControllerBase { [HttpGet] public async Task List( [FromQuery("subject")] string? subject = null, [FromQuery("offset")] int offset = 0, [FromQuery("count")] int count = 20) { var body = new Dictionary { ["offset"] = offset, ["count"] = count }; if (subject is not null) body["subject"] = subject; return await Forward(IdentityEndpoints.ManageTokens, "list", body); } [HttpDelete("{id}")] public async Task Revoke([FromRoute("id")] string id) { return await Forward(IdentityEndpoints.ManageTokens, "revoke", ParseIdBody(id, numericKey: "tokenId", stringKey: "tokenId")); } [HttpPost("revoke-by-subject")] public async Task RevokeBySubject([FromBody] Dictionary request) { return await Forward(IdentityEndpoints.ManageTokens, "revoke-by-user", request); } [HttpPost("prune")] public async Task Prune([FromQuery("dryRun")] string? dryRun = null) { var body = new Dictionary(); if (bool.TryParse(dryRun, out var dr) && dr) body["dryRun"] = true; return await Forward(IdentityEndpoints.ManageTokens, "prune", body); } } Path: redb-identity/src/redb.Identity.Management/Controllers/UsersController.cs Snapshot: redb-identity, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages. License: Apache-2.0. Repository: https://github.com/redbase-app/redb-identity Page: https://redbase.app/src/dev-2026-12-06/redb-identity/src/redb.Identity.Management/Controllers/UsersController.cs ---- using redb.Identity.Contracts.Common; using redb.Identity.Contracts.Users; using redb.Identity.Contracts.Routes; using redb.Route.Controllers.Attributes; namespace redb.Identity.Management.Controllers; /// /// REST management API for user accounts. /// Forwards to direct-vm://identity-manage-users route. /// [Route("users")] public class UsersController : IdentityControllerBase { [HttpGet] public async Task List( [FromQuery("offset")] int offset = 0, [FromQuery("count")] int count = 25) { return await Forward(IdentityEndpoints.ManageUsers, "list", new ListRequest { Offset = offset, Count = count }); } [HttpGet("{id}")] public async Task Get([FromRoute("id")] string id) { return await Forward(IdentityEndpoints.ManageUsers, "read", ParseIdBody(id, stringKey: "login")); } [HttpPost] public async Task Create([FromBody] CreateUserRequest request) { if (ValidateRequest(request) is { } problem) return problem; return await Forward(IdentityEndpoints.ManageUsers, "create", request); } [HttpPut("{id}")] public async Task Update([FromRoute("id")] string id, [FromBody] UpdateUserRequest request) { if (long.TryParse(id, out var numericId)) request.Id = numericId; if (ValidateRequest(request) is { } problem) return problem; return await Forward(IdentityEndpoints.ManageUsers, "update", request); } [HttpDelete("{id}")] public async Task Delete([FromRoute("id")] string id) { return await Forward(IdentityEndpoints.ManageUsers, "delete", ParseIdBody(id, stringKey: "login")); } [HttpPost("{id}/change-password")] public async Task ChangePassword([FromRoute("id")] string id, [FromBody] ChangePasswordRequest request) { if (long.TryParse(id, out var numericId)) request.Id = numericId; if (ValidateRequest(request) is { } problem) return problem; return await Forward(IdentityEndpoints.ManageUsers, "change-password", request); } /// /// Admin-side password reset (no OldPassword challenge — admin scope IS the /// authorization). Use for "user forgot the password and the operator /// resets it out-of-band" — the regular user-self change-password flow /// stays as it was. /// [HttpPost("{id}/admin-reset-password")] public async Task AdminResetPassword([FromRoute("id")] string id, [FromBody] AdminResetPasswordRequest request) { if (long.TryParse(id, out var numericId)) request.Id = numericId; if (ValidateRequest(request) is { } problem) return problem; return await Forward(IdentityEndpoints.ManageUsers, "admin-reset-password", request); } [HttpGet("search")] public async Task Search( [FromQuery("query")] string query, [FromQuery("offset")] string? offset = null, [FromQuery("count")] string? count = null) { var body = new Dictionary { ["query"] = query }; if (!string.IsNullOrEmpty(offset)) body["offset"] = offset; if (!string.IsNullOrEmpty(count)) body["count"] = count; return await Forward(IdentityEndpoints.ManageUsers, "search", body); } } Path: redb-identity/src/redb.Identity.Management/Controllers/WebhooksController.cs Snapshot: redb-identity, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages. License: Apache-2.0. Repository: https://github.com/redbase-app/redb-identity Page: https://redbase.app/src/dev-2026-12-06/redb-identity/src/redb.Identity.Management/Controllers/WebhooksController.cs ---- using redb.Identity.Contracts.Common; using redb.Identity.Contracts.Routes; using redb.Identity.Contracts.Webhooks; using redb.Route.Controllers.Attributes; namespace redb.Identity.Management.Controllers; /// /// W1 — REST admin API for outbound webhook subscriptions. /// Forwards to direct-vm://identity-manage-webhooks. /// [Route("webhooks")] public class WebhooksController : IdentityControllerBase { [HttpGet] public async Task List( [FromQuery("offset")] int offset = 0, [FromQuery("count")] int count = 25) { return await Forward(IdentityEndpoints.ManageWebhooks, "list", new ListRequest { Offset = offset, Count = count }); } /// /// The rows of the delivery outbox, webhooks and audit targets alike, newest first, without payload. /// Declared before so that the literal deliveries is not read as an id. /// [HttpGet("deliveries")] public async Task ListDeliveries( [FromQuery("status")] string? status = null, [FromQuery("kind")] string? kind = null, [FromQuery("destination")] string? destination = null, [FromQuery("offset")] int offset = 0, [FromQuery("count")] int count = 25) { return await Forward(IdentityEndpoints.ManageWebhooks, "list-deliveries", new Dictionary { ["status"] = status, ["kind"] = kind, ["destination"] = destination, ["offset"] = offset, ["count"] = count, }); } /// Sends a failed or cancelled delivery again, from its first attempt. [HttpPost("deliveries/{id}/redeliver")] public async Task Redeliver([FromRoute("id")] string id) { return await Forward(IdentityEndpoints.ManageWebhooks, "redeliver", new Dictionary { ["id"] = id }); } [HttpGet("{id}")] public async Task Get([FromRoute("id")] string id) { return await Forward(IdentityEndpoints.ManageWebhooks, "get", new Dictionary { ["id"] = id }); } [HttpPost] public async Task Create([FromBody] CreateWebhookSubscriptionRequest request) { if (ValidateRequest(request) is { } problem) return problem; return await Forward(IdentityEndpoints.ManageWebhooks, "create", request); } [HttpPut("{id}")] public async Task Update( [FromRoute("id")] string id, [FromBody] UpdateWebhookSubscriptionRequest request) { var body = new Dictionary { ["id"] = id, ["displayName"] = request.DisplayName, ["description"] = request.Description, ["url"] = request.Url, ["eventTypeFilter"] = request.EventTypeFilter, ["enabled"] = request.Enabled, ["timeoutMs"] = request.TimeoutMs, ["maxAttempts"] = request.MaxAttempts, ["retryBackoffMs"] = request.RetryBackoffMs, ["extraHeaders"] = request.ExtraHeaders, }; return await Forward(IdentityEndpoints.ManageWebhooks, "update", body); } [HttpDelete("{id}")] public async Task Delete([FromRoute("id")] string id) { return await Forward(IdentityEndpoints.ManageWebhooks, "delete", new Dictionary { ["id"] = id }); } [HttpPost("{id}/rotate-secret")] public async Task RotateSecret([FromRoute("id")] string id) { return await Forward(IdentityEndpoints.ManageWebhooks, "rotate-secret", new Dictionary { ["id"] = id }); } } Path: redb-identity/src/redb.Identity.Management/ManagementErrorCodes.cs Snapshot: redb-identity, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages. License: Apache-2.0. Repository: https://github.com/redbase-app/redb-identity Page: https://redbase.app/src/dev-2026-12-06/redb-identity/src/redb.Identity.Management/ManagementErrorCodes.cs ---- using redb.Identity.Contracts; using redb.Route.Abstractions; namespace redb.Identity.Management; /// /// What a management controller's error document means, as a status code. /// /// The controllers answer failures with a JSON body carrying an error string and no status of their /// own — the transport decides how to say "no". That decision is the same one on every transport, so it /// lives here, in the package that owns the controllers, rather than once per facade. Two copies of this /// table would drift, and the drift that matters is a refusal that arrives as a success. /// /// /// The values are HTTP status codes because that is the vocabulary the rest of the codebase already /// speaks — Core writes verdicts as redbHttp.ResponseCode, and each facade translates from there /// into its own protocol. Nothing here is HTTP-specific beyond the spelling. /// /// public static class ManagementErrorCodes { /// Maps an error value from a controller's error document to a status code. public static int ToStatusCode(string error) => error switch { "not_found" => 404, "duplicate" => 409, // A request that is well formed but cannot be carried out against the current state: the // record already exists, or it is one that must not be removed. "conflict" => 409, "validation_error" => 400, "invalid_request" => 400, "invalid_operation" => 400, "invalid_password" => 400, "weak_password" => 400, "registration_disabled" => 403, // A one-time code (e-mail MFA enrollment) asked for too often, not delivered, or with no channel to send it. "rate_limited" => 429, "delivery_failed" => 502, "no_channel" => 501, "server_error" => 500, _ => 400, }; /// /// The error status already decided for an answer, or null when the table above should decide. /// /// The table exists for one case: a controller that returned an error document, which the dispatcher /// then wrapped in a success status. It must not reach past that. The controller dispatcher writes its /// own verdict when it has one — NotFound 404 for a path no action matches, InternalError /// 500 for an action that threw — and so does Core, through the controller, when it states a code /// (a 503 during an outage, say). None of those strings are in the table, so a mapper that consulted it /// anyway turned every one into 400: a missing route told the caller their request was malformed, and /// an exception in our own code reached the client as the client's fault. /// has always said it the other way round — the status wins where there is one, and the error document /// is read only when nobody stated a code. /// /// /// Read from the two headers the dispatchers write: redbHttp.ResponseCode (the HTTP dispatcher, /// and Core through the controller) and status.code (every controller dispatcher, gRPC /// included, which writes nothing else). /// /// public static int? DecidedErrorStatus(IMessage answer) { ArgumentNullException.ThrowIfNull(answer); foreach (var header in DecidingHeaders) { if (answer.Headers.TryGetValue(header, out var raw) && IdentityVerdict.ParseResponseCode(raw) is >= 400 and var code) { return code; } } return null; } private static readonly string[] DecidingHeaders = ["redbHttp.ResponseCode", "status.code"]; } Path: redb-identity/src/redb.Identity.Management/redb.Identity.Management.csproj Snapshot: redb-identity, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages. License: Apache-2.0. Repository: https://github.com/redbase-app/redb-identity Page: https://redbase.app/src/dev-2026-12-06/redb-identity/src/redb.Identity.Management/redb.Identity.Management.csproj ---- redb.Identity.Management redb.Identity.Management Transport-neutral management and self-service controllers for redb.Identity. Thin adapters over the direct-vm://identity-manage-* routes, shared by every facade.