https://github.com/casbin/protobuf-adapter
Google Protocol Buffers adapter for Casbin
https://github.com/casbin/protobuf-adapter
access-control adapter authorization casbin protobuf storage-driver
Last synced: about 2 months ago
JSON representation
Google Protocol Buffers adapter for Casbin
- Host: GitHub
- URL: https://github.com/casbin/protobuf-adapter
- Owner: casbin
- License: apache-2.0
- Created: 2017-06-28T05:02:09.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2023-08-06T13:56:54.000Z (almost 2 years ago)
- Last Synced: 2025-04-10T18:47:29.703Z (about 2 months ago)
- Topics: access-control, adapter, authorization, casbin, protobuf, storage-driver
- Language: Go
- Homepage: https://github.com/casbin/casbin
- Size: 10.7 KB
- Stars: 192
- Watchers: 4
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Protobuf Adapter [](https://travis-ci.org/casbin/protobuf-adapter) [](https://coveralls.io/github/casbin/protobuf-adapter?branch=master) [](https://godoc.org/github.com/casbin/protobuf-adapter)
====Protobuf Adapter is the [Google Protocol Buffers](https://developers.google.com/protocol-buffers/) adapter for [Casbin](https://github.com/casbin/casbin). With this library, Casbin can load policy from Protocol Buffers or save policy to it.
## Installation
go get github.com/casbin/protobuf-adapter
## Simple Example
```go
package mainimport (
"github.com/casbin/casbin"
"github.com/casbin/protobuf-adapter"
)func main() {
// Initialize a Protobuf adapter and use it in a Casbin enforcer:
b := []byte{} // b stores Casbin policy in Protocol Buffers.
a := protobufadapter.NewProtobufAdapter(&b) // Use b as the data source.
e := casbin.NewEnforcer("examples/rbac_model.conf", a)
// Load the policy from Protocol Buffers bytes b.
e.LoadPolicy()
// Check the permission.
e.Enforce("alice", "data1", "read")
// Modify the policy.
// e.AddPolicy(...)
// e.RemovePolicy(...)
// Save the policy back to Protocol Buffers bytes b.
e.SavePolicy()
}
```## Getting Help
- [Casbin](https://github.com/casbin/casbin)
## License
This project is under Apache 2.0 License. See the [LICENSE](LICENSE) file for the full license text.