{"id":49732933,"url":"https://github.com/apache/casbin-aspnetcore","last_synced_at":"2026-05-09T07:01:27.366Z","repository":{"id":44765581,"uuid":"276772820","full_name":"apache/casbin-aspnetcore","owner":"apache","description":"Casbin.NET integration middleware and sample code for ASP.NET Core","archived":false,"fork":false,"pushed_at":"2026-03-23T12:21:32.000Z","size":1192,"stargazers_count":76,"open_issues_count":0,"forks_count":20,"subscribers_count":8,"default_branch":"master","last_synced_at":"2026-05-02T03:12:52.727Z","etag":null,"topics":["abac","acl","aspnet","aspnetcore","auth","authorization","casbin","dotnet","rbac","security"],"latest_commit_sha":null,"homepage":"https://github.com/casbin/Casbin.NET","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/apache.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":"2020-07-03T00:41:13.000Z","updated_at":"2026-04-25T16:06:11.000Z","dependencies_parsed_at":"2024-04-04T16:06:05.037Z","dependency_job_id":null,"html_url":"https://github.com/apache/casbin-aspnetcore","commit_stats":null,"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"purl":"pkg:github/apache/casbin-aspnetcore","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apache%2Fcasbin-aspnetcore","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apache%2Fcasbin-aspnetcore/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apache%2Fcasbin-aspnetcore/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apache%2Fcasbin-aspnetcore/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/apache","download_url":"https://codeload.github.com/apache/casbin-aspnetcore/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apache%2Fcasbin-aspnetcore/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32807860,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-08T08:22:46.396Z","status":"online","status_checked_at":"2026-05-09T02:00:06.633Z","response_time":123,"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":["abac","acl","aspnet","aspnetcore","auth","authorization","casbin","dotnet","rbac","security"],"created_at":"2026-05-09T07:00:55.076Z","updated_at":"2026-05-09T07:01:27.360Z","avatar_url":"https://github.com/apache.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Casbin.AspNetCore\n\n[![Actions Status](https://github.com/casbin-net/casbin-aspnetcore/workflows/Build/badge.svg)](https://github.com/casbin-net/casbin-aspnetcore/actions)\n[![Coverage Status](https://coveralls.io/repos/github/casbin-net/casbin-aspnetcore/badge.svg?branch=master)](https://coveralls.io/github/casbin-net/casbin-aspnetcore?branch=master)\n[![License](https://img.shields.io/github/license/casbin-net/casbin-aspnetcore)](https://github.com/casbin-net/casbin-aspnetcore/blob/master/LICENSE)\n[![Nuget](https://img.shields.io/nuget/v/Casbin.AspNetCore?label=Casbin.AspNetCore)](https://www.nuget.org/packages/Casbin.AspNetCore)\n\nCasbin.AspNetCore is a [Casbin.NET](https://github.com/casbin/Casbin.NET) integration and extension for [ASP.NET Core](https://asp.net).\n\n## Installation\n\nThis project is on developing, You can install the build version to try it.\n\n```csharp\ndotnet add package Casbin.AspNetCore --version \u003cbuild package version\u003e\n```\n\nOr you create a `NuGet.config` file on you solution directory like this.\n\n```xml\n\u003cconfiguration\u003e\n  \u003cpackageSources\u003e\n    \u003cadd key=\"nuget.org\" value=\"https://api.nuget.org/v3/index.json\" /\u003e\n  \u003c/packageSources\u003e\n\u003c/configuration\u003e\n```\n\n## Quick Start\nYou should add the service at `ConfigureServices` method and add MiddleWare at `Configure` method like this:\n\n```csharp\npublic void ConfigureServices(IServiceCollection services)\n{\n    // Other codes...\n\n    //Add Casbin Authorization\n    services.AddCasbinAuthorization(options =\u003e\n    {\n        options.DefaultModelPath = \"\u003cmodel path\u003e\";\n        options.DefaultPolicyPath = \"\u003cpolicy path\u003e\";\n    });\n}\n\npublic void Configure(IApplicationBuilder app, IWebHostEnvironment env)\n{\n    // Other codes...\n\n    app.UseCasbinAuthorization();\n\n    // You can add this to support offical authorization too.\n    app.UseAuthorization();\n\n    // Other codes...\n}\n```\nNow you can use the attribute like offical authorization, If you use the Basic Model, It will like this:\n\n```csharp\n[CasbinAuthorize(\"\u003cobj\u003e\", \"\u003cact\u003e\")]\npublic IActionResult Index()\n{\n    return View();\n}\n```\n\n## How It Works\n\nHere is a sequence chart that can well describe the process of this middleware. In the beginning, It looks like the process of official authorization middleware. It changes in the last half part.\n\n![Sequence Chart of Middleware](https://raw.githubusercontent.com/casbin-net/casbin-aspnetcore/master/docs/assets/casbin-aspnetcore-sequence-chart.png)\n\n## Samples\nSample applications using `Casbin.AspNetCore` can be found at [sample directory](https://github.com/casbin-net/casbin-aspnetcore/tree/master/samples).\n\n## Migrate form v0.x to v1.x\n\n1. Check the interfaces change:\n- IEnforcerProvider\n```csharp\npublic interface IEnforcerProvider\n{\n    // Before\n    public Enforcer? GetEnforcer();\n    // Now\n    public IEnforcer? GetEnforcer();\n}\n```\n- ICasbinModelProvider\n```csharp\npublic interface ICasbinModelProvider\n{\n    // Before\n    public Model? GetModel();\n    // Now\n    public IModel? GetModel();\n}\n```\n\n## Getting Help\n- [Casbin.NET](https://github.com/casbin/Casbin.NET)\n\n## License\nThis project is under Apache 2.0 License. See the [LICENSE](LICENSE) file for the full license text.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fapache%2Fcasbin-aspnetcore","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fapache%2Fcasbin-aspnetcore","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fapache%2Fcasbin-aspnetcore/lists"}