IntraDotNet.AspNetCore 1.0.1

There is a newer version of this package available.
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
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="IntraDotNet.AspNetCore" Version="1.0.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="IntraDotNet.AspNetCore" Version="1.0.1" />
                    
Directory.Packages.props
<PackageReference Include="IntraDotNet.AspNetCore" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add IntraDotNet.AspNetCore --version 1.0.1
                    
#r "nuget: IntraDotNet.AspNetCore, 1.0.1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package IntraDotNet.AspNetCore@1.0.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=IntraDotNet.AspNetCore&version=1.0.1
                    
Install as a Cake Addin
#tool nuget:?package=IntraDotNet.AspNetCore&version=1.0.1
                    
Install as a Cake Tool

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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.4 65 6/7/2025
1.0.3 128 1/22/2025
1.0.2 111 12/18/2024
1.0.1 105 12/17/2024
1.0.0 94 12/17/2024