# protobuf-adapter-casbin **Repository Path**: anyauth/protobuf-adapter-casbin ## Basic Information - **Project Name**: protobuf-adapter-casbin - **Description**: Google Protocol Buffers adapter for Casbin - **Primary Language**: Unknown - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2024-10-24 - **Last Updated**: 2024-10-24 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README Protobuf Adapter [![Build Status](https://travis-ci.org/casbin/protobuf-adapter.svg?branch=master)](https://travis-ci.org/casbin/protobuf-adapter) [![Coverage Status](https://coveralls.io/repos/github/casbin/protobuf-adapter/badge.svg?branch=master)](https://coveralls.io/github/casbin/protobuf-adapter?branch=master) [![Godoc](https://godoc.org/github.com/casbin/protobuf-adapter?status.svg)](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 main import ( "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.