Skip to content

linzhengen/opa-rbac

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

opa-rbac

Role-based access control (RBAC) with the Open Policy Agent.

Test golangci-lint

Usage

package main

import (
	"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))
}

About

Role-based access control (RBAC) with the Open Policy Agent.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published