envoyauth

package
v0.31.0-envoy Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2021 License: Apache-2.0 Imports: 27 Imported by: 1

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{}, logEntry *logrus.Entry, protoSet *protoregistry.Files) (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)
}

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
}

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

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) GetResponseHTTPStatus

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

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

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

Jump to

Keyboard shortcuts

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