Mybatis Adapter for JCasbin

Load policy from Mybatis or save policy to it

License

License

Categories

Categories

MyBatis Data ORM
GroupId

GroupId

org.casbin
ArtifactId

ArtifactId

mybatis-adapter
Last Version

Last Version

1.0.0
Release Date

Release Date

Type

Type

jar
Description

Description

Mybatis Adapter for JCasbin
Load policy from Mybatis or save policy to it
Project URL

Project URL

https://github.com/jcasbin/mybatis-adapter
Source Code Management

Source Code Management

https://github.com/jcasbin/mybatis-adapter

Download mybatis-adapter

How to add to project

<!-- https://jarcasting.com/artifacts/org.casbin/mybatis-adapter/ -->
<dependency>
    <groupId>org.casbin</groupId>
    <artifactId>mybatis-adapter</artifactId>
    <version>1.0.0</version>
</dependency>
// https://jarcasting.com/artifacts/org.casbin/mybatis-adapter/
implementation 'org.casbin:mybatis-adapter:1.0.0'
// https://jarcasting.com/artifacts/org.casbin/mybatis-adapter/
implementation ("org.casbin:mybatis-adapter:1.0.0")
'org.casbin:mybatis-adapter:jar:1.0.0'
<dependency org="org.casbin" name="mybatis-adapter" rev="1.0.0">
  <artifact name="mybatis-adapter" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.casbin', module='mybatis-adapter', version='1.0.0')
)
libraryDependencies += "org.casbin" % "mybatis-adapter" % "1.0.0"
[org.casbin/mybatis-adapter "1.0.0"]

Dependencies

compile (2)

Group / Artifact Type Version
org.casbin : jcasbin jar 1.1.0
org.mybatis : mybatis jar 3.4.6

test (2)

Group / Artifact Type Version
junit : junit jar 4.11
mysql : mysql-connector-java jar 8.0.16

Project Modules

There are no modules declared in this project.

mybatis-adapter

codebeat badge Build Status Coverage Status javadoc Maven Central Gitter

Mybatis Adapter is the Mybatis adapter for jCasbin, which provides interfaces for loading policies from Mybatis and saving policies to it.

Installation

<dependency>
    <groupId>org.casbin</groupId>
    <artifactId>mybatis-adapter</artifactId>
    <version>1.0-SNAPSHOT</version>
</dependency>

Example

package com.company.example;

import org.casbin.jcasbin.main.Enforcer;
import org.casbin.jcasbin.util.Util;
import org.casbin.adapter.MybatisAdapter;

public class Example {
    public void test() {
        Enforcer e = new Enforcer("examples/rbac_model.conf", "examples/rbac_policy.csv");
    
        String driver = "com.mysql.jdbc.Driver";
        String url = "jdbc:mysql://localhost:3306/tbl";
        String username = "YourUsername";
        String password = "YourPassword";
        
        MybatisAdapter a = new MybatisAdapter(driver, url, username, password, true);
    
        // Save policy to DB
        a.savePolicy(e.getModel());
    
        // Load policy from DB
        a.loadPolicy(e.getModel());
    }
}

Getting Help

License

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

org.casbin

jCasbin

jCasbin authorization library and the official middlewares

Versions

Version
1.0.0