options

package
v1.3.12-test13 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2022 License: MIT Imports: 7 Imported by: 1

Documentation

Overview

MIT License

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

MIT License

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

MIT License

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

MIT License

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

MIT License

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

MIT License

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

MIT License

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

MIT License

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

MIT License

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

MIT License

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

MIT License

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

MIT License

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

MIT License

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Index

Constants

View Source
const (
	SchemeBasic       = "basic"
	SchemeOAuth2      = "oauth2"
	SchemeCloudEntity = "cloudentity"
)
View Source
const MaxRetries uint32 = 255

Variables

This section is empty.

Functions

func StringToPtr added in v1.2.0

func StringToPtr(str string) *string

func ToCompactJSON added in v1.2.0

func ToCompactJSON(o interface{}) string

Types

type AuthOptions added in v1.1.0

type AuthOptions struct {
	// OPTIONAL
	OAuth2 *OAuth2 `json:"oauth2,omitempty" yaml:"oauth2,omitempty"`
	// OPTIONAL
	Custom *Custom `json:"custom,omitempty" yaml:"custom,omitempty"`
	// OPTIONAL
	Cloudentity *Cloudentity `json:"cloudentity,omitempty" yaml:"cloudentity,omitempty"`
}

AuthOptions example:

x-kusk:

...
auth:
  scheme: basic
  auth-upstream:
    path_prefix: /login # optional
    host:
      hostname: example.com
      port: 80

func (AuthOptions) String added in v1.2.0

func (o AuthOptions) String() string

func (AuthOptions) Validate added in v1.1.0

func (o AuthOptions) Validate() error

type AuthUpstreamHost added in v1.1.0

type AuthUpstreamHost struct {
	// REQUIRED.
	Hostname string `json:"hostname,omitempty" yaml:"hostname,omitempty"`
	// REQUIRED.
	Port uint32 `json:"port,omitempty" yaml:"port,omitempty"`
}

func (AuthUpstreamHost) Validate added in v1.1.0

func (o AuthUpstreamHost) Validate() error

type CORSOptions

type CORSOptions struct {
	Origins       []string `yaml:"origins,omitempty" json:"origins,omitempty"`
	Methods       []string `yaml:"methods,omitempty" json:"methods,omitempty"`
	Headers       []string `yaml:"headers,omitempty" json:"headers,omitempty"`
	ExposeHeaders []string `yaml:"expose_headers,omitempty" json:"expose_headers,omitempty"`

	Credentials *bool `yaml:"credentials,omitempty" json:"credentials,omitempty"`
	MaxAge      int   `yaml:"max_age,omitempty" json:"max_age,omitempty"`
}

func (*CORSOptions) DeepCopy

func (in *CORSOptions) DeepCopy() *CORSOptions

DeepCopy creates a copy of an object

func (CORSOptions) Validate

func (o CORSOptions) Validate() error

type CacheOptions added in v1.1.0

type CacheOptions struct {
	Enabled *bool `json:"enabled" yaml:"enabled"`
	MaxAge  *int  `json:"max_age" yaml:"max_age"`
}

func (CacheOptions) Validate added in v1.1.0

func (o CacheOptions) Validate() error

type ClientSecretRef added in v1.3.2

type ClientSecretRef struct {
	// REQUIRED.
	Name string `json:"name,omitempty" yaml:"name,omitempty"`
	// REQUIRED.
	Namespace string `json:"namespace,omitempty" yaml:"namespace,omitempty"`
}

func (ClientSecretRef) String added in v1.3.2

func (o ClientSecretRef) String() string

func (ClientSecretRef) Validate added in v1.3.2

func (o ClientSecretRef) Validate() error

type Cloudentity added in v1.3.5

type Cloudentity struct {
	// REQUIRED.
	Host AuthUpstreamHost `json:"host,omitempty" yaml:"host,omitempty"`
	// OPTIONAL.
	PathPrefix *string `json:"path_prefix,omitempty" yaml:"path_prefix,omitempty"`
}

func (Cloudentity) String added in v1.3.5

