All Projects → jcasbin → jdbc-adapter

jcasbin / jdbc-adapter

Licence: Apache-2.0 License
JDBC adapter for Casbin

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to jdbc-adapter

Xorm Adapter
Xorm adapter for Casbin
Stars: ✭ 329 (+1165.38%)
Mutual labels:  adapter, authorization, access-control
sqlx-adapter
Asynchronous casbin adapter for mysql, postgres, sqlite based on sqlx-rs
Stars: ✭ 27 (+3.85%)
Mutual labels:  adapter, access-control, storage-driver
Protobuf Adapter
Google Protocol Buffers adapter for Casbin
Stars: ✭ 185 (+611.54%)
Mutual labels:  adapter, authorization, access-control
sequelize-adapter
Sequelize adapter for Casbin
Stars: ✭ 51 (+96.15%)
Mutual labels:  adapter, authorization, access-control
Gorm Adapter
Gorm adapter for Casbin
Stars: ✭ 373 (+1334.62%)
Mutual labels:  adapter, authorization, access-control
Redis Adapter
Redis adapter for Casbin
Stars: ✭ 167 (+542.31%)
Mutual labels:  adapter, authorization, access-control
Mongodb Adapter
MongoDB adapter for Casbin
Stars: ✭ 194 (+646.15%)
Mutual labels:  adapter, authorization, access-control
caddy-security
🔐 Authentication, Authorization, and Accounting (AAA) App and Plugin for Caddy v2. 💎 Implements Form-Based, Basic, Local, LDAP, OpenID Connect, OAuth 2.0 (Github, Google, Facebook, Okta, etc.), SAML Authentication. MFA/2FA with App Authenticators and Yubico. 💎 Authorization with JWT/PASETO tokens. 🔐
Stars: ✭ 696 (+2576.92%)
Mutual labels:  authorization, access-control
lua-casbin
An authorization library that supports access control models like ACL, RBAC, ABAC in Lua (OpenResty)
Stars: ✭ 43 (+65.38%)
Mutual labels:  authorization, access-control
casbin-pg-adapter
A go-pg adapter for casbin
Stars: ✭ 23 (-11.54%)
Mutual labels:  adapter, access-control
objection-authorize
isomorphic, "magical" authorization integration with Objection.js 🎉
Stars: ✭ 71 (+173.08%)
Mutual labels:  authorization, access-control
sheriff
Build simple and robust authorization systems with just Elixir and Plug
Stars: ✭ 39 (+50%)
Mutual labels:  authorization, access-control
rbac-tool
Rapid7 | insightCloudSec | Kubernetes RBAC Power Toys - Visualize, Analyze, Generate & Query
Stars: ✭ 546 (+2000%)
Mutual labels:  authorization, access-control
dart-casbin
An authorization library that supports access control models like ACL, RBAC, ABAC in Dart/Flutter
Stars: ✭ 30 (+15.38%)
Mutual labels:  authorization, access-control
nova-permissions
Add Permissions based authorization for your Nova installation via User-based Roles and Permissions. Roles are defined in the database whereas Permissions are defined in the code base.
Stars: ✭ 115 (+342.31%)
Mutual labels:  authorization, access-control
ficam-playbooks
The Federal Identity Credentials and Access Management program publishes guides and playbooks to help U.S. federal executive agencies implement, maintain, and modernize identity management systems.
Stars: ✭ 30 (+15.38%)
Mutual labels:  authorization, access-control
SpringSecurityInEasySteps
Learn Spring Security step by step
Stars: ✭ 13 (-50%)
Mutual labels:  authorization, access-control
server
AuthzForce Server (Community Edition)
Stars: ✭ 48 (+84.62%)
Mutual labels:  authorization, access-control
keyonic-v2
A Keycloak Mobile Implementation using Angular v4 and Ionic v3
Stars: ✭ 23 (-11.54%)
Mutual labels:  adapter, authorization
casbin-ex
An authorization library that supports access control models like ACL, RBAC, ABAC in Elixir
Stars: ✭ 37 (+42.31%)
Mutual labels:  authorization, access-control

JDBC Adapter

codebeat badge build codecov Javadocs Maven Central Gitter

JDBC Adapter is the JDBC adapter for jCasbin. With this library, jCasbin can load policy from JDBC supported database or save policy to it.

Based on Supported JDBC Drivers and Databases, The current supported databases are:

  • MySQL
  • Java DB
  • Oracle
  • PostgreSQL
  • DB2
  • Sybase
  • Microsoft SQL Server

Verified Database

  • MySQL
  • PostgreSQL
  • Microsoft SQL Server

We need more developers to help us verify.

Installation

For Maven:

<dependency>
  <groupId>org.casbin</groupId>
  <artifactId>jdbc-adapter</artifactId>
  <version>2.0.1</version>
</dependency>

Simple Example

package com.company.test;

import org.casbin.adapter.JDBCAdapter;
import org.casbin.jcasbin.main.Enforcer;
import com.mysql.cj.jdbc.MysqlDataSource;

public class Test {
    public static void main() {
        String driver = "com.mysql.cj.jdbc.Driver";
        String url = "jdbc:mysql://localhost:3306/db_name";
        String username = "root";
        String password = "123456";

        // The adapter will use the table named "casbin_rule".
        // Use driver, url, username and password to initialize a JDBC adapter.
        JDBCAdapter a = new JDBCAdapter(driver, url, username, password); 
        
        // Recommend use DataSource to initialize a JDBC adapter.
        // Implementer of DataSource interface, such as hikari, c3p0, durid, etc.
        MysqlDataSource dataSource = new MysqlDataSource();
        dataSource.setURL(url);
        dataSource.setUser(username);
        dataSource.setPassword(password);

        a = JDBCAdapter(dataSource);        

        Enforcer e = new Enforcer("examples/rbac_model.conf", a);

        // Check the permission.
        e.enforce("alice", "data1", "read");

        // Modify the policy.
        // e.addPolicy(...);
        // e.removePolicy(...);

        // Save the policy back to DB.
        e.savePolicy();
        // Close the connection.
        a.close();
    }
}

Getting Help

License

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

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].