Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to .NET 9.0 #132

Merged
merged 7 commits into from
Jan 8, 2025
Merged

Update to .NET 9.0 #132

merged 7 commits into from
Jan 8, 2025

Conversation

marcominerva
Copy link
Owner

@marcominerva marcominerva commented Jan 8, 2025

This pull request introduces several significant changes, primarily focusing on the integration of Swashbuckle for Simple Authentication, updates to the README documentation, and project configuration adjustments. The key changes are grouped by their themes below:

Workflow and Project Configuration:

  • Added a new GitHub Actions workflow to publish the Swashbuckle package for Simple Authentication on NuGet (.github/workflows/publish_swashbuckle.yml).
  • Updated project files to target .NET 9.0 and added references to the new SimpleAuthentication.Swashbuckle project. [1] [2] [3] [4]
  • Included the new SimpleAuthentication.Swashbuckle project in the solution file (SimpleAuthentication.sln). [1] [2] [3]

Documentation Updates:

  • Updated the README to provide guidance on upgrading from version 2.x to 3.x, specifically moving Swashbuckle support to a separate package and providing instructions for integrating with Swashbuckle and Microsoft.AspNetCore.OpenApi. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10]

Codebase Adjustments:

  • Updated sample projects to target .NET 9.0 and upgraded Swashbuckle.AspNetCore package versions. [1] [2] [3] [4]
  • Modified the Program.cs file in the JwtBearerSample to use AddOpenApi instead of AddSwaggerGen for OpenAPI configuration.

Closes #127
Closes #128

- Updated README.md to note Swashbuckle support moved to SimpleAuthentication.Swashbuckle.
- Added SimpleAuthentication.Swashbuckle project to solution.
- Updated sample projects to target net9.0 and reference SimpleAuthentication.Swashbuckle.
- Updated SimpleAuthentication.csproj with conditional OpenApi reference and updated dependencies.
- Removed Swashbuckle-related files from SimpleAuthentication.
- Added GitHub Actions workflow to publish SimpleAuthentication.Swashbuckle to NuGet.
- Added SimpleAuthentication.Swashbuckle project and documentation files.
- Introduced new functionality for authentication support in Swagger, including JWT Bearer, API Key, and Basic Authentication schemes.
- Added version.json for version management with NerdBank.GitVersioning.
Introduce new functionality for adding authentication support in Swagger for .NET 9.0 or greater. This includes configuring and displaying the Authorize button in the Swagger UI for JWT Bearer, API Key, and Basic Authentication.

Encapsulate changes within `#if NET9_0_OR_GREATER` preprocessor directives to ensure compatibility with .NET 9.0+.

Add new using directives for necessary namespaces.

Introduce `SwaggerExtensions` class in `OpenApiExtensions.cs` with `AddSimpleAuthentication` methods for configuring Swagger authentication.

Add `AuthenticationDocumentTransformer` class in `AuthenticationDocumentTransformer.cs` to transform OpenAPI documents with security definitions and requirements.

Add `AuthenticationOperationTransformer` class in `AuthenticationOperationTransformer.cs` to automatically add 401 and 403 responses to authorized operations.

Introduce `Helpers` class in `Helpers.cs` with utility methods for creating security requirements and responses.

Ensure Swagger UI supports various authentication schemes for easier testing of authenticated endpoints.
Updated SimpleAuthentication.sln to include Net8JwtBearerSample.
Replaced Swashbuckle with OpenAPI in JwtBearerSample.csproj.
Refactored Program.cs for OpenAPI configuration.
Simplified OpenApiSecurityRequirement and OpenApiResponse in Helpers.cs.
Renamed SwaggerExtensions to OpenApiExtensions in OpenApiExtensions.cs.
Added appsettings.Development.json and appsettings.json for config.
Added Net8JwtBearerSample.csproj with necessary dependencies.
Added Program.cs for Net8JwtBearerSample setup.
Added ApplicationAuthenticationSchemeProvider.cs for custom auth logic.
Added ClaimsTransformer.cs for custom claims transformation.
Added launchSettings.json for JwtBearerSample project.
Updated README.md:
- Reformatted installation, configuration, and code examples using code blocks.
- Added sections for Swashbuckle and Microsoft.AspNetCore.OpenApi integration.
- Documented a known issue with `AddSimpleAuthentication` and `AddOpenApi`.
- Updated JWT Bearer and custom authentication logic examples.
- Enhanced permission-based authorization section.
- Added links to JWT Bearer and API Key samples.

Cleaned up AuthenticationOperationTransformer.cs:
- Removed several unused `using` directives.
Refactored and added new functionality for OpenAPI and Swagger integration related to authentication in a .NET project. Removed `Helpers` class and moved its functionality to a new `OpenApiHelpers` class. Updated `AuthenticationOperationFilter` and `AuthenticationOperationTransformer` to use `OpenApiHelpers`. Updated `SwaggerExtensions` and `OpenApiExtensions` to support OAuth2 authentication, including new methods for adding OAuth2 schemes and security requirements. Introduced `OAuth2AuthenticationDocumentTransformer` for transforming OpenAPI documents to include OAuth2. Ensured compatibility with .NET 9.0+ using conditional compilation. Defined `OpenApiHelpers` in both `SimpleAuthentication.Swagger` and `SimpleAuthentication.OpenApi` namespaces for different contexts.

#127 #128
Updated documentation comments to standardize "OpenAPI" terminology and clarify "OAuth2 custom authentication support." Corrected minor grammatical errors for improved readability. No functional code changes.

#128
Updated Nerdbank.GitVersioning package from 3.6.146 to 3.7.112 in Directory.Build.props.
Incremented project version in version.json from 2.1 to 3.0, indicating a new release or significant update.

#127
@marcominerva marcominerva merged commit 338318d into master Jan 8, 2025
5 checks passed
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.

Support the .NET 9.0 OpenAPI generation Update to support .NET 9.0
1 participant