{"id":25491845,"url":"https://github.com/megabytemark/intradotnet-aspnetcore","last_synced_at":"2025-04-10T00:06:31.094Z","repository":{"id":268125586,"uuid":"903033751","full_name":"MegaByteMark/intradotnet-aspnetcore","owner":"MegaByteMark","description":"ASP.NET Core polyfill for enabling Windows features when targetting an intranet enviroment.","archived":false,"fork":false,"pushed_at":"2025-01-29T21:21:49.000Z","size":53,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-10T00:06:26.182Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/MegaByteMark.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-12-13T19:36:23.000Z","updated_at":"2025-04-03T19:31:23.000Z","dependencies_parsed_at":"2024-12-17T22:25:14.729Z","dependency_job_id":"266b9fcd-1210-43e4-bb63-5c5f1ffa7b5e","html_url":"https://github.com/MegaByteMark/intradotnet-aspnetcore","commit_stats":null,"previous_names":["megabytemark/intradotnet-windows-server","megabytemark/intradotnet-aspnetcore"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MegaByteMark%2Fintradotnet-aspnetcore","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MegaByteMark%2Fintradotnet-aspnetcore/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MegaByteMark%2Fintradotnet-aspnetcore/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MegaByteMark%2Fintradotnet-aspnetcore/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MegaByteMark","download_url":"https://codeload.github.com/MegaByteMark/intradotnet-aspnetcore/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248131318,"owners_count":21052819,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-02-18T22:19:03.514Z","updated_at":"2025-04-10T00:06:31.051Z","avatar_url":"https://github.com/MegaByteMark.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# IntraDotNet.AspNetCore\n\nASP.NET Core polyfill for enabling Windows features when targeting a Windows intranet environment.\n\n## Summary\n\nThis 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.\n\n## Features\n\n- Windows Impersonation Middleware\n- Windows Group Membership Authorization\n\n## Installation\n\nTo install the library, add the following NuGet package to your project:\n\n```bash\ndotnet add package IntraDotNet.AspNetCore\n```\n\n## Usage\n\n### Windows Impersonation Middleware\n\nTo use the Windows Impersonation Middleware, add it to the middleware pipeline in the Program.cs file:\n```csharp\nusing IntraDotNet.AspNetCore.Middleware;\nusing Microsoft.AspNetCore.Builder;\nusing Microsoft.Extensions.DependencyInjection;\nusing IntraDotNet.AspNetCore.DependencyInjection;\nusing Microsoft.Extensions.Hosting;\n\nvar builder = WebApplication.CreateBuilder(args);\n\nbuilder.Services.AddControllers();\nbuilder.Services.AddAuthentication(NegotiateDefaults.AuthenticationScheme).AddNegotiate();\n\n//This is to make Windows Auth work on Kestrel.\nbuilder.Services.AddAuthorization(options =\u003e\n{\n    options.FallbackPolicy = options.DefaultPolicy;\n});\n\nvar app = builder.Build();\n\napp.UseAuthentication();\n\n// Add after UseAuthentication, you must have already added Negotiate authentication before calling UseAuthentication.\napp.UseWindowsImpersonation();\n\napp.UseAuthorization();\n\napp.MapControllers();\n\napp.Run();\n```\n\n### Windows Group Membership Authorization\n\nTo use Windows Group Membership Authorization, configure the authorization policies in the appsettings.json file and Startup.cs file:\n\n#### appsettings.json\n```json\n{\n  \"Authorization\": {\n    \"Policies\": [\n      {\n        \"Name\": \"RequireWindowsGroup\",\n        \"AllowedGroups\": [ \"DomainName\\\\GroupName\" ]\n      }\n    ]\n  }\n}\n```\n\n#### Program.cs\n```csharp\nusing IntraDotNet.AspNetCore.Authorization.WindowsGroupMembership.DependencyInjection;\nusing Microsoft.AspNetCore.Authorization;\nusing Microsoft.Extensions.Configuration;\nusing Microsoft.Extensions.DependencyInjection;\nusing Microsoft.Extensions.Hosting;\n\nvar builder = WebApplication.CreateBuilder(args);\n\nbuilder.Services.AddControllers();\n\nbuilder.Services.AddWindowsGroupMembershipAuthorization(() =\u003e\n{\n  return builder.Configuration.GetSection(\"Authorization:WindowsGroupMembershipAuthorization\").Get\u003cWindowsGroupMembershipAuthorizationOptions\u003e()\n});\n\nvar app = builder.Build();\n\napp.UseRouting();\napp.UseAuthorization();\napp.MapControllers();\n\napp.Run();\n```\n\nIn your controller, you can then use the policy to protect actions:\n\n```csharp\n[Authorize(Policy = \"RequireWindowsGroup\")]\npublic class SecureController : ControllerBase\n{\n    public IActionResult Get()\n    {\n        return Ok(\"This is a secure endpoint.\");\n    }\n}\n```\n\nFor minimal API:\n```csharp\napp.MapGet(\"/ping\", (HttpContext httpContext) =\u003e\n{\n    var username = httpContext.User.Identity?.Name ?? \"Anonymous\";\n    return $\"pong from {username}\";\n})\n.RequireAuthorization(\"RequireWindowsGroup\");\n```\n\n## Contributing\n\nContributions are welcome! Please open an issue or submit a pull request.\n\n## License\n\nThis project is licensed under the MIT License.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmegabytemark%2Fintradotnet-aspnetcore","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmegabytemark%2Fintradotnet-aspnetcore","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmegabytemark%2Fintradotnet-aspnetcore/lists"}