Giter VIP home page Giter VIP logo

casbin-aspnetcore's Introduction

Casbin.AspNetCore

Actions Status Coverage Status License Build Version

Casbin.AspNetCore is a Casbin.NET integration and extension for ASP.NET Core.

Installation

This project is on developing, You can install the build version to try it.

dotnet add package Casbin.AspNetCore --version <build package version> --source https://www.myget.org/F/casbin-net/api/v3/index.json

Or you create a NuGet.config file on you solution directory like this.

<configuration>
  <packageSources>
    <add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
    <add key="myget.org" value="https://www.myget.org/F/casbin-net/api/v3/index.json" />
  </packageSources>
</configuration>

Quick Start

You should add the service at ConfigureServices method and add MiddleWare at Configure method like this:

public void ConfigureServices(IServiceCollection services)
{
    // Other codes...

    //Add Casbin Authorization
    services.AddCasbinAuthorization(options =>
    {
        options.DefaultModelPath = "<model path>";
        options.DefaultPolicyPath = "<policy path>";
    });
}

public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
    // Other codes...

    app.UseCasbinAuthorization();

    // You can add this to support offical authorization too.
    app.UseAuthorization();

    // Other codes...
}

Now you can use the attribute like offical authorization, If you use the Basic Model, It will like this:

[CasbinAuthorize("<obj>", "<act>")]
public IActionResult Index()
{
    return View();
}

Usages

Head over to the usages on the wiki to know all the features.

How It Works

Head over to the how it works on the wiki for user guidance on how it works.

Samples

Sample applications using Casbin.AspNetCore can be found at sample directory.

Getting Help

License

This project is under Apache 2.0 License. See the LICENSE file for the full license text.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.