目录

Cassandra Adapter Build Status Coverage Status Godoc

Cassandra Adapter is the Apache Cassandra DB adapter for Casbin. With this library, Casbin can load policy from Cassandra or save policy to it.

Installation

go get github.com/casbin/cassandra-adapter

Simple Example

package main

import (
    "github.com/casbin/casbin"
    "github.com/casbin/cassandra-adapter"
)

func main() {
    // Initialize a Cassandra adapter and use it in a Casbin enforcer:
    a := cassandraadapter.NewAdapter("127.0.0.1") // Your Cassandra hosts. 
    e := casbin.NewEnforcer("examples/rbac_model.conf", a)
    
    // Load the policy from DB.
    e.LoadPolicy()
    
    // Check the permission.
    e.Enforce("alice", "data1", "read")
    
    // Modify the policy.
    // e.AddPolicy(...)
    // e.RemovePolicy(...)
    
    // Save the policy back to DB.
    e.SavePolicy()
}

Getting Help

License

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

关于
46.0 KB
邀请码
    Gitlink(确实开源)
  • 加入我们
  • 官网邮箱:gitlink@ccf.org.cn
  • QQ群
  • QQ群
  • 公众号
  • 公众号

版权所有:中国计算机学会技术支持:开源发展技术委员会
京ICP备13000930号-9 京公网安备 11010802032778号