Skip to content

feat(AspNetCore): increase granularity of startup extensions + OpenApi and Authorization#167

Open
at-bgp wants to merge 20 commits intomainfrom
feat/aspnetcore-extensions-increase-granularity
Open

feat(AspNetCore): increase granularity of startup extensions + OpenApi and Authorization#167
at-bgp wants to merge 20 commits intomainfrom
feat/aspnetcore-extensions-increase-granularity

Conversation

@at-bgp
Copy link
Copy Markdown
Contributor

@at-bgp at-bgp commented Apr 9, 2026

No description provided.

Copilot AI review requested due to automatic review settings April 9, 2026 21:28
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR increases the granularity of the ASP.NET Core startup/service-registration extensions and adds first-class OpenAPI + authorization/authentication helpers (including Entra ID support).

Changes:

  • Split the existing “configure API” setup into smaller, composable service-registration methods (standard MVC + health checks + startup checks).
  • Add OpenAPI extension helpers (basic spec metadata + Entra OAuth2/Bearer scheme wiring).
  • Introduce AuthConfiguration + standard auth registration methods and update startup checks execution to support multiple groups/scopes.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
AspNetCore/AT.Common.AspNetCore.Publish/Extensions/StartupExtensions.cs Refactors API setup into more granular extension methods; adds standard OpenAPI + auth helpers; marks old APIs obsolete.
AspNetCore/AT.Common.AspNetCore.Publish/Extensions/OpenApiExtensions.cs New OpenAPI option transformers for basic metadata + Entra security schemes.
AspNetCore/AT.Common.AspNetCore.Publish/CrossCutting/StartupBackgroundService.cs Updates startup task execution to support multiple StartupChecks registrations with separate scopes.
AspNetCore/AT.Common.AspNetCore.Publish/CrossCutting/AuthConfiguration.cs New configuration record for Entra/JWT settings + disable-auth flag.
AspNetCore/AT.Common.AspNetCore.Publish/AT.Common.AspNetCore.Publish.csproj Adds JwtBearer package dependency to support Entra/JWT auth.
Comments suppressed due to low confidence (3)

AspNetCore/AT.Common.AspNetCore.Publish/Extensions/StartupExtensions.cs:77

  • ConfigureStandardApi() already calls AddStandardHealthChecks(), which registers StartupHealthCheck and adds a health check named "Startup". Re-registering the same singleton and adding the same named health check here risks duplicate health check entries (often causing runtime failures when building the health report dictionary). Remove the duplicate AddSingleton<StartupHealthCheck>()/.AddCheck<StartupHealthCheck>("Startup") from this obsolete method and only call services.AddHealthChecks() for buildHealthChecksAction if needed.
            {
                options.JsonSerializerOptions.Converters.Add(new JsonStringEnumConverter());
                options.JsonSerializerOptions.Converters.Add(new JsonStringUriConverter());
            });

AspNetCore/AT.Common.AspNetCore.Publish/Extensions/StartupExtensions.cs:288

  • The obsolete message says "Use AddBasicOpenApi instead." but this PR introduces AddStandardOpenApi(...) (and no AddBasicOpenApi exists here). Update the obsolete guidance to point to the correct replacement method to avoid broken migration instructions.
            })
            .WithLogging(
                logging =>
                {
                    logging.AddOtlpExporter();

AspNetCore/AT.Common.AspNetCore.Publish/Extensions/StartupExtensions.cs:418

  • This logging code likely won’t compile as-is: IAssemblyInfo is declared in namespace Arbeidstilsynet.Common.AspNetCore (see IAssemblyInfo.cs) and isn’t in scope here, so CreateLogger<IAssemblyInfo>() is unresolved. Also, creating a new LoggerFactory with AddConsole() bypasses the host’s configured logging pipeline and can cause unexpected console output in consuming apps. Prefer logging via DI at runtime (e.g., from a hosted service/startup filter) or remove the log here; if you keep it, use an in-scope category type (e.g., StartupExtensions) and the app’s ILoggerFactory/ILogger<T> instead of creating a new factory. (Also the message references AuthenticationConfiguration, but the type is AuthConfiguration.)
                else if (allowedOrigins != null && allowedOrigins.Length > 0)
                {
                    policy.WithOrigins(allowedOrigins).AllowAnyMethod().AllowAnyHeader();

                    if (allowCredentials)
                    {

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated 6 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@at-bgp at-bgp enabled auto-merge (squash) April 10, 2026 12:10
@sonarqubecloud
Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants