Skip to content

feat(aspnetcore): warn at startup when the API is mapped without auth (rec #2) - #227

Merged
thiagoluga merged 1 commit into
masterfrom
feat/auth-startup-warning
Jul 30, 2026
Merged

feat(aspnetcore): warn at startup when the API is mapped without auth (rec #2)#227
thiagoluga merged 1 commit into
masterfrom
feat/auth-startup-warning

Conversation

@thiagoluga

Copy link
Copy Markdown
Owner

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 without RequireAuthorization exposes the report-management surface (trigger runs, POST /reports, POST /sources storing 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

MapNeoReports logs a single Warning at mapping time only when RequireAuthorization was not set and no IAuthenticationSchemeProvider is registered (the host called neither AddAuthentication nor RequireAuthorization). It names the prefix and says the management API is reachable unauthenticated and to configure auth before exposing it beyond a trusted network.

  • Default behaviour unchanged (still no imposed auth) → non-breaking.
  • Stays quiet whenever the host has authentication configured, so it's not noise for correctly-secured deployments.

Tests

Three cases: warns with no auth; silent with AddAuthentication; silent with RequireAuthorization=true. (A capturing ILoggerProvider asserts the presence/absence of the warning.)

Verification

  • dotnet build --no-incremental — 0 warnings, 0 errors.
  • AspNetCore integration suite 147/147 (144 existing + 3 new; the existing tests map without auth and now emit the warning, which is harmless — none assert its absence).
  • dotnet format clean.

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).

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.
@sonarqubecloud

Copy link
Copy Markdown

@sonarqubecloud

Copy link
Copy Markdown

@thiagoluga
thiagoluga merged commit c9b2d40 into master Jul 30, 2026
5 checks passed
@thiagoluga
thiagoluga deleted the feat/auth-startup-warning branch July 30, 2026 13:45
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.

1 participant