https://github.com/jcasbin/mybatis-adapter
  
  
    MyBatis 3 adapter for Casbin 
    https://github.com/jcasbin/mybatis-adapter
  
access-control adapter authorization casbin java jcasbin jdbc mybatis storage-driver
        Last synced: 4 months ago 
        JSON representation
    
MyBatis 3 adapter for Casbin
- Host: GitHub
- URL: https://github.com/jcasbin/mybatis-adapter
- Owner: jcasbin
- License: apache-2.0
- Created: 2020-03-19T08:13:32.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2023-07-06T14:57:05.000Z (over 2 years ago)
- Last Synced: 2023-07-06T15:44:08.307Z (over 2 years ago)
- Topics: access-control, adapter, authorization, casbin, java, jcasbin, jdbc, mybatis, storage-driver
- Language: Java
- Homepage: https://github.com/casbin/jcasbin
- Size: 24.4 KB
- Stars: 8
- Watchers: 3
- Forks: 4
- Open Issues: 0
- 
            Metadata Files:
            - Readme: README.md
- License: LICENSE
 
Awesome Lists containing this project
README
          # mybatis-adapter
[](https://codebeat.co/projects/github-com-jcasbin-mybatis-adapter-master)
[](https://github.com/jcasbin/mybatis-adapter/actions)
[](https://codecov.io/github/jcasbin/mybatis-adapter)
[](https://javadoc.io/doc/org.casbin/mybatis-adapter)
[](https://mvnrepository.com/artifact/org.casbin/mybatis-adapter/latest)
[](https://discord.gg/S5UjpzGZjN)
Mybatis Adapter is the Mybatis adapter for jCasbin, which provides interfaces for loading policies from Mybatis and saving policies to it.
## Installation
    
        org.casbin
        mybatis-adapter
        version
    
    
## 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
- [jCasbin](https://github.com/casbin/jcasbin)
## License
This project is under Apache 2.0 License. See the [LICENSE](LICENSE) file for the full license text.