apisecurity

package
v1.9.0 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2026 License: AGPL-3.0 Imports: 29 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const Feature = "api-security-v1"
View Source
const MaxBodyBytes = 131072

Variables

This section is empty.

Functions

func Discover

func Discover(path string) string

func LogJSON

func LogJSON(raw json.RawMessage) string

LogJSON validates the small metadata envelope again at the data-plane boundary; unknown fields and request values never enter the proto log.

func ValidPath

func ValidPath(path string) bool

Types

type Body

type Body struct {
	Required bool    `json:"required"`
	Schema   *Schema `json:"schema"`
}

type Discovery

type Discovery struct {
	Enabled    bool `json:"enabled"`
	SampleRate int  `json:"sampleRate"`
}

type Endpoint

type Endpoint struct {
	Method     string      `json:"method"`
	Path       string      `json:"path"`
	Parameters []Parameter `json:"parameters"`
	Body       *Body       `json:"body,omitempty"`
}

type Exception

type Exception struct {
	ID      string `json:"id"`
	Enabled bool   `json:"enabled"`
	Method  string `json:"method"`
	Path    string `json:"path"`
	Check   string `json:"check"`
	Reason  string `json:"reason"`
}

type GraphQLSettings

type GraphQLSettings struct {
	Mode             string   `json:"mode"`
	PathPrefixes     []string `json:"pathPrefixes"`
	MaxDepth         int      `json:"maxDepth"`
	MaxFields        int      `json:"maxFields"`
	MaxAliases       int      `json:"maxAliases"`
	MaxBatch         int      `json:"maxBatch"`
	MaxDocumentBytes int      `json:"maxDocumentBytes"`
	Introspection    bool     `json:"introspection"`
}

type ImportIssue

type ImportIssue struct {
	Location string `json:"location"`
	Code     string `json:"code"`
}

type Issue

type Issue struct {
	Check string `json:"check"`
	Code  string `json:"code"`
	Mode  string `json:"mode"`
}

type JWK

type JWK struct {
	Kid string `json:"kid"`
	Alg string `json:"alg"`
	Kty string `json:"kty"`
	N   string `json:"n,omitempty"`
	E   string `json:"e,omitempty"`
	Crv string `json:"crv,omitempty"`
	X   string `json:"x,omitempty"`
	Y   string `json:"y,omitempty"`
}

type JWTSettings

type JWTSettings struct {
	Mode                  string   `json:"mode"`
	Scope                 Scope    `json:"scope"`
	Issuer                string   `json:"issuer"`
	Audiences             []string `json:"audiences"`
	Algorithms            []string `json:"algorithms"`
	Keys                  []JWK    `json:"keys"`
	ClockToleranceSeconds int      `json:"clockToleranceSeconds"`
}

type Log

type Log struct {
	Template     string   `json:"template"`
	Source       string   `json:"source"`
	Issues       []Issue  `json:"issues"`
	ExceptionIDs []string `json:"exceptionIds"`
}

type Parameter

type Parameter struct {
	Name     string  `json:"name"`
	In       string  `json:"in"`
	Required bool    `json:"required"`
	Schema   *Schema `json:"schema"`
}

type Request

type Request struct {
	SiteID           string              `json:"site_id"`
	Version          string              `json:"version"`
	Method           string              `json:"method"`
	Path             string              `json:"path"`
	RawPath          string              `json:"raw_path"`
	Query            string              `json:"query"`
	JWTScoped        bool                `json:"jwt_scoped"`
	GraphQLScoped    bool                `json:"graphql_scoped"`
	Headers          map[string][]string `json:"headers"`
	Authorization    []string            `json:"authorization"`
	Body             []byte              `json:"body"`
	BodyTruncated    bool                `json:"body_truncated"`
	HeadersTruncated bool                `json:"headers_truncated"`
	PathAmbiguous    bool                `json:"path_ambiguous"`
}

Scope selection is shared with access authentication in Lua. Only the local agent socket accepts these fields; the version binds them to the plan.

type Result

type Result struct {
	Status int    `json:"status"`
	Error  string `json:"error,omitempty"`
	Log    *Log   `json:"log,omitempty"`
}

type Schema

type Schema struct {
	Type                 string             `json:"type"`
	Nullable             bool               `json:"nullable,omitempty"`
	Properties           map[string]*Schema `json:"properties,omitempty"`
	Required             []string           `json:"required,omitempty"`
	AdditionalProperties *bool              `json:"additionalProperties,omitempty"`
	Items                *Schema            `json:"items,omitempty"`
	Enum                 []any              `json:"enum,omitempty"`
	MinLength            *int               `json:"minLength,omitempty"`
	MaxLength            *int               `json:"maxLength,omitempty"`
	Minimum              *float64           `json:"minimum,omitempty"`
	Maximum              *float64           `json:"maximum,omitempty"`
	MinItems             *int               `json:"minItems,omitempty"`
	MaxItems             *int               `json:"maxItems,omitempty"`
}

type SchemaSettings

type SchemaSettings struct {
	Mode             string        `json:"mode"`
	UnknownEndpoints string        `json:"unknownEndpoints"`
	Endpoints        []Endpoint    `json:"endpoints"`
	Issues           []ImportIssue `json:"issues"`
}

type Scope

type Scope struct {
	Domains             []string `json:"domains,omitempty"`
	PathPrefixes        []string `json:"pathPrefixes,omitempty"`
	Extensions          []string `json:"extensions,omitempty"`
	ExcludePathPrefixes []string `json:"excludePathPrefixes,omitempty"`
}

type Settings

type Settings struct {
	Version    int             `json:"version"`
	Discovery  Discovery       `json:"discovery"`
	Schema     SchemaSettings  `json:"schema"`
	JWT        JWTSettings     `json:"jwt"`
	GraphQL    GraphQLSettings `json:"graphql"`
	Exceptions []Exception     `json:"exceptions"`
	// contains filtered or unexported fields
}

func Parse

func Parse(raw string) (*Settings, string, error)

Parse preserves the wire document's identity; the plan sends its digest, never a re-encoded configuration, to the data plane.

func (*Settings) Check

func (s *Settings) Check(ctx context.Context, req Request, now time.Time) Result

Jump to

Keyboard shortcuts

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