eval

package
v1.13.0 Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2024 License: MIT Imports: 35 Imported by: 0

Documentation

Index

Constants

View Source
const TokenRequestPrefix = "_tr_"

Variables

This section is empty.

Functions

func ApplyCustomLogs

func ApplyCustomLogs(httpCtx *hcl.EvalContext, bodies []hcl.Body, logger *logrus.Entry) logrus.Fields

func ApplyRequestContext

func ApplyRequestContext(httpCtx *hcl.EvalContext, body *hclsyntax.Body, req *http.Request) error

func ApplyResponseContext

func ApplyResponseContext(ctx *hcl.EvalContext, body *hclsyntax.Body, beresp *http.Response) error

func ApplyResponseHeaderOps

func ApplyResponseHeaderOps(httpCtx *hcl.EvalContext, body hcl.Body, headers ...http.Header) error

func ApplyResponseStatus

func ApplyResponseStatus(httpCtx *hcl.EvalContext, attr *hclsyntax.Attribute, beresp *http.Response) (int, error)

func EvalCustomLogFields

func EvalCustomLogFields(httpCtx *hcl.EvalContext, body *hclsyntax.Body) (cty.Value, error)

func GetBody

func GetBody(ctx *hcl.EvalContext, content *hclsyntax.Body) (string, string, error)

func IsReservedContextName

func IsReservedContextName(name string) bool

func IsUpgradeRequest

func IsUpgradeRequest(req *http.Request) bool

func IsUpgradeResponse

func IsUpgradeResponse(req *http.Request, res *http.Response) bool

func MapTokenResponse

func MapTokenResponse(evalCtx *hcl.EvalContext, name string)

func NewRawOrigin

func NewRawOrigin(u *url.URL) *url.URL

func SetBody

func SetBody(req *http.Request, body []byte)

SetBody creates a reader from the given bytes for the Body itself and the request GetBody method. Since the size is known the Content-Length will be configured too.

func SetGetBody

func SetGetBody(req *http.Request, bufferOpts buffer.Option, bodyLimit int64) error

SetGetBody determines if we have to buffer a request body for further processing. First the user has a related reference within a related options' context declaration. Additionally, the request body is nil or a NoBody-Type and the http method has no http-body restrictions like 'TRACE'.

func SetHeader

func SetHeader(val cty.Value, headerCtx http.Header)

func Value

func Value(ctx *hcl.EvalContext, exp hcl.Expression) (cty.Value, error)

Value is used to clone and modify the given expression if an expression would make use of undefined context variables. Effectively results in cty.NilVal or empty string value for template expression.

A common case would be accessing a deeper nested structure which MAY be incomplete. This replacement prevents returning unknown cty.Value's which could not be processed.

func ValueFromBodyAttribute

func ValueFromBodyAttribute(ctx *hcl.EvalContext, body *hclsyntax.Body, name string) (cty.Value, error)

ValueFromBodyAttribute lookups the given attribute from given hcl.Body and returns cty.NilVal if the attribute is not present.

Types

type Context

type Context struct {
	// contains filtered or unexported fields
}

func ContextFromRequest

func ContextFromRequest(req *http.Request) *Context

ContextFromRequest extracts the eval.Context implementation value from given request and returns a noop one as fallback.

func NewContext

func NewContext(srcBytes [][]byte, defaults *config.Defaults, environment string) *Context

func NewDefaultContext

func NewDefaultContext() *Context

func (*Context) Deadline

func (c *Context) Deadline() (deadline time.Time, ok bool)

func (*Context) Done

func (c *Context) Done() <-chan struct{}

func (*Context) Err

func (c *Context) Err() error

func (*Context) HCLContext

func (c *Context) HCLContext() *hcl.EvalContext

func (*Context) HCLContextSync

func (c *Context) HCLContextSync() *hcl.EvalContext

func (*Context) Value

func (c *Context) Value(key interface{}) interface{}

func (*Context) WithBeresp

func (c *Context) WithBeresp(beresp *http.Response, backendVal cty.Value) (*Context, string, cty.Value, cty.Value)

func (*Context) WithClientRequest

func (c *Context) WithClientRequest(req *http.Request) *Context

func (*Context) WithContext

func (c *Context) WithContext(ctx context.Context) context.Context

func (*Context) WithJWTSigningConfigs

func (c *Context) WithJWTSigningConfigs(configs map[string]*lib.JWTSigningConfig) *Context

WithJWTSigningConfigs initially sets up the lib.FnJWTSign function.

func (*Context) WithMemStore

func (c *Context) WithMemStore(store *cache.MemoryStore) *Context

func (*Context) WithOAuth2AC

func (c *Context) WithOAuth2AC(os []*config.OAuth2AC) *Context

WithOAuth2AC adds the OAuth2AC config structs.

func (*Context) WithOidcConfig

func (c *Context) WithOidcConfig(confs oidc.Configs) *Context

WithOidcConfig adds the OidcConfig config structs.

func (*Context) WithSAML

func (c *Context) WithSAML(s []*config.SAML) *Context

WithSAML initially set up the saml configuration.

type ContextMap

type ContextMap map[string]cty.Value

func (ContextMap) Merge

func (m ContextMap) Merge(other ContextMap) ContextMap

type ReadCloser

type ReadCloser struct {
	io.Reader
	// contains filtered or unexported fields
}

func NewReadCloser

func NewReadCloser(r io.Reader, c io.Closer) *ReadCloser

func (ReadCloser) Close

func (rc ReadCloser) Close() error

type SyncedVariables

type SyncedVariables struct {
	// contains filtered or unexported fields
}

func NewSyncedVariables

func NewSyncedVariables() *SyncedVariables

func (*SyncedVariables) Set

func (sv *SyncedVariables) Set(ctx context.Context, reqName string, bereqV, berespV cty.Value)

Set finalized cty req/resp pair.

func (*SyncedVariables) SetResp

func (sv *SyncedVariables) SetResp(beresp *http.Response)

func (*SyncedVariables) Sync

func (sv *SyncedVariables) Sync(vars map[string]cty.Value)

type ValueFunc

type ValueFunc interface {
	Value(*hcl.EvalContext, hcl.Expression) (cty.Value, hcl.Diagnostics)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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