Skip to content
This repository has been archived by the owner on Mar 14, 2023. It is now read-only.
/ grbac Public archive

Golang library implements RBAC (role-based access control)

License

Notifications You must be signed in to change notification settings

vadim-su/grbac

Repository files navigation

GRBAC Build Status Coverage Status GoDoc

GRBAC is a fast Golang library which provides a role-based access control.

The project is written with a focus on performance, minimalism, and a small number of abstractions.

Install

Run this command

go get -v github.com/deterok/grbac

or

go get -v gopkg.in/deterok/grbac.v1

Usage

// Create User role
roleU := NewRole("User")

// Add the permissions to the User role
roleU.Permit("CreateMsg")
roleU.Permit("ReadMsg")

// Create Admin role
roleA := NewRole("Admin")

// Add the permissions to the Admin role
roleA.Permit("EditMsg")
roleA.Permit("DelMsg")

// Set the parent
roleA.SetParent(roleU)

// Check the permissions
if roleA.IsAllowed("CreateMsg", "ReadMsg", "EditMsg", "DelMsg") {
	fmt.Println("All permissions are allowed for the Admin role!")
}

More examples in godoc

Contributing

Pull requests and stars are welcome. For bugs and feature requests, please create an issue.

License

Copyright (C) 2016, Vadim Suharnikov. Released under the MIT license.

About

Golang library implements RBAC (role-based access control)

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages