Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/flowerinthenight/casbin-spanner-adapter
Casbin adapter for Cloud Spanner.
https://github.com/flowerinthenight/casbin-spanner-adapter
access-control casbin cloud-spanner gcp golang rbac spanner
Last synced: 2 days ago
JSON representation
Casbin adapter for Cloud Spanner.
- Host: GitHub
- URL: https://github.com/flowerinthenight/casbin-spanner-adapter
- Owner: flowerinthenight
- License: apache-2.0
- Created: 2021-06-16T11:54:53.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2025-01-08T02:46:38.000Z (3 days ago)
- Last Synced: 2025-01-08T03:26:49.158Z (3 days ago)
- Topics: access-control, casbin, cloud-spanner, gcp, golang, rbac, spanner
- Language: Go
- Homepage:
- Size: 167 KB
- Stars: 0
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[![main](https://github.com/flowerinthenight/casbin-spanner-adapter/actions/workflows/main.yml/badge.svg)](https://github.com/flowerinthenight/casbin-spanner-adapter/actions/workflows/main.yml)
This library implements a [Casbin](https://casbin.org/) [adapter](https://casbin.org/docs/adapters) for [Cloud Spanner](https://cloud.google.com/spanner).
To install:
```sh
$ go get github.com/flowerinthenight/casbin-spanner-adapter
```Example usage:
```go
package mainimport (
"flag"
"log"
"time""github.com/casbin/casbin/v2"
spanneradapter "github.com/flowerinthenight/casbin-spanner-adapter"
)func main() {
a, _ := spanneradapter.NewAdapter(
"projects/{v}/instances/{v}/databases/{v}",
spanneradapter.WithSkipDatabaseCreation(true),
)e, _ := casbin.NewEnforcer("rbac_model.conf", a)
// Load stored policy from database.
e.LoadPolicy()// Do permission checking.
e.Enforce("alice", "data1", "write")// Do some mutations.
e.AddPolicy("alice", "data2", "write")
e.RemovePolicy("alice", "data1", "write")// Persist policy to database.
e.SavePolicy()
}
```