rules

package
v0.5.4 Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2026 License: AGPL-3.0 Imports: 5 Imported by: 0

Documentation

Overview

Package rules contains all rules related logic.

Index

Constants

View Source
const NoMatchingRuleIndex = -1

NoMatchingRuleIndex is the rule index used when no rule matched and the default policy was applied.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthorizationResult added in v0.5.2

type AuthorizationResult struct {
	Allowed         bool
	RuleIndex       int
	Action          string
	IsDefaultPolicy bool
}

AuthorizationResult contains the result of an authorization check with metadata. RuleIndex is NoMatchingRuleIndex if the default policy was used.

func NewAuthorizationResult added in v0.5.2

func NewAuthorizationResult(ruleIndex int, action string) AuthorizationResult

NewAuthorizationResult creates a new AuthorizationResult from a rule index and action.

type Engine

type Engine struct {
	// contains filtered or unexported fields
}

Engine is the access control engine that checks if a given query is allowed by the rules.

func NewEngine

func NewEngine(config *config.AccessControl) *Engine

NewEngine creates a new access control engine for the given access control configuration.

func (*Engine) Authorize

func (e *Engine) Authorize(query *Query) AuthorizationResult

Authorize checks if the given query is allowed by the engine's rules and returns detailed result including which rule matched.

func (*Engine) UpdateConfig

func (e *Engine) UpdateConfig(config *config.AccessControl)

UpdateConfig updates the engine's configuration with the given access control configuration.

type Query

type Query struct {
	RequestedDomain string
	RequestedMethod string
	SourceIP        netip.Addr
	SourceCountry   string
	SourceASN       uint32
}

Query represents a query to be checked by the access control engine.

Jump to

Keyboard shortcuts

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