rules

package
v0.1.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 22, 2025 License: Apache-2.0 Imports: 0 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Groups

type Groups []string

Groups is a string list, preferably a string set.

func (Groups) Test

func (groups Groups) Test(rule Rule, more ...Rule) bool

Test verifies that the user's groups satisfy the membership rules.

Use AllOf and/or OneOf to describe how to authorise the user's groups.

Usage:

// user must be able to read both payments and inventory.
Groups([]string{...}).Test(AllOf("can_read_payment", "can_read_inventory"))

// user must be able to read both payments and inventory, but write permissions implies read as well.
Groups([]string{...}).Test(OneOf("can_read_payment", "can_write_payment"), OneOf("can_read_inventory", "can_write_inventory"))

type Rule

type Rule func(*rules)

Rule can only be either AllOf or OneOf.

func AllOf

func AllOf(group string, more ...string) Rule

AllOf adds a rule that the user must belong to all the groups specified here.

func OneOf

func OneOf(first, second string, more ...string) Rule

OneOf adds a rule that the user must belong to at least one of the groups specified here.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL