attribute

package
v0.8.3 Latest Latest
Warning

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

Go to latest
Published: May 8, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	// ErrInvalidRuleFormat is returned when a rule format is invalid.
	ErrInvalidRuleFormat = errors.New("rule is invalid: should have at least one resource.<attribute> or a principal.<attribute>")
)

Functions

This section is empty.

Types

type Rule

type Rule struct {
	ResourceAttribute  string       `json:"resource_attribute"`
	PrincipalAttribute string       `json:"principal_attribute"`
	Operator           RuleOperator `json:"operator"`
	Value              string       `json:"Value"`
}

Rule represents an attribute rule containing the attribute name and the operator to apply to a given value.

func ConvertStringToRuleOperator

func ConvertStringToRuleOperator(ruleStr string) (*Rule, error)

ConvertStringToRuleOperator converts a string to a RuleOperator.

func (*Rule) MatchPrincipal

func (r *Rule) MatchPrincipal(attributes model.Attributes) bool

func (*Rule) MatchResource

func (r *Rule) MatchResource(attributes model.Attributes) bool

func (*Rule) ToString

func (r *Rule) ToString() string

ToString converts the rule structure to string.

type RuleOperator

type RuleOperator string
const (
	// RuleOperatorEqual represents an equal attribute rule.
	// For example: my.owner_id == 123
	RuleOperatorEqual RuleOperator = "=="

	// RuleOperatorGreater represents a greater value attribute rule.
	// For example: my.number > 123
	RuleOperatorGreater RuleOperator = ">"

	// RuleOperatorGreater represents a greater or equal value attribute rule.
	// For example: my.number >= 123
	RuleOperatorGreaterEqual RuleOperator = ">="

	// RuleOperatorLower represents a lower value attribute rule.
	// For example: my.number < 123
	RuleOperatorLower RuleOperator = "<"

	// RuleOperatorLowerEqual represents a lower or equal value attribute rule.
	// For example: my.number <= 123
	RuleOperatorLowerEqual RuleOperator = "<="

	// RuleOperatorEqual represents a NOT equal attribute rule.
	// For example: my.owner_id != 123
	RuleOperatorNotEqual RuleOperator = "!="
)

Jump to

Keyboard shortcuts

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