func (o Cloudentity) String() string

func (Cloudentity) Validate added in v1.3.5

func (o Cloudentity) Validate() error

type CookieNames added in v1.2.0

type CookieNames struct {
	// Defaults to BearerToken.
	BearerToken string `json:"bearer_token,omitempty" yaml:"bearer_token,omitempty"`
	// Defaults to OauthHMAC.
	OauthHMAC string `json:"oauth_hmac,omitempty" yaml:"oauth_hmac,omitempty"`
	// Defaults to OauthExpires.
	ExpiresOauth string `json:"oauth_expires,omitempty" yaml:"oauth_expires,omitempty"`
}

CookieNames - By default, OAuth2 filter sets some cookies with the following names: BearerToken, OauthHMAC, and OauthExpires. These cookie names can be customized by setting cookie_names.

func (CookieNames) Validate added in v1.2.0

func (o CookieNames) Validate() error

type Credentials added in v1.2.0

type Credentials struct {
	// REQUIRED.
	ClientID string `json:"client_id,omitempty" yaml:"client_id,omitempty"`
	// REQUIRED, if `client_secret_ref` is not set, i.e., mutually exclusive with `client_secret_ref`.
	ClientSecret *string `json:"client_secret,omitempty" yaml:"client_secret,omitempty"`
	// REQUIRED, if `client_secret` is not set, i.e., mutually exclusive with `client_secret`.
	ClientSecretRef *ClientSecretRef `json:"client_secret_ref,omitempty" yaml:"client_secret_ref,omitempty"`
	// OPTIONAL.
	HmacSecret string `json:"hmac_secret,omitempty" yaml:"hmac_secret,omitempty"`
	// OPTIONAL.
	CookieNames CookieNames `json:"cookie_names,omitempty" yaml:"cookie_names,omitempty"`
}

func (Credentials) String added in v1.3.2

func (o Credentials) String() string

func (Credentials) Validate added in v1.2.0

func (o Credentials) Validate() error

type Custom added in v1.3.5

type Custom struct {
	// REQUIRED.
	Host AuthUpstreamHost `json:"host,omitempty" yaml:"host,omitempty"`
	// OPTIONAL.
	PathPrefix *string `json:"path_prefix,omitempty" yaml:"path_prefix,omitempty"`
}

func (Custom) String added in v1.3.5

func (o Custom) String() string

func (Custom) Validate added in v1.3.5

func (o Custom) Validate() error

type HTTPMethod

type HTTPMethod string

HTTPMethod defines HTTP Method like GET, POST...

type Host

type Host string

Host is a vHost (and domain name) definition that is used during request routing. Could be wildcard ("*" - all vhosts), prefix/suffix wildcard (*-example.com, example.*, but not both *example*), or simple domain (www.example.com)

func (Host) Validate

func (h Host) Validate() error

type MockingOptions

type MockingOptions struct {
	Enabled *bool `json:"enabled" yaml:"enabled"`
}

func (MockingOptions) Validate

func (o MockingOptions) Validate() error

type OAuth2 added in v1.2.0

