Awesome Open Source
Awesome Open Source

jcasbin-jfinal-plugin Build Status

jcasbin-jfinal-plugin is an authorization middleware for JFinal, it's based on https://awesomeopensource.com/project/casbin/jcasbin. It is developed under the latest JFinal 3.4 and Java 8.

Installation

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

Simple Example

This project itself is a working JFinal project that integrates with jCasbin. The steps to use jCasbin in your own JFinal project are:

  1. Copy the JCasbinAuthzInterceptor class to your own project.
  2. Copy authz_model.conf and authz_policy.csv to your project. You can modify them to your own jCasbin model and policy (or loading policy from DB), see Model persistence and Policy persistence.
  3. Replace the HttpBasicAuthnInterceptor class (which provides HTTP basic authentication) with your own authentication like OAuth, Apache Shiro, Spring Security, etc. Rewrite JCasbinAuthzInterceptor's String getUser(HttpServletRequest request) method to make sure jCasbin can get the authenticated user name.
  4. Make sure the JCasbinAuthzInterceptor interceptor is loaded, so it can filter all your requests. To do this, you can use the following code in your XXXConfig class:
public class DemoConfig extends JFinalConfig {
    public void configInterceptor(Interceptors me) {
        me.add(new JCasbinAuthzInterceptor());
    }
}

Tutorials

Getting Help

License

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


Get A Weekly Email With Trending Projects For These Topics
No Spam. Unsubscribe easily at any time.
Java (698,488
Plugin (10,169
Authorization (1,346
Rbac (495
Access Control (400
Casbin (193
Abac (119
Jfinal (34
Related Projects