Skip to content

Extend IIdentityProvider with Logout and CreateForbiddenResponse#16

Merged
ReneSchwarzer merged 1 commit intodevelopfrom
copilot/extend-identity-provider-interface
Apr 14, 2026
Merged

Extend IIdentityProvider with Logout and CreateForbiddenResponse#16
ReneSchwarzer merged 1 commit intodevelopfrom
copilot/extend-identity-provider-interface

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 14, 2026

Authenticated users who lack required permissions currently fall through to the login prompt or get no meaningful response. The identity system needs a dedicated forbidden-page mechanism and provider-level logout support.

Interface changes

  • IIdentityProvider.Logout(IRequest) — lets providers clear their own auth state (cookies, tokens, etc.) during logout
  • IIdentityProvider.CreateForbiddenResponse(IRequest, IEndpointContext, IIdentity) — returns a provider-specific forbidden page for authenticated-but-unauthorized users
  • IIdentityManager.CreateForbiddenResponse — same signature, delegates to registered providers

IdentityManager

  • CreateForbiddenResponse follows the existing first-provider-wins delegation pattern used by CreateAuthenticationPrompt
  • Logout now notifies all registered providers before clearing the session property

HttpServer authorization flow

The request pipeline now distinguishes between unauthenticated and unauthorized:

if (!_componentHub.IdentityManager.CheckAccess(identity, searchResult.EndpointContext))
{
    // authenticated but lacks permissions → forbidden page
    if (identity is not null)
    {
        var forbiddenResponse = _componentHub.IdentityManager.CreateForbiddenResponse(
            httpContext.Request, searchResult.EndpointContext, identity);
        if (forbiddenResponse is not null) { /* send and return */ }
    }

    // not authenticated → login prompt (existing behavior)
    var loginResponse = _componentHub.IdentityManager.CreateAuthenticationPrompt(...);
    if (loginResponse is not null) { /* send and return */ }
}

Test

  • MockIdentityProvider updated with no-op implementations of both new methods
  • All 936 existing tests pass

…ate HttpServer forbidden page flow

Agent-Logs-Url: https://github.com/webexpress-framework/WebExpress.WebCore/sessions/42eb3cb9-7106-40a7-a098-76c8b8ae1498

Co-authored-by: ReneSchwarzer <31061438+ReneSchwarzer@users.noreply.github.com>
@ReneSchwarzer ReneSchwarzer marked this pull request as ready for review April 14, 2026 19:10
@ReneSchwarzer ReneSchwarzer merged commit 33446b7 into develop Apr 14, 2026
1 check passed
@ReneSchwarzer ReneSchwarzer deleted the copilot/extend-identity-provider-interface branch April 14, 2026 19:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants