Kitto.Web.Routing.AppFilters
Application-level request filters (Sprint E.1 of the routing refactor). These are the concrete IKXRequestFilter implementations that need the web application / session / response services; they are kept out of the dependency-free Kitto.Web.Routing.Filters unit to avoid a circular uses.
Registered globally (in this unit's initialization) in the order that makes the error handler the OUTERMOST layer:
- TKXErrorHandlerFilter — turns exceptions into a modal error dialog
- TKXJWTAuthFilter — hydrates the session from the JWT cookie
- TKXAuthorizationFilter — session-lost + unauthenticated gate
Both the attribute pipeline (TKXRoutingRoute) and the legacy TKWebApplication.DoHandleRequest run their dispatch through this chain, so the gate and the error handling apply uniformly and are defined once.
TKXJWTAuthFilter class
Hydrates the session from the kx_token cookie (no-op for non-JWT auth).
procedure BeforeInvoke(const AContext: IKXRequestContext);Validates the JWT cookie and hydrates the session from it (no-op otherwise).
procedure AfterInvoke(const AContext: IKXRequestContext);No-op.
function OnException(const AContext: IKXRequestContext;Does not handle exceptions (returns False).
TKXNavigationGuardFilter class
Bounces a top-level browser navigation (no X-KittoX header) aimed at an HTML-fragment endpoint back to the app root, so pasting/typing a /kx/... URL never serves a bare fragment. Navigable endpoints (home, [TKXAnonymous], [TKXNavigable] — e.g. blob downloads) are exempt via AllowDirectNavigation.
procedure BeforeInvoke(const AContext: IKXRequestContext);Redirects a top-level navigation to a fragment endpoint to the app root (sets Handled); passes through SPA requests and navigable endpoints.
procedure AfterInvoke(const AContext: IKXRequestContext);No-op.
function OnException(const AContext: IKXRequestContext;Does not handle exceptions (returns False).
TKXAuthorizationFilter class
Session-lost fatal check + unauthenticated 404 gate, honouring the context AllowSessionLost / AllowUnauthenticated flags computed by the pipeline.
procedure BeforeInvoke(const AContext: IKXRequestContext);Raises on a lost session, and 404s an unauthenticated request to a protected endpoint (sets Handled), honouring the context exemptions.
procedure AfterInvoke(const AContext: IKXRequestContext);No-op.
function OnException(const AContext: IKXRequestContext;Does not handle exceptions (returns False).
TKXErrorHandlerFilter class
Renders any exception escaping the dispatch as a non-fatal modal dialog, keeping the session alive (same behaviour as the old DoHandleRequest except).
procedure BeforeInvoke(const AContext: IKXRequestContext);No-op.
procedure AfterInvoke(const AContext: IKXRequestContext);No-op.
function OnException(const AContext: IKXRequestContext;Renders the exception as a non-fatal modal dialog and returns True (session stays alive).
