Giter Site home page Giter Site logo

ericdotwang / beego-authz Goto Github PK

View Code? Open in Web Editor NEW

This project forked from casvisor/casvisor

0.0 0.0 0.0 26 KB

Beego's RBAC & ABAC Authorization middleware based on Casbin

Home Page: https://github.com/casbin/casbin

License: Apache License 2.0

Go 100.00%

beego-authz's Introduction

beego-authz Build Status Coverage Status GoDoc

beego-authz is an authorization middleware for Beego. It provides authorization like ACL, RBAC, ABAC based on Casbin: https://github.com/casbin/casbin

With beego-authz, you can control who can access what resource via which method for your Beego app.

Get Started

Step 1: edit the policy

Modify the Casbin model: authz_model.conf and policy: authz_policy.csv as you want. You may need to learn Casbin's basics to know how to edit these files. The policy means that the user alice can access /dataset1/* via GET and /dataset1/resource1 via POST. The similar way applies to user bob. cathy has the role dataset1_admin, which is permitted to access any resources under /dataset1/ with any action. For more advanced usage of Casbin (like database support, policy language grammar, etc), please refer to Casbin: https://github.com/casbin/casbin

Step 2: integrate with Beego

Insert the Casbin authorizer as a Beego filter.

beego.InsertFilter("*", beego.BeforeRouter, authz.NewAuthorizer(casbin.NewEnforcer("authz_model.conf", "authz_policy.csv")))

Step 3: setup with authentication

Make sure you already have an authentication mechanism, so you know who is accessing, like a username. Modify the GetUserName() method to let Casbin know the current authenticated username.

Getting Help

License

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

beego-authz's People

Contributors

hsluoyz avatar shalk avatar

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.