Giter VIP home page Giter VIP logo

nutz-authz's Introduction

jcasbin-nutz-plugin Build Status Coverage Status

(For English version)

jcasbin-nutz-plugin是专门为Java Web框架Nutz打造的权限管理插件, 基于https://github.com/casbin/jcasbin技术实现。基于最新的Nutz 1.r.65和Java 8版本进行开发。

安装

git clone https://github.com/jcasbin/jcasbin-nutz-plugin

一个简单例子

本项目自身就是一个Nutz项目,演示了如何与jCasbin权限框架集成。如果你要在自己的Nutz项目里使用jCasbin进行权限管理,可以参考如下步骤:

  1. 把这个类:JCasbinAuthzFilter复制到你自己的项目里;
  2. 把jCasbin的模型文件:authz_model.conf和策略文件:authz_policy.csv复制到你自己的项目里。你可以按自己需求这几个文件(或者直接从数据库读取策略),详情请参考:如何读写jCasbin模型以及如何读写jCasbin策略
  3. 把这个类:HttpBasicAuthnFilter(实现了HTTP basic authentication)替换成你自己的身份认证机制(用户登录),比如OAuth、Apache Shiro、Spring Security等。重写JCasbinAuthzFilter里的这个方法:String getUser(HttpServletRequest request)来保证jCasbin能够得到登录后的用户名;
  4. 保证JCasbinAuthzFilter过滤器被加载, 使其可以过滤所有请求。可以参考下面的例子对MainModule类进行修改:
@Filters({@By(type=JCasbinAuthzFilter.class), @By(type=HttpBasicAuthnFilter.class)})
public class MainModule {
    ...
}

教程

帮助

协议

本软件采用Apache 2.0授权协议开源,请点击LICENSE查看完整授权协议。

nutz-authz's People

Contributors

hsluoyz avatar shy1st avatar

Stargazers

 avatar

Watchers

 avatar  avatar  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.