The Wayback Machine - https://web.archive.org/web/20190322180508/https://github.com/codercom/perms
Skip to content
Please note that GitHub no longer supports Internet Explorer.

We recommend upgrading to the latest Microsoft Edge, Google Chrome, or Firefox.

Learn more
This repository has been archived by the owner. It is now read-only.
A Golang permissions system
Branch: master
Clone or download
Cannot retrieve the latest commit at this time.
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
whitespace add whitespace strip Nov 11, 2016
.gitignore
README.md
group.go
group_test.go add master pconf from web Nov 14, 2016
node.go
node_bench_test.go
node_test.go
nodes.go
nodes_bench_test.go improve WithoutDuplicates perf Sep 8, 2017
nodes_test.go
user.go add master pconf from web Nov 14, 2016
user_test.go add master pconf from web Nov 14, 2016

README.md

Perms

An extremely flexible permissions system

Table of Contents

Nodes

A permission node grants a particular kind of access to a resource.

It should be formatted as follows

[-]<resource>[.<sub_resource>...].<verb>

The following are examples of good nodes

  • projects.webserver.build
  • projects.webserver.chat.use
  • projects.webserver.chat.moderate

Important Considerations

  • Nodes are case sensitive
  • Only runes within UTF8 0x21 to 0x7e are allowed.
  • Whitespaces are not allowed

Wildcards

An asterisk or * may be used to signify a wildcard match.

The * node would match every permission.

The projects.* node would match for

  • projects.*
  • projects.webserver.test
  • etc.

The projects.*.chat.use node would match for

  • projects.webserver.chat.use
  • projects.database.chat.use
  • projects.client.chat.use

The match isn't bidirectional. projects.use does not match *.

Negations

A - prefixing a node signifies it's negated. Negation will be only be overwritten if the user has the node explicitely defined. If the negation lies directly on the user, it must be removed for the user to have access to the permission.

if Bob has

  • *
  • -projects.*

He has access to

  • billing.budget.manage

But not

  • projects.webserver.use

List

The standard way to list nodes is to delimit them with whitespace. Redudent whitespaces are ignored.

The following lists are functionally identitical.

projects.publish projects.manage
projects.publish
projects.manage

use ParseNodes() to parse a list of nodes.

Nodes.String() return a newline delimited string of nodes.

You can’t perform that action at this time.