Documentation ¶
Index ¶
- func Eval(ctx context.Context, evalContext EvalContext, input ast.Value, ...) error
- func NewEvalResult() (*EvalResult, StopFunc, error)
- func RequestToInput(req interface{}, logger logging.Logger, protoSet *protoregistry.Files, ...) (map[string]interface{}, error)
- type EvalContext
- type EvalResult
- func (result *EvalResult) GetRequestHTTPHeadersToRemove() ([]string, error)
- func (result *EvalResult) GetResponseBody() (string, error)
- func (result *EvalResult) GetResponseEnvoyHTTPStatus() (*ext_type_v3.HttpStatus, error)
- func (result *EvalResult) GetResponseEnvoyHeaderValueOptions() ([]*ext_core_v3.HeaderValueOption, error)
- func (result *EvalResult) GetResponseHTTPHeaders() (http.Header, error)
- func (result *EvalResult) GetResponseHTTPHeadersToAdd() ([]*ext_core_v3.HeaderValueOption, error)
- func (result *EvalResult) GetResponseHTTPStatus() (int, error)
- func (result *EvalResult) GetTxn(ctx context.Context, store storage.Store) (storage.Transaction, TransactionCloser, error)
- func (result *EvalResult) HasResponseBody() bool
- func (result *EvalResult) IsAllowed() (bool, error)
- type StopFunc
- type TransactionCloser
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 ¶
func (result *EvalResult) GetTxn(ctx context.Context, store storage.Store) (storage.Transaction, TransactionCloser, error)
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