@@ -404,6 +404,36 @@ public IResponse CreateAuthenticationPrompt(IRequest request, IEndpointContext i
404404 return null ;
405405 }
406406
407+ /// <summary>
408+ /// Creates a forbidden response page for the specified request when the authenticated
409+ /// user lacks the required permissions to access the requested resource.
410+ /// </summary>
411+ /// <param name="request">The request for which access was denied. Cannot be null.</param>
412+ /// <param name="initiator">The endpoint that the user attempted to access.</param>
413+ /// <param name="identity">The authenticated identity that lacks sufficient permissions.</param>
414+ /// <returns>
415+ /// A response representing the forbidden page if a registered identity provider can handle the
416+ /// forbidden scenario; otherwise, <c>null</c>.
417+ /// </returns>
418+ public IResponse CreateForbiddenResponse ( IRequest request , IEndpointContext initiator , IIdentity identity )
419+ {
420+ if ( _identityProviders . TryGetValue ( initiator ? . ApplicationContext , out var list ) )
421+ {
422+ foreach ( var provider in list )
423+ {
424+ var response = provider . CreateForbiddenResponse ( request , initiator , identity ) ;
425+
426+ if ( response is not null )
427+ {
428+ // the first provider that can show a forbidden page wins
429+ return response ;
430+ }
431+ }
432+ }
433+
434+ return null ;
435+ }
436+
407437 /// <summary>
408438 /// Attempts to authenticate the specified request within the given application context.
409439 /// </summary>
@@ -454,6 +484,15 @@ public bool Login(IRequest request, IIdentity identity)
454484 /// <param name="request">The request.</param>
455485 public void Logout ( IRequest request )
456486 {
487+ // notify all registered identity providers so they can clear their own state
488+ foreach ( var list in _identityProviders . Values )
489+ {
490+ foreach ( var provider in list )
491+ {
492+ provider . Logout ( request ) ;
493+ }
494+ }
495+
457496 var session = _componentHub . SessionManager . GetSession ( request ) ;
458497 session . RemoveProperty < SessionPropertyAuthentification > ( ) ;
459498 }
0 commit comments