Skip to content

Prevent OpenIdConnectMiddlewareDiagnostics from logging sensitive values - #3850

Merged
iarekk merged 1 commit into
masterfrom
iarekk/redact-openidconnect-diagnostic-logging
Jun 9, 2026
Merged

Prevent OpenIdConnectMiddlewareDiagnostics from logging sensitive values#3850
iarekk merged 1 commit into
masterfrom
iarekk/redact-openidconnect-diagnostic-logging

Conversation

@iarekk

@iarekk iarekk commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Description

The diagnostic is now built by a factory that throws IDW10117 unless IHostEnvironment.IsDevelopment() returns true, so any authentication attempt outside Development fails before the handler can log the message.

Supersedes #3847.

@iarekk
iarekk requested a review from a team as a code owner June 9, 2026 12:15
@iarekk
iarekk force-pushed the iarekk/redact-openidconnect-diagnostic-logging branch from 412468e to 51f0cdb Compare June 9, 2026 12:20
OpenIdConnectMiddlewareDiagnostics logs full protocol messages, including
bearer tokens and PII, at Debug level. The middleware is opt-in via
subscribeToOpenIdConnectMiddlewareDiagnosticsEvents, but the parameter
gives no signal that flipping it in production leaks credentials.

Register a hosted service whenever the caller opts in. On host startup it
resolves IHostEnvironment and throws IDW10117 unless the environment is
Development, aborting deployment before any HTTP request can trigger the
diagnostic. The check fails closed: a missing IHostEnvironment is treated
as non-Development.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@iarekk
iarekk force-pushed the iarekk/redact-openidconnect-diagnostic-logging branch from 51f0cdb to d027f00 Compare June 9, 2026 13:48
@iarekk
iarekk merged commit 536b733 into master Jun 9, 2026
4 checks passed
@iarekk
iarekk deleted the iarekk/redact-openidconnect-diagnostic-logging branch June 9, 2026 14:09
This was referenced Jun 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants