config

package
v0.3.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	GuardEndpointEU = "https://guard.aikido.dev/"
	GuardEndpointUS = "https://guard.us.aikido.dev/"
	GuardEndpointME = "https://guard.me.aikido.dev/"
	RuntimeEndpoint = "https://runtime.aikido.dev/"
)
View Source
const (
	Version = "0.3.0"
)

Variables

View Source
var CollectAPISchema bool

Functions

func GetCloudConfigUpdatedAt

func GetCloudConfigUpdatedAt() time.Time

func GetMatchingBlockedIPKeys added in v0.3.0

func GetMatchingBlockedIPKeys(ip string) []string

GetMatchingBlockedIPKeys returns the keys of all blocked IP lists that match the given IP.

func GetMatchingMonitoredIPKeys added in v0.3.0

func GetMatchingMonitoredIPKeys(ip string) []string

GetMatchingMonitoredIPKeys returns the keys of all monitored IP lists that match the given IP.

func GetMatchingUserAgentKeys added in v0.3.0

func GetMatchingUserAgentKeys(userAgent string) []string

GetMatchingUserAgentKeys returns the keys of all user agent detail patterns that match the given user agent.

func Init

func Init(environmentConfig *aikido_types.EnvironmentConfigData, aikidoConfig *aikido_types.AikidoConfigData) error

Init initializes the configuration system, extracting region from token to determine default endpoint URL if not set. Returns an error if setting the log level fails.

func IsBlockingEnabled

func IsBlockingEnabled() bool

func IsCompiledWithZenGo added in v0.2.0

func IsCompiledWithZenGo() bool

IsCompiledWithZenGo returns true if the binary was compiled with zen-go toolexec.

func IsIPAllowed

func IsIPAllowed(ip string) bool

IsIPAllowed checks that the IP is allowed if the global allowed IP list is set. Private/local IP addresses are always allowed, even when an allow list is configured.

func IsIPBlocked

func IsIPBlocked(ip string) (bool, string)

IsIPBlocked function checks the cloud config mutex for blocked IP addresses.

func IsIPBypassed

func IsIPBypassed(ip string) bool

func IsMonitoredUserAgent added in v0.3.0

func IsMonitoredUserAgent(userAgent string) bool

IsMonitoredUserAgent returns true if the user agent matches the monitored regex.

func IsUserAgentBlocked

func IsUserAgentBlocked(userAgent string) (bool, string)

IsUserAgentBlocked returns true if we block (e.g. bot blocking), and a string with the reason why.

func IsUserBlocked

func IsUserBlocked(userID string) bool

func IsZenDisabled

func IsZenDisabled() bool

func IsZenLoaded

func IsZenLoaded() bool

func ResetWarnOnce added in v0.2.0

func ResetWarnOnce()

ResetWarnOnce resets the WarnIfNotProtected once guard.

func SetBlocking

func SetBlocking(blocking bool)

func SetUserBlocked

func SetUserBlocked(userID string)

func SetZenDisabled

func SetZenDisabled(disabled bool)

func SetZenLoaded

func SetZenLoaded(loaded bool)

func ShouldBlockHostname

func ShouldBlockHostname(hostname string) bool

func ShouldProtect

func ShouldProtect() bool

ShouldProtect returns true if protection should run. Protection runs when zen is not disabled AND has been loaded successfully.

func Uninit

func Uninit()

func UpdateServiceConfig

func UpdateServiceConfig(cloudConfig *aikido_types.CloudConfigData, blockListConfig *aikido_types.ListsConfigData)

func WarnIfNotProtected added in v0.2.0

func WarnIfNotProtected()

WarnIfNotProtected logs a warning once if zen.Protect() has not been called and Zen is not explicitly disabled. This helps customers notice when they have configured the middleware but forgotten to call zen.Protect().

Types

type Endpoint

type Endpoint struct {
	Method             string                    `json:"method"`
	Route              string                    `json:"route"`
	ForceProtectionOff bool                      `json:"forceProtectionOff"`
	Graphql            any                       `json:"graphql"`
	AllowedIPAddresses ipaddr.MatchList          `json:"allowedIPAddresses"`
	RateLimiting       aikido_types.RateLimiting `json:"rateLimiting"`
}

func GetEndpoints

func GetEndpoints() []Endpoint

type EndpointKey

type EndpointKey struct {
	Method string
	Route  string
}

type RateLimiting

type RateLimiting struct {
	Enabled        bool
	MaxRequests    int
	WindowSizeInMS int
}

type ServiceConfigData

type ServiceConfigData struct {
	ConfigUpdatedAt          time.Time
	Endpoints                []Endpoint
	BlockedUserIDs           map[string]bool
	BypassedIPs              ipaddr.MatchList
	AllowedIPs               map[string]ipaddr.MatchList
	BlockedIPs               map[string]ipaddr.MatchList
	MonitoredIPs             map[string]ipaddr.MatchList
	BlockedUserAgents        *regexp.Regexp
	MonitoredUserAgents      *regexp.Regexp
	UserAgentDetails         []UserAgentDetail
	Block                    bool
	BlockNewOutgoingRequests bool
	Domains                  []aikido_types.OutboundDomain
}

type UserAgentDetail added in v0.3.0

type UserAgentDetail struct {
	Key     string
	Pattern *regexp.Regexp
}

Jump to

Keyboard shortcuts

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