IntraDotNet.AspNetCore
1.0.1
See the version list below for details.
dotnet add package IntraDotNet.AspNetCore --version 1.0.1
NuGet\Install-Package IntraDotNet.AspNetCore -Version 1.0.1
<PackageReference Include="IntraDotNet.AspNetCore" Version="1.0.1" />
<PackageVersion Include="IntraDotNet.AspNetCore" Version="1.0.1" />
<PackageReference Include="IntraDotNet.AspNetCore" />
paket add IntraDotNet.AspNetCore --version 1.0.1
#r "nuget: IntraDotNet.AspNetCore, 1.0.1"
#:package IntraDotNet.AspNetCore@1.0.1
#addin nuget:?package=IntraDotNet.AspNetCore&version=1.0.1
#tool nuget:?package=IntraDotNet.AspNetCore&version=1.0.1
IntraDotNet.AspNetCore
ASP.NET Core polyfill for enabling Windows features when targeting a Windows intranet environment.
Summary
This library provides middleware and authorization handlers to enable Windows-specific features in an ASP.NET Core application. It includes support for Windows impersonation and Windows group membership authorization, making it easier to integrate with existing Windows-based AD DS infrastructure in an intranet environment.
Features
- Windows Impersonation Middleware
- Windows Group Membership Authorization
Installation
To install the library, add the following NuGet package to your project:
dotnet add package IntraDotNet.AspNetCore
Usage
Windows Impersonation Middleware
To use the Windows Impersonation Middleware, add it to the middleware pipeline in the Program.cs file:
using IntraDotNet.AspNetCore.Middleware;
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddControllers();
builder.Services.AddAuthentication(NegotiateDefaults.AuthenticationScheme).AddNegotiate();
builder.Services.AddAuthorization();
var app = builder.Build();
app.UseAuthentication();
// Add after UseAuthentication, you must have already added Negotiate authentication before calling UseAuthentication.
app.UseMiddleware<WindowsImpersonationMiddleware>();
app.UseAuthorization();
app.MapControllers();
app.Run();
Windows Group Membership Authorization
To use Windows Group Membership Authorization, configure the authorization policies in the appsettings.json file and Startup.cs file:
appsettings.json
{
"Authorization": {
"Policies": [
{
"Name": "RequireWindowsGroup",
"AllowedGroups": [ "DomainName\\GroupName" ]
}
]
}
}
Program.cs
using IntraDotNet.AspNetCore.Authorization.WindowsGroupMembership.DependencyInjection;
using Microsoft.AspNetCore.Authorization;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddControllers();
//You must add the configuration here before calling AddWindowsGroupMembershipAuthorization
builder.Services.Configure<WindowsGroupMembershipAuthorizationOptions>(
builder.Configuration.GetSection("Authorization:WindowsGroupMembershipAuthorization"));
builder.Services.AddWindowsGroupMembershipAuthorization();
var app = builder.Build();
app.UseRouting();
app.UseAuthorization();
app.MapControllers();
app.Run();
In your controller, you can then use the policy to protect actions:
[Authorize(Policy = "RequireWindowsGroup")]
public class SecureController : ControllerBase
{
public IActionResult Get()
{
return Ok("This is a secure endpoint.");
}
}
Contributing
Contributions are welcome! Please open an issue or submit a pull request.
License
This project is licensed under the MIT License.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net9.0
- Microsoft.AspNetCore.Authorization (>= 9.0.0)
- Microsoft.AspNetCore.Http (>= 2.2.2)
- Microsoft.Extensions.Configuration (>= 9.0.0)
- Microsoft.Extensions.Configuration.Binder (>= 9.0.0)
- System.DirectoryServices.AccountManagement (>= 9.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.