Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/linzhengen/opa-rbac
Role-based access control (RBAC) with the Open Policy Agent.
https://github.com/linzhengen/opa-rbac
golang golang-library opa rego
Last synced: 7 days ago
JSON representation
Role-based access control (RBAC) with the Open Policy Agent.
- Host: GitHub
- URL: https://github.com/linzhengen/opa-rbac
- Owner: linzhengen
- License: apache-2.0
- Created: 2022-07-16T11:03:07.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2022-07-17T01:30:41.000Z (over 2 years ago)
- Last Synced: 2024-11-14T23:04:34.431Z (about 2 months ago)
- Topics: golang, golang-library, opa, rego
- Language: Go
- Homepage:
- Size: 71.3 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# opa-rbac
Role-based access control (RBAC) with the Open Policy Agent.
[![Test](https://github.com/linzhengen/opa-rbac/actions/workflows/test.yml/badge.svg)](https://github.com/linzhengen/opa-rbac/actions/workflows/test.yml)
[![golangci-lint](https://github.com/linzhengen/opa-rbac/actions/workflows/golangci-lint.yml/badge.svg)](https://github.com/linzhengen/opa-rbac/actions/workflows/golangci-lint.yml)## Usage
```go
package mainimport (
"context"
"fmt"
"github.com/linzhengen/opa-rbac"
)func main() {
var data = oparbac.Data{
UserRoles: map[string][]string{
"alice": {
"admin",
},
"bob": {
"employee",
},
"eve": {
"customer",
},
},
RoleGrants: map[string][]map[string]string{
"customer": {
{
"resource": "user.get",
},
},
"employee": {
{
"resource": "user.list",
},
},
},
}
input := oparbac.Input{User: "alice", Resource: "employee.get"}
fmt.Println(oparbac.Allowed(context.TODO(), data, input))
}
```