type OAuth2 struct {
	// Endpoint on the authorization server to retrieve the access token from.
	// REQUIRED.
	TokenEndpoint string `json:"token_endpoint,omitempty" yaml:"token_endpoint,omitempty"`
	// The endpoint redirect to for authorization in response to unauthorized requests.
	// REQUIRED.
	AuthorizationEndpoint string `json:"authorization_endpoint,omitempty" yaml:"authorization_endpoint,omitempty"`
	// Credentials used for OAuth.
	// REQUIRED.
	Credentials Credentials `json:"credentials,omitempty" yaml:"credentials,omitempty"`
	// The redirect URI passed to the authorization endpoint. Supports header formatting tokens.
	// REQUIRED.
	RedirectURI string `json:"redirect_uri,omitempty" yaml:"redirect_uri,omitempty"`
	// Matching criteria used to determine whether a path appears to be the result of a redirect from the authorization server.
	// REQUIRED.
	RedirectPathMatcher string `json:"redirect_path_matcher,omitempty" yaml:"redirect_path_matcher,omitempty"`
	// The path to sign a user out, clearing their credential cookies.
	// REQUIRED.
	SignoutPath string `json:"signout_path,omitempty" yaml:"signout_path,omitempty"`
	// Forward the OAuth token as a Bearer to upstream web service.
	// When the authn server validates the client and returns an authorization token back to the OAuth filter, no matter what format that token is, if forward_bearer_token is set to true the filter will send over a cookie named BearerToken to the upstream. Additionally, the Authorization header will be populated with the same value.
	// REQUIRED.
	ForwardBearerToken bool `json:"forward_bearer_token,omitempty" yaml:"forward_bearer_token,omitempty"`
	// Optional list of OAuth scopes to be claimed in the authorization request.
	// If not specified, defaults to “user” scope. OAuth RFC https://tools.ietf.org/html/rfc6749#section-3.3.
	// OPTIONAL.
	AuthScopes []string `json:"auth_scopes,omitempty" yaml:"auth_scopes,omitempty"`
	// Optional resource parameter for authorization request RFC: https://tools.ietf.org/html/rfc8707.
	// OPTIONAL.
	Resources []string `json:"resources,omitempty" yaml:"resources,omitempty"`
}

func (OAuth2) String added in v1.2.0

func (o OAuth2) String() string

func (OAuth2) Validate added in v1.2.0

func (o OAuth2) Validate() error

type Options

type Options struct {
	// Top root of the configuration (top x-kusk settings) provides configuration for all paths/methods
	// Overrides per method+path are in OperationFinalSubOptions map
	SubOptions
	// Host (Host header) to serve for
	// Multiple are possible
	// Hosts are not overridable per path/method intentionally since
	// there is no valid use case for such override per path in the same OpenAPI config
	Hosts []Host `yaml:"hosts,omitempty" json:"hosts,omitempty"`

	// OperationFinalSubOptions is the map of method+path key with value - merged root suboptions + path suboptions + operation suboptions
	// They are filled during the parsing of OpenAPI with extension
	OperationFinalSubOptions map[string]SubOptions `yaml:"-" json:"-"`
}

Options is the container for all parsed from the supplied configuration OpenAPI x-kusk options and any additional options

func (*Options) FillDefaults

func (o *Options) FillDefaults()

func (Options) Validate

func (o Options) Validate() error

type PathOptions

type PathOptions struct {
	// Prefix is the preceding prefix for the route (i.e. /your-prefix/here/rest/of/the/route).
	Prefix string `yaml:"prefix,omitempty" json:"prefix,omitempty"`
}

func (PathOptions) Validate

func (o PathOptions) Validate() error

type QoSOptions

type QoSOptions struct {
	// Retries define how many times to retry calling the backend
	Retries uint32 `yaml:"retries,omitempty" json:"retries,omitempty"`
	// RequestTimeout is total request timeout
	RequestTimeout uint32 `yaml:"request_timeout,omitempty" json:"request_timeout,omitempty"`
	// IdleTimeout is timeout for idle connection
	IdleTimeout uint32 `yaml:"idle_timeout,omitempty" json:"idle_timeout,omitempty"`
}

func (QoSOptions) Validate

func (o QoSOptions) Validate() error

type RateLimitOptions

type RateLimitOptions struct {
	RequestsPerUnit uint32 `json:"requests_per_unit,omitempty" yaml:"requests_per_unit,omitempty"`
	Unit            string `json:"unit,omitempty" yaml:"unit,omitempty"`
	PerConnection   bool   `json:"per_connection,omitempty" yaml:"per_connection,omitempty"`
	ResponseCode    uint32 `yaml:"response_code,omitempty" json:"response_code,omitempty"`
}

func (RateLimitOptions) Validate

func (o RateLimitOptions) Validate() error

type RedirectOptions

