OIDC: warn once at startup that suspension cannot end live chat sessions without BackchannelLogoutUri

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
Heimdall 2026-11-11 12:23:06 +00:00
commit d91d4a3da6
3 changed files with 62 additions and 1 deletions

View file

@ -103,6 +103,10 @@ to 15 minutes; a 400 (token refused) or 404 (unknown provider ULID) is a configu
and retried at the 15 minute cap. Nothing is revoked until MAS answers 2xx. A restart loses the backoff and nothing
else: the authorizations table is the queue, so a later-set URI also catches up on earlier demotions.
Without `BackchannelLogoutUri` none of this runs: suspension stops new sign-ins and token refresh (the authorize, token and userinfo
endpoints refuse a suspended account) but does not end a chat session that is already live, and the issuer logs one warning at
startup saying so. The other lever is MAS admin deactivation of the user (ops, not built here).
Tradeoff: delivery latency is up to one tick, and a member demoted and re-promoted inside one tick keeps their sessions.
MAS verified at v1.28.0 (`crates/handlers/src/upstream_oauth2/backchannel_logout.rs`): the token is checked like an

View file

@ -14,10 +14,17 @@ public sealed class OidcClientSeeder(
IServiceScopeFactory scopeFactory,
OidcIssuerOptions options,
OidcKeyMaterial material,
IOptions<OpenIddictServerOptions> serverOptions) : IHostedService
IOptions<OpenIddictServerOptions> serverOptions,
ILogger<OidcClientSeeder> logger) : IHostedService
{
public async Task StartAsync(CancellationToken cancellationToken)
{
if (string.IsNullOrWhiteSpace(options.Clients.Mas.BackchannelLogoutUri))
{
logger.LogWarning(
"Bifrost:Oidc:Clients:Mas:BackchannelLogoutUri is not set: suspending an account stops new sign-ins and token refresh but does not end its existing chat sessions.");
}
// Reading the server options now runs their configuration, so a bad issuer stops startup rather than the first request.
_ = serverOptions.Value;

View file

@ -0,0 +1,50 @@
using Bifrost.Web.Tests.Support;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
namespace Bifrost.Web.Tests;
/// <summary>Without a back-channel logout URL suspension cannot end live chat sessions, and the host says so once at startup.</summary>
public sealed class OidcLogoutReachWarningTests
{
private const string Marker = "does not end its existing chat sessions";
private static int Warnings(Microsoft.AspNetCore.Mvc.Testing.WebApplicationFactory<Program> factory, CapturingLoggerProvider logs)
{
_ = factory.Services; // starts the host and its hosted services
return logs.Lines.Count(x => x.Contains(Marker));
}
private static Microsoft.AspNetCore.Mvc.Testing.WebApplicationFactory<Program> WithLogs(Microsoft.AspNetCore.Mvc.Testing.WebApplicationFactory<Program> factory, CapturingLoggerProvider logs) =>
factory.WithWebHostBuilder(b => b.ConfigureServices(s => s.AddLogging(l => l.AddProvider(logs))));
[Fact]
public void OIDC_configured_without_the_logout_url_warns_exactly_once()
{
var logs = new CapturingLoggerProvider();
using var plain = new OidcWebApplicationFactory();
using var factory = WithLogs(plain, logs);
Assert.Equal(1, Warnings(factory, logs));
}
[Fact]
public void OIDC_with_the_logout_url_does_not_warn()
{
var logs = new CapturingLoggerProvider();
using var plain = new OidcLogoutFactory();
using var factory = WithLogs(plain, logs);
Assert.Equal(0, Warnings(factory, logs));
}
[Fact]
public void OIDC_unconfigured_does_not_warn()
{
var logs = new CapturingLoggerProvider();
using var plain = new TestWebApplicationFactory();
using var factory = WithLogs(plain, logs);
Assert.Equal(0, Warnings(factory, logs));
}
}