@@ -36,11 +36,12 @@ public static AuthenticationBuilder AddMrWhoAuthentication(
3636 // Decide default require-https if not set
3737 bool requireHttps = options . RequireHttpsMetadata ?? options . Authority . StartsWith ( "https://" , StringComparison . OrdinalIgnoreCase ) ;
3838
39- // Configure authentication with a local cookie scheme and OIDC challenge scheme
39+ // Configure authentication with a local cookie scheme and OIDC challenge + sign-out scheme
4040 var builder = services . AddAuthentication ( auth =>
4141 {
4242 auth . DefaultScheme = cookieScheme ;
4343 auth . DefaultChallengeScheme = oidcScheme ;
44+ auth . DefaultSignOutScheme = oidcScheme ; // ensure SignOutAsync() triggers OIDC end-session
4445 } )
4546 . AddCookie ( cookieScheme , cookie =>
4647 {
@@ -69,6 +70,10 @@ public static AuthenticationBuilder AddMrWhoAuthentication(
6970 oidc . CallbackPath = options . CallbackPath ;
7071 oidc . SignedOutCallbackPath = options . SignedOutCallbackPath ;
7172 oidc . RemoteSignOutPath = options . RemoteSignOutPath ;
73+ if ( ! string . IsNullOrWhiteSpace ( options . SignedOutRedirectUri ) )
74+ {
75+ oidc . SignedOutRedirectUri = options . SignedOutRedirectUri ;
76+ }
7277
7378 // Ensure Identity.Name and roles resolve using standard OIDC claims by default
7479 oidc . TokenValidationParameters = new TokenValidationParameters
@@ -147,6 +152,13 @@ public static AuthenticationBuilder AddMrWhoAuthentication(
147152 }
148153 return Task . CompletedTask ;
149154 } ,
155+ OnRedirectToIdentityProviderForSignOut = ctx =>
156+ {
157+ var logger = ctx . HttpContext . RequestServices . GetRequiredService < ILoggerFactory > ( )
158+ . CreateLogger ( "MrWho.ClientAuth.OIDC" ) ;
159+ logger . LogInformation ( "Initiating OIDC end-session for client_id={ClientId}. IdTokenHint? {HasHint}" , ctx . Options . ClientId , ! string . IsNullOrEmpty ( ctx . ProtocolMessage . IdTokenHint ) ) ;
160+ return Task . CompletedTask ;
161+ } ,
150162 OnTokenResponseReceived = ctx =>
151163 {
152164 var logger = ctx . HttpContext . RequestServices . GetRequiredService < ILoggerFactory > ( )
@@ -162,7 +174,6 @@ public static AuthenticationBuilder AddMrWhoAuthentication(
162174 var identity = ctx . Principal ? . Identities ? . FirstOrDefault ( ) ;
163175 if ( identity != null )
164176 {
165- // If there's no "name" claim, try to synthesize one from preferred_username, email, then sub
166177 bool hasName = identity . HasClaim ( c => c . Type == "name" ) ;
167178 if ( ! hasName )
168179 {
0 commit comments