Eliassen.AspNetCore.Mvc
0.1.82
See the version list below for details.
dotnet add package Eliassen.AspNetCore.Mvc --version 0.1.82
NuGet\Install-Package Eliassen.AspNetCore.Mvc -Version 0.1.82
<PackageReference Include="Eliassen.AspNetCore.Mvc" Version="0.1.82" />
paket add Eliassen.AspNetCore.Mvc --version 0.1.82
#r "nuget: Eliassen.AspNetCore.Mvc, 0.1.82"
// Install Eliassen.AspNetCore.Mvc as a Cake Addin #addin nuget:?package=Eliassen.AspNetCore.Mvc&version=0.1.82 // Install Eliassen.AspNetCore.Mvc as a Cake Tool #tool nuget:?package=Eliassen.AspNetCore.Mvc&version=0.1.82
Eliassen.AspNetCore.Mvc
Summary
This code is part of an open-source project that provides extensions for ASP.NET Core. The extensions include authentication, authorization, and search query support. The code contains several functions and classes that are used to implement these extensions.
Configuration
The configuration options for this code can be found in the ServiceCollectionExtensions class. The main configuration options are:
TryAddAspNetCoreExtensions
This function adds the necessary services to support all ASP.NET Core extensions provided by this library. It takes several parameters, including requireAuthenticatedByDefault, requireApplicationUserId, and authorizationPolicyBuilder.AddRequireAuthenticatedUser
This function adds authentication requirements to the service collection. It takes two parameters, requireApplicationUserId and authorizationPolicyBuilder.TryAddCommonOpenApiExtensions
This function enables extensions for Swagger/OpenAPI.TryAddAspNetCoreSearchQuery
This function enables extensions for shared search query extensions.
Example
Here is an example of how to configure the code
public void ConfigureServices(IServiceCollection services)
{
services.TryAddAspNetCoreExtensions(
requireAuthenticatedByDefault: true,
requireApplicationUserId: true,
authorizationPolicyBuilder: policyBuilder =>
{
policyBuilder.RequireClaim("scope", "api1");
policyBuilder.RequireClaim("scope", "api2");
}
);
services.AddRequireAuthenticatedUser(
requireApplicationUserId: true,
authorizationPolicyBuilder: policyBuilder =>
{
policyBuilder.RequireClaim("role", "admin");
}
);
services.TryAddCommonOpenApiExtensions();
services.TryAddAspNetCoreSearchQuery();
}
In this example, authentication is required by default, and the application user ID is also required. Additionally, two authorization policies are added: one that requires authentication and two specific claims (scope), and another that requires authentication and a specific claim (role). Finally, the Swagger/OpenAPI and search query extensions are enabled.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
-
net8.0
- Eliassen.AspNetCore.Abstractions (>= 0.1.82)
- Eliassen.Extensions (>= 0.1.82)
- Eliassen.System (>= 0.1.82)
- Microsoft.IdentityModel.Logging (>= 7.6.3)
- Swashbuckle.AspNetCore (>= 6.6.2)
- Swashbuckle.AspNetCore.SwaggerGen (>= 6.6.2)
NuGet packages (2)
Showing the top 2 NuGet packages that depend on Eliassen.AspNetCore.Mvc:
Package | Downloads |
---|---|
Eliassen.AspNetCore.JwtAuthentication
Package Description |
|
Eliassen.Common.AspNetCore
Package Description |
GitHub repositories
This package is not used by any popular GitHub repositories.