type RedirectOptions struct {
	// http|https
	SchemeRedirect string `yaml:"scheme_redirect,omitempty" json:"scheme_redirect,omitempty"`

	HostRedirect string `yaml:"host_redirect,omitempty" json:"host_redirect,omitempty"`
	PortRedirect uint32 `yaml:"port_redirect,omitempty" json:"port_redirect,omitempty"`

	// mutually exclusive with rewrite regex redirect
	PathRedirect string `yaml:"path_redirect,omitempty" json:"path_redirect,omitempty"`
	// mutually exclusive with path redirect
	RewriteRegex *RewriteRegex `yaml:"rewrite_regex,omitempty" json:"rewrite_regex,omitempty"`

	ResponseCode uint32 `yaml:"response_code,omitempty" json:"response_code,omitempty"`
	StripQuery   *bool  `yaml:"strip_query,omitempty" json:"strip_query,omitempty"`
}

RedirectOptions provide http redirects see https://www.envoyproxy.io/docs/envoy/latest/api-v3/config/route/v3/route_components.proto#envoy-v3-api-msg-config-route-v3-redirectaction

func (*RedirectOptions) DeepCopy

func (in *RedirectOptions) DeepCopy() *RedirectOptions

DeepCopy is used to copy

func (RedirectOptions) MutuallyExlusivePathRedirectCheck

func (o RedirectOptions) MutuallyExlusivePathRedirectCheck(value interface{}) error

MutuallyExclusivePathRedirectCheck returns error if both path redirect and regex substitution redirect are enabled

func (RedirectOptions) Validate

func (o RedirectOptions) Validate() error

type RequestValidationOptions

type RequestValidationOptions struct {
	Enabled *bool `json:"enabled,omitempty" yaml:"enabled,omitempty"`
}

type RewriteRegex

type RewriteRegex struct {
	Pattern      string `yaml:"pattern,omitempty" json:"pattern"`
	Substitution string `yaml:"substitution,omitempty" json:"substitution"`
}

RewriteRegex is used during the redirects and paths mangling

func (RewriteRegex) Validate

func (r RewriteRegex) Validate() error

type StaticOperationSubOptions

type StaticOperationSubOptions map[HTTPMethod]*SubOptions

StaticOperationSubOptions maps method (get, post) to related static subopts

type StaticOptions

type StaticOptions struct {
	// Host (Host header) to serve for.
	// Multiple are possible. Each Host creates Envoy's Virtual Host with Domains set to only that Host and routes specified in config.
	// I.e. multiple hosts - multiple vHosts with Domains=Host and with the same routes.
	// Note on Host header matching in Envoy:
	/* courtesy of @hzxuzhonghu (https://github.com/istio/istio/issues/35826#issuecomment-957184380)
	The virtual hosts order does not influence the domain matching order
	It is the domain matters
	Domain search order:
	1. Exact domain names: www.foo.com.
	2. Suffix domain wildcards: *.foo.com or *-bar.foo.com.
	3. Prefix domain wildcards: foo.* or foo-*.
	4. Special wildcard * matching any domain. (edited)
	*/
	Hosts []Host

	// Paths allow to specify a specific set of option for a given path and a method.
	// This is a 2-dimensional map[path][method].
	// The map key is the path and the next map key is a HTTP method (operation).
	// This closely follows OpenAPI structure, but was chosen only due to the only way to specify different routing action for
	// different methods in one YAML document.
	// E.g. if GET / goes to frontend, and POST / goes to API, you cannot specify path as a key with the different methods twice in one YAML file.
	Paths map[string]StaticOperationSubOptions `yaml:"-" json:"-"`
}

StaticOptions define options for single routing config - domain names to use and path to setup routes for.

func (*StaticOptions) FillDefaultsAndValidate

func (o *StaticOptions) FillDefaultsAndValidate() error

func (StaticOptions) Validate

func (o StaticOptions) Validate() error

type SubOptions

