Repository navigation
Description
Note: LogoutAll already changes UAuthState on remote chain.
Summary
UltimateAuth should provide a unified mechanism for detecting remote session termination and automatically transitioning affected clients into a reauthentication-required state.
When a session is terminated from another device, browser, or administrative context, the affected client must recognize that its authentication state is no longer valid.
This behavior must be consistent across supported client profiles, including Blazor Server, Blazor WebAssembly, MAUI, and other .NET clients.
The implementation should remain transport-agnostic and must not depend on Blazor Server circuits or SignalR.
Problem
Currently, remote logout invalidates the corresponding server-side authentication session, but the affected client may continue displaying its previously authenticated UI until another validation or authentication operation occurs.
Although protected server operations correctly reject invalid sessions, the client-side authentication state may remain stale.
UltimateAuth should distinguish between:
- Server-side invalidation: The session is no longer authorized.
- Client-side detection: The client recognizes the invalidation.
- Application reaction: The client clears authentication state and requests reauthentication.
- Real-time notification: The server proactively informs affected clients of session changes.
Phase 1 — Unified Session Invalidation Detection
Priority: High
Implement consistent invalidation detection through existing client request, validation, and session coordinator infrastructure.
Requirements
- Detect invalid or remotely terminated sessions during authenticated requests.
- Distinguish authentication invalidation from ordinary authorization failures.
- Avoid treating unrelated
403 Forbiddenresponses as expired sessions. - Integrate detection with the existing
UAuthStateManagerand session coordinator. - Clear or invalidate stale client authentication state.
- Trigger a unified reauthentication-required event.
- Ensure the event is not repeatedly emitted for the same invalidation.
- Preserve existing local logout and session revocation behavior.
- Support all applicable authentication modes and client profiles.
Expected behavior
When a client discovers that its session has been remotely terminated:
- The failed validation or authenticated request identifies the invalid session.
- UltimateAuth updates its authentication state.
- A reauthentication-required event is emitted.
- The application reacts using its configured client-specific behavior.
For Blazor applications, this may involve navigating to /login.
For MAUI or other clients, the application may instead display a login screen or execute a custom authentication recovery flow.
Navigation must remain an application-level concern, not a requirement of the core authentication engine.
Phase 2 — Proactive Cross-Client Session Events
Priority: Medium — after Phase 1
Introduce optional server-to-client event delivery for session lifecycle changes.
Requirements
- Publish events when sessions or chains are remotely terminated, logged out, or revoked.
- Identify affected authentication contexts without exposing sensitive session credentials.
- Deliver notifications to eligible connected clients.
- Provide a transport-independent event abstraction.
- Allow different delivery mechanisms, such as SignalR, WebSockets, push notifications, or custom transports.
- Keep transport integrations optional.
- Support multi-instance server deployments through an appropriate event distribution mechanism.
- Handle duplicate, delayed, missed, and out-of-order notifications safely.
- Trigger session revalidation when an invalidation notification is received.
- Reuse the Phase 1 authentication state transition and reauthentication-required event.
- Ensure disconnected clients still detect invalidation through Phase 1.
Security considerations
Notifications must not be treated as authorization decisions.
The server remains authoritative for authentication and session validity.
Clients should validate the relevant session state before applying security-sensitive transitions.
Event subscriptions must be authenticated and scoped to the appropriate user, session, or chain.
Architecture
The proposed flow should remain independent of UI frameworks and communication transports.
UltimateAuth Server
|
| Session / Chain Invalidation
v
Session Lifecycle Event
|
v
Optional Event Delivery Transport
|
v
UltimateAuth Client
|
v
Session Validation / Invalidation Detection
|
v
UAuthStateManager
|
v
Reauthentication Required
|
v
Application-Specific Reaction
Phase 1 must work independently of Phase 2.
Phase 2 should improve responsiveness without introducing a dependency on persistent connections.
Acceptance Criteria
Phase 1
- Remote logout is detected on the affected client's next authenticated request or validation.
- Invalid sessions transition the client into a reauthentication-required state.
- Ordinary permission denials do not trigger reauthentication.
- Existing authentication state events remain consistent.
- No repeated reauthentication event storms occur.
- Behavior is covered by unit and integration tests across relevant authentication modes.
- Client applications can handle reauthentication without framework-specific dependencies.
Phase 2
- Server-side session lifecycle events can be published.
- An optional transport can deliver invalidation notifications.
- Connected clients can react without waiting for their next manual operation.
- Notifications trigger authoritative validation rather than bypassing it.
- Missed notifications are recovered through normal validation.
- Cross-client and multi-instance scenarios are covered by integration tests.
- Documentation includes transport integration examples for different client profiles.
Scope
Target release: v0.2.0
Phase 1: Core client reliability and authentication state consistency.
Phase 2: Optional real-time session lifecycle notifications.
The implementation should extend existing UltimateAuth abstractions rather than introduce a Blazor-specific session management system.
Activity