envoyauth

package
v0.0.0-...-ab11e36 Latest Latest
Warning

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

Go to latest
Published: May 5, 2023 License: Apache-2.0 Imports: 33 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Eval

func Eval(ctx context.Context, evalContext EvalContext, input ast.Value, result *EvalResult, opts ...func(*rego.Rego)) error

Eval - Evaluates an input against a provided EvalContext and yields result

func NewEvalResult

func NewEvalResult() (*EvalResult, StopFunc, error)

NewEvalResult creates a new EvalResult and a StopFunc that is used to stop the timer for metrics

func RequestToInput

func RequestToInput(req interface{}, logger logging.Logger, protoSet *protoregistry.Files, skipRequestBodyParse bool) (map[string]interface{}, error)

RequestToInput - Converts a CheckRequest in either protobuf 2 or 3 to an input map

Types

type EvalContext

type EvalContext interface {
	ParsedQuery() ast.Body
	Store() storage.Store
	Compiler() *ast.Compiler
	Runtime() *ast.Term
	PreparedQueryDoOnce() *sync.Once
	InterQueryBuiltinCache() iCache.InterQueryCache
	PreparedQuery() *rego.PreparedEvalQuery
	SetPreparedQuery(*rego.PreparedEvalQuery)
	Logger() logging.Logger
	Config() *config.Config
}

EvalContext - This is an SPI that has to be provided if the envoy external authorization is used from outside the plugin, i.e. as a Go module

type EvalResult

type EvalResult struct {
	Revision       string // Deprecated: Use `revisions` instead.
	Revisions      map[string]string
	DecisionID     string
	TxnID          uint64
	Decision       interface{}
	Metrics        metrics.Metrics
	Txn            storage.Transaction
	NDBuiltinCache builtins.NDBCache
}

EvalResult - Captures the result from evaluating a query against an input

func (*EvalResult) GetRequestHTTPHeadersToRemove

func (result *EvalResult) GetRequestHTTPHeadersToRemove() ([]string, error)

GetRequestHTTPHeadersToRemove - returns the http headers to remove from the original request before dispatching it to the upstream

func (*EvalResult) GetResponseBody

func (result *EvalResult) GetResponseBody() (string, error)

GetResponseBody returns the http body to return if they are part of the decision

func (*EvalResult) GetResponseEnvoyHTTPStatus

func (result *EvalResult) GetResponseEnvoyHTTPStatus() (*ext_type_v3.HttpStatus, error)

GetResponseEnvoyHTTPStatus returns the http status to return if they are part of the decision

func (*EvalResult) GetResponseEnvoyHeaderValueOptions

func (result *EvalResult) GetResponseEnvoyHeaderValueOptions() ([]*ext_core_v3.HeaderValueOption, error)

GetResponseEnvoyHeaderValueOptions - returns the http headers to return if they are part of the decision as envoy header value options

func (*EvalResult) GetResponseHTTPHeaders

func (result *EvalResult) GetResponseHTTPHeaders() (http.Header, error)

GetResponseHTTPHeaders - returns the http headers to return if they are part of the decision

func (*EvalResult) GetResponseHTTPHeadersToAdd

func (result *EvalResult) GetResponseHTTPHeadersToAdd() ([]*ext_core_v3.HeaderValueOption, error)

GetResponseHTTPHeadersToAdd - returns the http headers to send to the downstream client

func (*EvalResult) GetResponseHTTPStatus

func (result *EvalResult) GetResponseHTTPStatus() (int, error)

GetResponseHTTPStatus returns the http status to return if they are part of the decision

func (*EvalResult) GetTxn

GetTxn creates a read transaction suitable for the configured EvalResult object

func (*EvalResult) HasResponseBody

func (result *EvalResult) HasResponseBody() bool

HasResponseBody returns true if the decision defines a body (only true for structured decisions)

func (*EvalResult) IsAllowed

func (result *EvalResult) IsAllowed() (bool, error)

IsAllowed - Returns if the decision is representing an "allow" depending on the decision structure. Returns an error if the decision structure is invalid

type StopFunc

type StopFunc = func()

StopFunc should be called as soon as the evaluation is finished

type TransactionCloser

type TransactionCloser func(ctx context.Context, err error) error

TransactionCloser should be called to abort the transaction

Jump to

Keyboard shortcuts

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