feat(aspnetcore): warn at startup when the API is mapped without auth (rec #2) - #227
Merged
Conversation
Auth inherits from the host (ADR D20) and the engine imposes no default — but a host that just calls MapNeoReports() with no authentication configured and without setting RequireAuthorization exposes the whole report-management surface (trigger runs, register reports, store source connection strings, mutate schedules, download artifacts) unauthenticated. That is a valid deployment only behind a trusted boundary. MapNeoReports now logs a single Warning at mapping time when RequireAuthorization is not set AND no IAuthenticationSchemeProvider is registered (i.e. the host called neither AddAuthentication nor RequireAuthorization), so the unauthenticated posture is a deliberate choice rather than a silent default. The default behaviour is unchanged (still no imposed auth), so this is non-breaking; the warning stays quiet whenever the host has any authentication configured. Tests cover all three cases: warns with no auth, silent with AddAuthentication, silent with RequireAuthorization=true.
|
|
This was referenced Jul 30, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Second maintainer-decision recommendation from the audit. Secure-by-default nudge — non-breaking.
Context
The audit flagged that a host calling
MapNeoReports()with no authentication and withoutRequireAuthorizationexposes the report-management surface (trigger runs,POST /reports,POST /sourcesstoring connection strings, schedule mutation, artifact download, the Pro query-SQL generator) unauthenticated. Per D20 that's a deliberate design — "auth inherits from the host" — so I did not flip the default (that would break every existing consumer). Instead, a startup warning makes the unauthenticated posture a conscious choice.The change
MapNeoReportslogs a singleWarningat mapping time only whenRequireAuthorizationwas not set and noIAuthenticationSchemeProvideris registered (the host called neitherAddAuthenticationnorRequireAuthorization). It names the prefix and says the management API is reachable unauthenticated and to configure auth before exposing it beyond a trusted network.Tests
Three cases: warns with no auth; silent with
AddAuthentication; silent withRequireAuthorization=true. (A capturingILoggerProviderasserts the presence/absence of the warning.)Verification
dotnet build --no-incremental— 0 warnings, 0 errors.dotnet formatclean.Rec #1 (streaming XLSX) merged in #226. This is #2. Next: the dead ABI exceptions (#3), retry default (#4), whole-job deadline + async error scrub (#5), and the minor items (#6).