{"id":21817809,"url":"https://github.com/weihanli/weihanli.web.extensions","last_synced_at":"2026-04-18T10:13:28.424Z","repository":{"id":34915590,"uuid":"189604389","full_name":"WeihanLi/WeihanLi.Web.Extensions","owner":"WeihanLi","description":" asp.net core web extensions","archived":false,"fork":false,"pushed_at":"2026-01-23T16:19:01.000Z","size":408,"stargazers_count":20,"open_issues_count":0,"forks_count":5,"subscribers_count":2,"default_branch":"dev","last_synced_at":"2026-01-24T07:15:24.452Z","etag":null,"topics":["aspnetcore","extensions","middlewares","web","weihanli"],"latest_commit_sha":null,"homepage":"https://www.nuget.org/packages/WeihanLi.Web.Extensions","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/WeihanLi.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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2019-05-31T14:08:19.000Z","updated_at":"2026-01-23T16:11:14.000Z","dependencies_parsed_at":"2023-11-16T02:29:35.018Z","dependency_job_id":"ba0ff4a4-a1b5-4667-9cb1-04bf96f77803","html_url":"https://github.com/WeihanLi/WeihanLi.Web.Extensions","commit_stats":{"total_commits":253,"total_committers":1,"mean_commits":253.0,"dds":0.0,"last_synced_commit":"cdb09039f5d1bca7d51e3cbc07704b7e7bac640d"},"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/WeihanLi/WeihanLi.Web.Extensions","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WeihanLi%2FWeihanLi.Web.Extensions","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WeihanLi%2FWeihanLi.Web.Extensions/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WeihanLi%2FWeihanLi.Web.Extensions/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WeihanLi%2FWeihanLi.Web.Extensions/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/WeihanLi","download_url":"https://codeload.github.com/WeihanLi/WeihanLi.Web.Extensions/tar.gz/refs/heads/dev","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WeihanLi%2FWeihanLi.Web.Extensions/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31964740,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-18T00:39:45.007Z","status":"online","status_checked_at":"2026-04-18T02:00:07.018Z","response_time":103,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["aspnetcore","extensions","middlewares","web","weihanli"],"created_at":"2024-11-27T15:48:35.295Z","updated_at":"2026-04-18T10:13:28.406Z","avatar_url":"https://github.com/WeihanLi.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# WeihanLi.Web.Extensions\n\n\u003e A curated set of practical building blocks for ASP.NET Core apps: authentication providers, endpoint filters, middleware, MVC helpers, and more.\n\n[![NuGet](https://img.shields.io/nuget/v/WeihanLi.Web.Extensions)](https://www.nuget.org/packages/WeihanLi.Web.Extensions/) \n[![NuGet (prerelease)](https://img.shields.io/nuget/vpre/WeihanLi.Web.Extensions)](https://www.nuget.org/packages/WeihanLi.Web.Extensions/absoluteLatest) \n[![Azure Pipelines](https://weihanli.visualstudio.com/Pipelines/_apis/build/status/WeihanLi.WeihanLi.Web.Extensions?branchName=dev)](https://weihanli.visualstudio.com/Pipelines/_build/latest?definitionId=19\u0026branchName=dev) \n[![GitHub Actions](https://github.com/WeihanLi/WeihanLi.Web.Extensions/workflows/dotnetcore/badge.svg)](https://github.com/WeihanLi/WeihanLi.Web.Extensions/actions?query=workflow%3Adotnetcore)\n\n## Table of Contents\n- [Features](#features)\n- [Installation](#installation)\n- [Quick Start](#quick-start)\n- [Usage Highlights](#usage-highlights)\n- [Samples and Docs](#samples-and-docs)\n- [Build Locally](#build-locally)\n- [Contributing](#contributing)\n- [License](#license)\n\n## Features\n\n- **Authentication providers** – drop-in handlers for API key, basic, header, query string, and delegate-based schemes (`AuthenticationBuilderExtension`).\n- **Access control helper** – configure granular resource checks, tag helpers, and middleware, or promote the policy to the app default (`AccessControlHelper`).\n- **JWT tooling** – lightweight `JwtTokenService` for issuing/refreshing tokens with ASP.NET Core authentication integration.\n- **Response filters** – `ApiResultFilter`, environment/conditional filters, and feature-flag-aware filters for consistent API responses.\n- **Middleware toolset** – exception handler, configuration inspector, feature-flag-based pipeline branching, health check helpers.\n- **MVC utilities** – strongly typed pager, plain-text formatter, tenant/user providers, and HTTP context extensions (`HttpContextExtension`). \n- **Target frameworks** – ships for `net8.0`, `net9.0`, and `net10.0`.\n\nExplore the `src/WeihanLi.Web.Extensions` folder for the full catalog; each namespace groups related functionality (Authentication, Authorization, Filters, Middleware, Pager, etc.).\n\n## Installation\n\n```bash\ndotnet add package WeihanLi.Web.Extensions\n```\n\n## Quick Start\n\n```csharp\nvar builder = WebApplication.CreateBuilder(args);\n\nbuilder.Services\n    .AddControllers(options =\u003e\n    {\n        options.Filters.Add\u003cApiResultFilter\u003e(); // standardize API responses\n    })\n    .AddJsonOptions();\n\nbuilder.Services.AddAuthentication()\n    .AddApiKey(options =\u003e\n    {\n        options.ApiKeyName = \"X-ApiKey\";\n        options.ApiKey = \"super-secret-key\";\n    })\n    .AddBasic(options =\u003e\n    {\n        options.UserName = \"demo\";\n        options.Password = \"demo\";\n    });\n\nbuilder.Services.AddAccessControlHelper\u003cMyResourceStrategy, MyControlStrategy\u003e(options =\u003e\n{\n    options.UseAsDefaultPolicy = true;\n});\n\nvar app = builder.Build();\n\napp.UseAuthentication();\napp.UseAuthorization();\napp.UseAccessControlHelper(); // enable middleware support\n\napp.MapControllers();\napp.Run();\n```\n\nReplace `MyResourceStrategy`/`MyControlStrategy` with your own `IResourceAccessStrategy`/`IControlAccessStrategy` implementations. For a more complete walk-through, review the sample project linked below.\n\n## Usage Highlights\n\n- **Access control** – decorate MVC controllers with `[AccessControl]`, register tag helpers, or use `UseAccessControlHelper()` middleware to enforce centralised policies.\n- **API response shaping** – apply `ApiResultFilter` globally, per controller, or as a minimal API endpoint filter to wrap responses with the built-in `Result` model.\n- **Feature flags** – gate middleware with `app.UseIfFeatureEnabled(...)` or guard actions via `[FeatureFlagFilter(\"MyFlag\")]`, using configuration-driven toggles.\n- **Authentication mix-and-match** – compose multiple schemes (`AddApiKey`, `AddHeader`, `AddQuery`, `AddDelegate`) and map policies using standard `AuthorizeAttribute`.\n- **Developer tooling** – surface configuration via `app.MapConfigInspector()`, enrich structured logging with `HttpContextLoggingEnricher`, or expose probes with `app.MapProbes(...)`.\n\nThese helpers are additive: you can adopt a single filter or mix several features without impacting the default ASP.NET Core pipeline.\n\n## Samples and Docs\n\n- Sample application: `samples/WeihanLi.Web.Extensions.Samples` demonstrates authentication combos, endpoint filters, feature switches, and the config inspector UI.\n- Release notes: `docs/ReleaseNotes.md` tracks major additions for each NuGet version.\n- API reference / documentation site: build with `docfx docfx.json` or browse the published GitHub Pages site (if available).\n\n## Build Locally\n\n\u003e Have the latest .NET SDK installed first, download from \u003chttps://get.dot.net/\u003e\n\nBuild the project\n\n```bash\ndotnet build\n```\n\nTo experiment quickly, run the sample:\n\n```bash\ndotnet run --project samples/WeihanLi.Web.Extensions.Samples\n```\n\n## Contributing\n\nContributions are welcome—issues, feature ideas, and pull requests all help the project grow. Please discuss sizeable changes in an issue before opening a PR and ensure builds pass locally (`dotnet build`) before submitting.\n\n## License\n\nThis project is licensed under the [Apache License 2.0](LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fweihanli%2Fweihanli.web.extensions","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fweihanli%2Fweihanli.web.extensions","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fweihanli%2Fweihanli.web.extensions/lists"}