Skip to content

Casbin CouchDB Adapter is an adapter for jCasbin, a robust authorization library that supports access control models like ACL, RBAC, ABAC in Java, using CouchDB as a storage backend.

License

Notifications You must be signed in to change notification settings

java-casbin/casbin-couchdb-adapter

Repository files navigation

Casbin CouchDB Adapter

Casbin CouchDB Adapter is an adapter for jCasbin, a robust authorization library that supports access control models like ACL, RBAC, ABAC in Java, using CouchDB as a storage backend.

Features

  • Efficient and secure data handling with CouchDB.
  • Easy integration with jCasbin.
  • Scalable for large datasets.
  • Support for all jCasbin models (ACL, RBAC, ABAC).

Build

Requirements:

  • JDK 17
./gradlew build

Installation

To install the casbin-couchdb-adapter, add the following dependency to your build.gradle file:

dependencies {
    implementation 'io.github.java-casbin:casbin-couchdb-adapter'
}

Or if you are using Maven, add the following dependency to your pom.xml file:

<dependency>
  <groupId>io.github.java-casbin</groupId>
  <artifactId>casbin-couchdb-adapter</artifactId>
</dependency>

Usage

Here's a basic example of how to use the casbin-couchdb-adapter with jCasbin:

import org.casbin.jcasbin.main.Enforcer;
import com.github.yourusername.casbin.CouchDBAdapter;

public class Main {
    public static void main(String[] args) {
        CouchDbProperties properties = new CouchDbProperties()
                .setDbName("test_db")
                .setCreateDbIfNotExist(true)
                .setUsername("admin")
                .setPassword("admin")
                .setProtocol("http")
                .setHost("localhost")
                .setPort(5984)
                .setMaxConnections(100)
                .setConnectionTimeout(0);
        couchDbClient = new CouchDbClient(properties);
        String modelPath = "path/to/model.conf";
        CouchDBAdapter adapter = new CouchDBAdapter(couchDbClient, "policies");
        Enforcer enforcer = new Enforcer(modelPath, adapter);
        // use the enforcer...
    }
}

Contributing

Contributions to casbin-couchdb-adapter are welcome! Please feel free to open an issue or submit a pull request if you have any questions or suggestions.

License

Licensed under the Apache License, Version 2.0: http://www.apache.org/licenses/LICENSE-2.0

Release

  • Change the version to the next release version in build.gradle.
  • Run ./bundle.sh to build the bundle file. The bundle file will be located at build/bundle.zip.
  • Upload the bundle file to https://central.sonatype.com/
  • Create a new release on GitHub with the release notes

About

Casbin CouchDB Adapter is an adapter for jCasbin, a robust authorization library that supports access control models like ACL, RBAC, ABAC in Java, using CouchDB as a storage backend.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published