type SubOptions struct {
	Disabled *bool `yaml:"disabled,omitempty" json:"disabled,omitempty"`
	// Upstream is a set of options of a target service to receive traffic.
	Upstream *UpstreamOptions `yaml:"upstream,omitempty" json:"upstream,omitempty"`
	// Redirect specifies thre redirect optins, mutually exclusive with Upstream
	Redirect *RedirectOptions `yaml:"redirect,omitempty" json:"redirect,omitempty"`
	// Path is a set of options to configure service endpoints paths.
	Path          *PathOptions       `yaml:"path,omitempty" json:"path,omitempty"`
	QoS           *QoSOptions        `yaml:"qos,omitempty" json:"qos,omitempty"`
	CORS          *CORSOptions       `yaml:"cors,omitempty" json:"cors,omitempty"`
	Websocket     *bool              `json:"websocket,omitempty" yaml:"websocket,omitempty"`
	Validation    *ValidationOptions `json:"validation,omitempty" yaml:"validation,omitempty"`
	Mocking       *MockingOptions    `json:"mocking,omitempty" yaml:"mocking,omitempty"`
	RateLimit     *RateLimitOptions  `json:"rate_limit,omitempty" yaml:"rate_limit,omitempty"`
	Cache         *CacheOptions      `json:"cache,omitempty" yaml:"cache,omitempty"`
	PublicAPIPath string             `json:"public_api_path,omitempty" yaml:"public-api-path,omitempty"`
	Auth          *AuthOptions       `json:"auth,omitempty" yaml:"auth,omitempty"`
}

SubOptions allow user to overwrite certain options at path/operation level using x-kusk extension

func (*SubOptions) MergeInSubOptions

func (o *SubOptions) MergeInSubOptions(in *SubOptions)

MergeInSubOptions handles merging other SubOptions (usually - upper level in root/path/method hierarchy)

func (SubOptions) Validate

func (o SubOptions) Validate() error

type UpstreamHost

type UpstreamHost struct {
	// Hostname is the upstream hostname, without port.
	Hostname string `yaml:"hostname" json:"hostname"`

	// Port is the upstream port.
	Port uint32 `yaml:"port" json:"port"`
}

UpstreamHost defines any DNS hostname with port that we can proxy to, even outside of the cluster

func (UpstreamHost) Validate

func (o UpstreamHost) Validate() error

type UpstreamOptions

type UpstreamOptions struct {
	Host    *UpstreamHost    `yaml:"host,omitempty" json:"host,omitempty"`
	Service *UpstreamService `yaml:"service,omitempty" json:"service,omitempty"`

	// Rewrite is the pattern (regex) and a substitution string that will change URL when request is being forwarded
	// to the upstream service.
	// e.g. given that Prefix is set to "/petstore/api/v3", and with
	// Rewrite.Pattern is set to "^/petstore", Rewrite.Substitution is set to ""
	// path that would be generated is "/petstore/api/v3/pets", URL that the upstream service would receive
	// is "/api/v3/pets".
	Rewrite RewriteRegex `yaml:"rewrite,omitempty" json:"rewrite,omitempty"`
}

UpstreamOptions defines upstream that we proxy to Host and Service are mutually exclusive

func (*UpstreamOptions) DeepCopy

func (in *UpstreamOptions) DeepCopy() *UpstreamOptions

DeepCopy creates a copy of an object

func (*UpstreamOptions) FillDefaults added in v1.0.1

func (o *UpstreamOptions) FillDefaults()

func (UpstreamOptions) Validate

func (o UpstreamOptions) Validate() error

type UpstreamService

type UpstreamService struct {
	// Name is the upstream K8s Service's name.
	Name string `yaml:"name" json:"name,omitempty"`

	// Namespace where service is located
	Namespace string `yaml:"namespace" json:"namespace"`

	// Port is the upstream K8s Service's port.
	Port uint32 `yaml:"port" json:"port"`
}

UpstreamService defines K8s Service in the cluster

func (*UpstreamService) FillDefaults added in v1.0.1

func (o *UpstreamService) FillDefaults()

func (UpstreamService) Validate

func (o UpstreamService) Validate() error

type ValidationOptions

type ValidationOptions struct {
	Request *RequestValidationOptions `json:"request,omitempty" yaml:"request,omitempty"`
}

Jump to

Keyboard shortcuts

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