permissions

package
v0.0.0-...-d931726 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2024 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package permissions provides functionalities to calculate, update and merge arrays of permission domain rules.

Read this to get more information about how permission domains and rules are working: https://github.com/zekroTJA/shinpuru/wiki/Permissions-Guide

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type PermissionArray

type PermissionArray []string

PermissionArray describes a set of permission rules.

Example:

+sp.guild.config.*
+sp.*
+sp.guild.*
-sp.guild.mod.ban
+sp.etc.*
+sp.chat.*

func (PermissionArray) Check

func (p PermissionArray) Check(domainName string) bool

Check returns true if the passed domainName matches positively on the permission array p.

func (PermissionArray) Equals

func (p PermissionArray) Equals(p2 PermissionArray) bool

Equals returns true when p2 has the same elements in the same order as p.

func (PermissionArray) Merge

func (p PermissionArray) Merge(newPerms PermissionArray, override bool) PermissionArray

Merge updates all entries of p using Update one by one with all entries of newPerms. Parameter override is passed to the Update function.

A new permissions array is returned with the resulting permission rule set.

func (PermissionArray) Update

func (p PermissionArray) Update(newPerm string, override bool) (newPermsArray PermissionArray, changed bool)

Update "adds" the passed newPerm to the permission array p by merging the permissions and returns the result as new permission array.

This means, if p looks like following

+sp.guild.*
+sp.guild.mod.ban

and newPerm is '-sp.guild.mod.ban', the returned permission array will be

+sp.guild.*

Jump to

Keyboard shortcuts

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