Go API Documentation

github.com/TykTechnologies/tyk/apidef

No package summary is available.

Package

Files: 7. Third party imports: 3. Imports from organisation: 2. Tests: 0. Benchmarks: 0.

Constants

const (
	NoAction	EndpointMethodAction	= "no_action"
	Reply		EndpointMethodAction	= "reply"

	UseBlob	SourceMode	= "blob"
	UseFile	SourceMode	= "file"

	RequestXML	RequestInputType	= "xml"
	RequestJSON	RequestInputType	= "json"

	OttoDriver	MiddlewareDriver	= "otto"
	PythonDriver	MiddlewareDriver	= "python"
	LuaDriver	MiddlewareDriver	= "lua"
	GrpcDriver	MiddlewareDriver	= "grpc"
	GoPluginDriver	MiddlewareDriver	= "goplugin"

	BodySource		IdExtractorSource	= "body"
	HeaderSource		IdExtractorSource	= "header"
	QuerystringSource	IdExtractorSource	= "querystring"
	FormSource		IdExtractorSource	= "form"

	ValueExtractor	IdExtractorType	= "value"
	XPathExtractor	IdExtractorType	= "xpath"
	RegexExtractor	IdExtractorType	= "regex"

	// For multi-type auth
	AuthTypeNone	AuthTypeEnum	= ""
	AuthToken	AuthTypeEnum	= "auth_token"
	CustomAuth	AuthTypeEnum	= "custom_auth"
	HMACKey		AuthTypeEnum	= "hmac_key"
	BasicAuthUser	AuthTypeEnum	= "basic_auth_user"
	JWTClaim	AuthTypeEnum	= "jwt_claim"
	OIDCUser	AuthTypeEnum	= "oidc_user"
	OAuthKey	AuthTypeEnum	= "oauth_key"
	UnsetAuth	AuthTypeEnum	= ""

	// For routing triggers
	All	RoutingTriggerOnType	= "all"
	Any	RoutingTriggerOnType	= "any"

	// Subscription Types
	GQLSubscriptionUndefined	SubscriptionType	= ""
	GQLSubscriptionWS		SubscriptionType	= "graphql-ws"
	GQLSubscriptionTransportWS	SubscriptionType	= "graphql-transport-ws"
	GQLSubscriptionSSE		SubscriptionType	= "sse"

	// TykInternalApiHeader - flags request as internal api looping request
	TykInternalApiHeader	= "x-tyk-internal"

	HeaderLocation		= "header"
	URLParamLocation	= "url-param"
	URLLocation		= "url"
	ExpirationTimeFormat	= "2006-01-02 15:04"

	Self			= "self"
	DefaultAPIVersionKey	= "x-api-version"
	HeaderBaseAPIID		= "x-tyk-base-api-id"

	AuthTokenType	= "authToken"
	JWTType		= "jwt"
	HMACType	= "hmac"
	BasicType	= "basic"
	CoprocessType	= "coprocess"
	OAuthType	= "oauth"
	// ExternalOAuthType holds configuration for an external OAuth provider.
	// Deprecated: ExternalOAuth support has been deprecated from 5.7.0.
	// To avoid any disruptions, we recommend that you use JSON Web Token (JWT) instead,
	// as explained in https://tyk.io/docs/basic-config-and-security/security/authentication-authorization/ext-oauth-middleware/.
	ExternalOAuthType	= "externalOAuth"
	// OIDCType holds configuration for OpenID Connect.
	// Deprecated: OIDC support has been deprecated from 5.7.0.
	// To avoid any disruptions, we recommend that you use JSON Web Token (JWT) instead,
	// as explained in https://tyk.io/docs/api-management/client-authentication/#integrate-with-openid-connect-deprecated.

	OIDCType	= "oidc"

	// OAuthAuthorizationTypeClientCredentials is the authorization type for client credentials flow.
	OAuthAuthorizationTypeClientCredentials	= "clientCredentials"
	// OAuthAuthorizationTypePassword is the authorization type for password flow.
	OAuthAuthorizationTypePassword	= "password"
)
const (
	GraphQLConfigVersionNone	GraphQLConfigVersion	= ""
	GraphQLConfigVersion1		GraphQLConfigVersion	= "1"
	GraphQLConfigVersion2		GraphQLConfigVersion	= "2"
	GraphQLConfigVersion3Preview	GraphQLConfigVersion	= "3-preview"
)
const (
	GraphQLEngineDataSourceKindREST		= "REST"
	GraphQLEngineDataSourceKindGraphQL	= "GraphQL"
	GraphQLEngineDataSourceKindKafka	= "Kafka"
)
const (
	// GraphQLExecutionModeProxyOnly is the mode in which the GraphQL Middleware doesn't evaluate the GraphQL request
	// In other terms, the GraphQL Middleware will not act as a GraphQL server in itself.
	// The GraphQL Middleware will (optionally) validate the request and leave the execution up to the upstream.
	GraphQLExecutionModeProxyOnly	GraphQLExecutionMode	= "proxyOnly"
	// GraphQLExecutionModeExecutionEngine is the mode in which the GraphQL Middleware will evaluate every request.
	// This means the Middleware will act as a independent GraphQL service which might delegate partial execution to upstreams.
	GraphQLExecutionModeExecutionEngine	GraphQLExecutionMode	= "executionEngine"
	// GraphQLExecutionModeSubgraph is the mode if the API is defined as a subgraph for usage in GraphQL federation.
	// It will basically act the same as an API in proxyOnly mode but can be used in a supergraph.
	GraphQLExecutionModeSubgraph	GraphQLExecutionMode	= "subgraph"
	// GraphQLExecutionModeSupergraph is the mode where an API is able to use subgraphs to build a supergraph in GraphQL federation.
	GraphQLExecutionModeSupergraph	GraphQLExecutionMode	= "supergraph"
)
const (
	Pass	HealthCheckStatus	= "pass"
	Fail				= "fail"
	Warn				= "warn"

	Component	HealthCheckComponentType	= "component"
	Datastore					= "datastore"
	System						= "system"
)
const (
	ResponseProcessorResponseBodyTransform	= "response_body_transform"
	// DefaultCacheTimeout is the default cache TTL in seconds if not specified for api and endpoint level caching
	DefaultCacheTimeout	int64	= 60
)
const (
	typeWhitelist	= 0
	typeBlacklist	= 1
	typeIgnore	= 2
)

Vars

var DefaultValidationRuleSet = ValidationRuleSet{
	&RuleUniqueDataSourceNames{},
	&RuleAtLeastEnableOneAuthSource{},
	&RuleValidateIPList{},
	&RuleValidateEnforceTimeout{},
	&RuleUpstreamAuth{},
}
var ErrAllAuthSourcesDisabled = "all auth sources are disabled for %s, at least one of header/cookie/query must be enabled"
var ErrDuplicateDataSourceName = errors.New("duplicate data source names are not allowed")
var ErrInvalidIPCIDR = "invalid IP/CIDR %q"
var ErrInvalidTimeoutValue = errors.New("invalid timeout value")
var (
	ErrMigrationNewVersioningEnabled = errors.New("not migratable - new versioning is already enabled")
)
var Schema string
var Template = template.New("").Funcs(map[string]interface{}{
	"jsonMarshal": func(v interface{}) (string, error) {
		bs, err := json.Marshal(v)
		return string(bs), err
	},
	"xmlMarshal": func(v interface{}) (string, error) {
		var err error
		var xmlValue []byte
		mv, ok := v.(mxj.Map)
		if ok {
			mxj.XMLEscapeChars(true)
			xmlValue, err = mv.Xml()
		} else {
			res, ok := v.(map[string]interface{})
			if ok {
				mxj.XMLEscapeChars(true)
				xmlValue, err = mxj.Map(res).Xml()
			} else {
				xmlValue, err = xml.MarshalIndent(v, "", "  ")
			}
		}

		return string(xmlValue), err
	},
})
var (
	// ErrMultipleUpstreamAuthEnabled is the error to be returned when multiple upstream authentication modes are configured.
	ErrMultipleUpstreamAuthEnabled	= errors.New("multiple upstream authentication modes not allowed")
	// ErrMultipleUpstreamOAuthAuthorizationType is the error to return when multiple OAuth authorization types are configured.
	ErrMultipleUpstreamOAuthAuthorizationType	= errors.New("multiple upstream OAuth authorization type not allowed")
	// ErrUpstreamOAuthAuthorizationTypeRequired is the error to return when OAuth authorization type is not specified.
	ErrUpstreamOAuthAuthorizationTypeRequired	= errors.New("upstream OAuth authorization type is required")
	// ErrInvalidUpstreamOAuthAuthorizationType is the error to return when configured OAuth authorization type is invalid.
	ErrInvalidUpstreamOAuthAuthorizationType	= errors.New("invalid OAuth authorization type")
)
var (
	// Deprecated: Use ErrClassicAPIExpected instead.
	ErrAPIMigrated				= errors.New("the supplied API definition is in Tyk classic format, please use OAS format for this API")
	ErrClassicAPIExpected			= errors.New("this API endpoint only supports Tyk Classic APIs; please use the appropriate Tyk OAS API endpoint")
	ErrAPINotMigrated			= errors.New("the supplied API definition is in OAS format, please use the Tyk classic format for this API")
	ErrOASGetForOldAPI			= errors.New("the requested API definition is in Tyk classic format, please use old api endpoint")
	ErrImportWithTykExtension		= errors.New("the import payload should not contain x-tyk-api-gateway")
	ErrPayloadWithoutTykExtension		= errors.New("the payload should contain x-tyk-api-gateway")
	ErrPayloadWithoutTykStreamingExtension	= errors.New("the payload should contain x-tyk-streaming")
	ErrAPINotFound				= errors.New("API not found")
	ErrMissingAPIID				= errors.New("missing API ID")
)
var err error
var httpClient = initHttpNotificationClient()
var log = logger.Get()
var xmlValue []byte

Types

APIDefinition

APIDefinition represents the configuration for a single proxied API and it's versions.

swagger:model

Field name Field type Comment
Id

model.ObjectID

No comment on field.
Name

string

No comment on field.
Expiration

string

No comment on field.
ExpirationTs

time.Time

No comment on field.
Slug

string

No comment on field.
ListenPort

int

No comment on field.
Protocol

string

No comment on field.
EnableProxyProtocol

bool

No comment on field.
APIID

string

No comment on field.
OrgID

string

No comment on field.
UseKeylessAccess

bool

No comment on field.
UseOauth2

bool

No comment on field.
ExternalOAuth

ExternalOAuth

No comment on field.
UseOpenID

bool

No comment on field.
OpenIDOptions

OpenIDOptions

No comment on field.
Oauth2Meta

struct { AllowedAccessTypes []osin.AccessRequestType `bson:"allowed_access_types" json:"allowed_access_types"` AllowedAuthorizeTypes []osin.AuthorizeRequestType `bson:"allowed_authorize_types" json:"allowed_authorize_types"` AuthorizeLoginRedirect string `bson:"auth_login_redirect" json:"auth_login_redirect"` }

No comment on field.
Auth

AuthConfig

No comment on field.
AuthConfigs

map[string]AuthConfig

No comment on field.
UseBasicAuth

bool

No comment on field.
BasicAuth

struct { DisableCaching bool `bson:"disable_caching" json:"disable_caching"` CacheTTL int `bson:"cache_ttl" json:"cache_ttl"` ExtractFromBody bool `bson:"extract_from_body" json:"extract_from_body"` BodyUserRegexp string `bson:"body_user_regexp" json:"body_user_regexp"` BodyPasswordRegexp string `bson:"body_password_regexp" json:"body_password_regexp"` }

No comment on field.
UseMutualTLSAuth

bool

No comment on field.
ClientCertificates

[]string

No comment on field.
UpstreamCertificates

map[string]string

UpstreamCertificates stores the domain to certificate mapping for upstream mutualTLS

UpstreamCertificatesDisabled

bool

UpstreamCertificatesDisabled disables upstream mutualTLS on the API

PinnedPublicKeys

map[string]string

PinnedPublicKeys stores the public key pinning details

CertificatePinningDisabled

bool

CertificatePinningDisabled disables public key pinning

EnableJWT

bool

No comment on field.
UseStandardAuth

bool

No comment on field.
UseGoPluginAuth

bool

No comment on field.
EnableCoProcessAuth

bool

No comment on field.
CustomPluginAuthEnabled

bool

No comment on field.
JWTSigningMethod

string

No comment on field.
JWTSource

string

No comment on field.
JWTJwksURIs

[]JWK

No comment on field.
JWTIdentityBaseField

string

No comment on field.
JWTClientIDBaseField

string

No comment on field.
JWTPolicyFieldName

string

No comment on field.
JWTDefaultPolicies

[]string

No comment on field.
JWTIssuedAtValidationSkew

uint64

No comment on field.
JWTExpiresAtValidationSkew

uint64

No comment on field.
JWTNotBeforeValidationSkew

uint64

No comment on field.
JWTSkipKid

bool

No comment on field.
Scopes

Scopes

No comment on field.
IDPClientIDMappingDisabled

bool

No comment on field.
JWTScopeToPolicyMapping

map[string]string

No comment on field.
JWTScopeClaimName

string

No comment on field.
NotificationsDetails

NotificationsManager

No comment on field.
EnableSignatureChecking

bool

No comment on field.
HmacAllowedClockSkew

float64

No comment on field.
HmacAllowedAlgorithms

[]string

No comment on field.
RequestSigning

RequestSigningMeta

No comment on field.
BaseIdentityProvidedBy

AuthTypeEnum

No comment on field.
VersionDefinition

VersionDefinition

No comment on field.
VersionData

VersionData

No comment on field.
UptimeTests

UptimeTests

No comment on field.
Proxy

ProxyConfig

No comment on field.
DisableRateLimit

bool

No comment on field.
DisableQuota

bool

No comment on field.
CustomMiddleware

MiddlewareSection

No comment on field.
CustomMiddlewareBundle

string

No comment on field.
CustomMiddlewareBundleDisabled

bool

No comment on field.
CacheOptions

CacheOptions

No comment on field.
SessionLifetimeRespectsKeyExpiration

bool

No comment on field.
SessionLifetime

int64

No comment on field.
Active

bool

No comment on field.
Internal

bool

No comment on field.
AuthProvider

AuthProviderMeta

No comment on field.
SessionProvider

SessionProviderMeta

No comment on field.
EventHandlers

EventHandlerMetaConfig

No comment on field.
EnableBatchRequestSupport

bool

No comment on field.
EnableIpWhiteListing

bool

No comment on field.
AllowedIPs

[]string

No comment on field.
EnableIpBlacklisting

bool

No comment on field.
BlacklistedIPs

[]string

No comment on field.
IPAccessControlDisabled

bool

No comment on field.
DontSetQuotasOnCreate

bool

No comment on field.
ExpireAnalyticsAfter

int64

No comment on field.
ResponseProcessors

[]ResponseProcessor

No comment on field.
CORS

CORSConfig

No comment on field.
Domain

string

No comment on field.
DomainDisabled

bool

No comment on field.
Certificates

[]string

No comment on field.
DoNotTrack

bool

No comment on field.
EnableContextVars

bool

No comment on field.
ConfigData

map[string]any

No comment on field.
ConfigDataDisabled

bool

No comment on field.
TagHeaders

[]string

No comment on field.
GlobalRateLimit

GlobalRateLimit

No comment on field.
StripAuthData

bool

No comment on field.
EnableDetailedRecording

bool

No comment on field.
GraphQL

GraphQLConfig

No comment on field.
AnalyticsPlugin

AnalyticsPluginConfig

No comment on field.
TagsDisabled

bool

Gateway segment tags

Tags

[]string

No comment on field.
IsOAS

bool

IsOAS is set to true when API has an OAS definition (created in OAS or migrated to OAS)

VersionName

string

No comment on field.
DetailedTracing

bool

No comment on field.
UpstreamAuth

UpstreamAuth

UpstreamAuth stores information about authenticating against upstream.

type APIDefinition struct {
	Id			model.ObjectID	`bson:"_id,omitempty" json:"id,omitempty" gorm:"primaryKey;column:_id"`
	Name			string		`bson:"name" json:"name"`
	Expiration		string		`bson:"expiration" json:"expiration,omitempty"`
	ExpirationTs		time.Time	`bson:"-" json:"-"`
	Slug			string		`bson:"slug" json:"slug"`
	ListenPort		int		`bson:"listen_port" json:"listen_port"`
	Protocol		string		`bson:"protocol" json:"protocol"`
	EnableProxyProtocol	bool		`bson:"enable_proxy_protocol" json:"enable_proxy_protocol"`
	APIID			string		`bson:"api_id" json:"api_id"`
	OrgID			string		`bson:"org_id" json:"org_id"`
	UseKeylessAccess	bool		`bson:"use_keyless" json:"use_keyless"`
	UseOauth2		bool		`bson:"use_oauth2" json:"use_oauth2"`
	ExternalOAuth		ExternalOAuth	`bson:"external_oauth" json:"external_oauth"`
	UseOpenID		bool		`bson:"use_openid" json:"use_openid"`
	OpenIDOptions		OpenIDOptions	`bson:"openid_options" json:"openid_options"`
	Oauth2Meta		struct {
		AllowedAccessTypes	[]osin.AccessRequestType	`bson:"allowed_access_types" json:"allowed_access_types"`
		AllowedAuthorizeTypes	[]osin.AuthorizeRequestType	`bson:"allowed_authorize_types" json:"allowed_authorize_types"`
		AuthorizeLoginRedirect	string				`bson:"auth_login_redirect" json:"auth_login_redirect"`
	}	`bson:"oauth_meta" json:"oauth_meta"`
	Auth		AuthConfig		`bson:"auth" json:"auth"`	// Deprecated: Use AuthConfigs instead.
	AuthConfigs	map[string]AuthConfig	`bson:"auth_configs" json:"auth_configs"`
	UseBasicAuth	bool			`bson:"use_basic_auth" json:"use_basic_auth"`
	BasicAuth	struct {
		DisableCaching		bool	`bson:"disable_caching" json:"disable_caching"`
		CacheTTL		int	`bson:"cache_ttl" json:"cache_ttl"`
		ExtractFromBody		bool	`bson:"extract_from_body" json:"extract_from_body"`
		BodyUserRegexp		string	`bson:"body_user_regexp" json:"body_user_regexp"`
		BodyPasswordRegexp	string	`bson:"body_password_regexp" json:"body_password_regexp"`
	}	`bson:"basic_auth" json:"basic_auth"`
	UseMutualTLSAuth	bool		`bson:"use_mutual_tls_auth" json:"use_mutual_tls_auth"`
	ClientCertificates	[]string	`bson:"client_certificates" json:"client_certificates"`

	// UpstreamCertificates stores the domain to certificate mapping for upstream mutualTLS
	UpstreamCertificates	map[string]string	`bson:"upstream_certificates" json:"upstream_certificates"`
	// UpstreamCertificatesDisabled disables upstream mutualTLS on the API
	UpstreamCertificatesDisabled	bool	`bson:"upstream_certificates_disabled" json:"upstream_certificates_disabled,omitempty"`

	// PinnedPublicKeys stores the public key pinning details
	PinnedPublicKeys	map[string]string	`bson:"pinned_public_keys" json:"pinned_public_keys"`
	// CertificatePinningDisabled disables public key pinning
	CertificatePinningDisabled	bool	`bson:"certificate_pinning_disabled" json:"certificate_pinning_disabled,omitempty"`

	EnableJWT				bool			`bson:"enable_jwt" json:"enable_jwt"`
	UseStandardAuth				bool			`bson:"use_standard_auth" json:"use_standard_auth"`
	UseGoPluginAuth				bool			`bson:"use_go_plugin_auth" json:"use_go_plugin_auth"`		// Deprecated. Use CustomPluginAuthEnabled instead.
	EnableCoProcessAuth			bool			`bson:"enable_coprocess_auth" json:"enable_coprocess_auth"`	// Deprecated. Use CustomPluginAuthEnabled instead.
	CustomPluginAuthEnabled			bool			`bson:"custom_plugin_auth_enabled" json:"custom_plugin_auth_enabled"`
	JWTSigningMethod			string			`bson:"jwt_signing_method" json:"jwt_signing_method"`
	JWTSource				string			`bson:"jwt_source" json:"jwt_source"`
	JWTJwksURIs				[]JWK			`bson:"jwt_jwks_uris" json:"jwt_jwks_uris"`
	JWTIdentityBaseField			string			`bson:"jwt_identit_base_field" json:"jwt_identity_base_field"`
	JWTClientIDBaseField			string			`bson:"jwt_client_base_field" json:"jwt_client_base_field"`
	JWTPolicyFieldName			string			`bson:"jwt_policy_field_name" json:"jwt_policy_field_name"`
	JWTDefaultPolicies			[]string		`bson:"jwt_default_policies" json:"jwt_default_policies"`
	JWTIssuedAtValidationSkew		uint64			`bson:"jwt_issued_at_validation_skew" json:"jwt_issued_at_validation_skew"`
	JWTExpiresAtValidationSkew		uint64			`bson:"jwt_expires_at_validation_skew" json:"jwt_expires_at_validation_skew"`
	JWTNotBeforeValidationSkew		uint64			`bson:"jwt_not_before_validation_skew" json:"jwt_not_before_validation_skew"`
	JWTSkipKid				bool			`bson:"jwt_skip_kid" json:"jwt_skip_kid"`
	Scopes					Scopes			`bson:"scopes" json:"scopes,omitempty"`
	IDPClientIDMappingDisabled		bool			`bson:"idp_client_id_mapping_disabled" json:"idp_client_id_mapping_disabled"`
	JWTScopeToPolicyMapping			map[string]string	`bson:"jwt_scope_to_policy_mapping" json:"jwt_scope_to_policy_mapping"`	// Deprecated: use Scopes.JWT.ScopeToPolicy or Scopes.OIDC.ScopeToPolicy
	JWTScopeClaimName			string			`bson:"jwt_scope_claim_name" json:"jwt_scope_claim_name"`		// Deprecated: use Scopes.JWT.ScopeClaimName or Scopes.OIDC.ScopeClaimName
	NotificationsDetails			NotificationsManager	`bson:"notifications" json:"notifications"`
	EnableSignatureChecking			bool			`bson:"enable_signature_checking" json:"enable_signature_checking"`
	HmacAllowedClockSkew			float64			`bson:"hmac_allowed_clock_skew" json:"hmac_allowed_clock_skew"`
	HmacAllowedAlgorithms			[]string		`bson:"hmac_allowed_algorithms" json:"hmac_allowed_algorithms"`
	RequestSigning				RequestSigningMeta	`bson:"request_signing" json:"request_signing"`
	BaseIdentityProvidedBy			AuthTypeEnum		`bson:"base_identity_provided_by" json:"base_identity_provided_by"`
	VersionDefinition			VersionDefinition	`bson:"definition" json:"definition"`
	VersionData				VersionData		`bson:"version_data" json:"version_data"`	// Deprecated. Use VersionDefinition instead.
	UptimeTests				UptimeTests		`bson:"uptime_tests" json:"uptime_tests"`
	Proxy					ProxyConfig		`bson:"proxy" json:"proxy"`
	DisableRateLimit			bool			`bson:"disable_rate_limit" json:"disable_rate_limit"`
	DisableQuota				bool			`bson:"disable_quota" json:"disable_quota"`
	CustomMiddleware			MiddlewareSection	`bson:"custom_middleware" json:"custom_middleware"`
	CustomMiddlewareBundle			string			`bson:"custom_middleware_bundle" json:"custom_middleware_bundle"`
	CustomMiddlewareBundleDisabled		bool			`bson:"custom_middleware_bundle_disabled" json:"custom_middleware_bundle_disabled"`
	CacheOptions				CacheOptions		`bson:"cache_options" json:"cache_options"`
	SessionLifetimeRespectsKeyExpiration	bool			`bson:"session_lifetime_respects_key_expiration" json:"session_lifetime_respects_key_expiration,omitempty"`
	SessionLifetime				int64			`bson:"session_lifetime" json:"session_lifetime"`
	Active					bool			`bson:"active" json:"active"`
	Internal				bool			`bson:"internal" json:"internal"`
	AuthProvider				AuthProviderMeta	`bson:"auth_provider" json:"auth_provider"`
	SessionProvider				SessionProviderMeta	`bson:"session_provider" json:"session_provider"`
	EventHandlers				EventHandlerMetaConfig	`bson:"event_handlers" json:"event_handlers"`
	EnableBatchRequestSupport		bool			`bson:"enable_batch_request_support" json:"enable_batch_request_support"`
	EnableIpWhiteListing			bool			`mapstructure:"enable_ip_whitelisting" bson:"enable_ip_whitelisting" json:"enable_ip_whitelisting"`
	AllowedIPs				[]string		`mapstructure:"allowed_ips" bson:"allowed_ips" json:"allowed_ips"`
	EnableIpBlacklisting			bool			`mapstructure:"enable_ip_blacklisting" bson:"enable_ip_blacklisting" json:"enable_ip_blacklisting"`
	BlacklistedIPs				[]string		`mapstructure:"blacklisted_ips" bson:"blacklisted_ips" json:"blacklisted_ips"`
	IPAccessControlDisabled			bool			`mapstructure:"ip_access_control_disabled" bson:"ip_access_control_disabled" json:"ip_access_control_disabled"`
	DontSetQuotasOnCreate			bool			`mapstructure:"dont_set_quota_on_create" bson:"dont_set_quota_on_create" json:"dont_set_quota_on_create"`
	ExpireAnalyticsAfter			int64			`mapstructure:"expire_analytics_after" bson:"expire_analytics_after" json:"expire_analytics_after"`	// must have an expireAt TTL index set (http://docs.mongodb.org/manual/tutorial/expire-data/)
	ResponseProcessors			[]ResponseProcessor	`bson:"response_processors" json:"response_processors"`
	CORS					CORSConfig		`bson:"CORS" json:"CORS"`
	Domain					string			`bson:"domain" json:"domain"`
	DomainDisabled				bool			`bson:"domain_disabled" json:"domain_disabled,omitempty"`
	Certificates				[]string		`bson:"certificates" json:"certificates"`
	DoNotTrack				bool			`bson:"do_not_track" json:"do_not_track"`
	EnableContextVars			bool			`bson:"enable_context_vars" json:"enable_context_vars"`
	ConfigData				map[string]interface{}	`bson:"config_data" json:"config_data"`
	ConfigDataDisabled			bool			`bson:"config_data_disabled" json:"config_data_disabled"`
	TagHeaders				[]string		`bson:"tag_headers" json:"tag_headers"`
	GlobalRateLimit				GlobalRateLimit		`bson:"global_rate_limit" json:"global_rate_limit"`
	StripAuthData				bool			`bson:"strip_auth_data" json:"strip_auth_data"`
	EnableDetailedRecording			bool			`bson:"enable_detailed_recording" json:"enable_detailed_recording"`
	GraphQL					GraphQLConfig		`bson:"graphql" json:"graphql"`
	AnalyticsPlugin				AnalyticsPluginConfig	`bson:"analytics_plugin" json:"analytics_plugin,omitempty"`

	// Gateway segment tags
	TagsDisabled	bool		`bson:"tags_disabled" json:"tags_disabled,omitempty"`
	Tags		[]string	`bson:"tags" json:"tags"`

	// IsOAS is set to true when API has an OAS definition (created in OAS or migrated to OAS)
	IsOAS		bool	`bson:"is_oas" json:"is_oas,omitempty"`
	VersionName	string	`bson:"-" json:"-"`

	DetailedTracing	bool	`bson:"detailed_tracing" json:"detailed_tracing"`

	// UpstreamAuth stores information about authenticating against upstream.
	UpstreamAuth	UpstreamAuth	`bson:"upstream_auth" json:"upstream_auth"`
}

AnalyticsPluginConfig

AnalyticsPluginConfig holds the configuration for the analytics custom function plugins

Field name Field type Comment
Enabled

bool

Enabled activates the custom plugin

PluginPath

string

PluginPath is the path to the shared object file or path to js code.

FuncName

string

FunctionName is the name of the method.

type AnalyticsPluginConfig struct {
	// Enabled activates the custom plugin
	Enabled	bool	`bson:"enable" json:"enable,omitempty"`
	// PluginPath is the path to the shared object file or path to js code.
	PluginPath	string	`bson:"plugin_path" json:"plugin_path,omitempty"`
	// FunctionName is the name of the method.
	FuncName	string	`bson:"func_name" json:"func_name,omitempty"`
}

AuthConfig

This type doesn't have documentation.

Field name Field type Comment
Name

string

No comment on field.
UseParam

bool

No comment on field.
ParamName

string

No comment on field.
UseCookie

bool

No comment on field.
CookieName

string

No comment on field.
DisableHeader

bool

No comment on field.
AuthHeaderName

string

No comment on field.
UseCertificate

bool

No comment on field.
ValidateSignature

bool

No comment on field.
Signature

SignatureConfig

No comment on field.
type AuthConfig struct {
	Name			string		`mapstructure:"name" bson:"name" json:"name"`
	UseParam		bool		`mapstructure:"use_param" bson:"use_param" json:"use_param"`
	ParamName		string		`mapstructure:"param_name" bson:"param_name" json:"param_name"`
	UseCookie		bool		`mapstructure:"use_cookie" bson:"use_cookie" json:"use_cookie"`
	CookieName		string		`mapstructure:"cookie_name" bson:"cookie_name" json:"cookie_name"`
	DisableHeader		bool		`mapstructure:"disable_header" bson:"disable_header" json:"disable_header"`
	AuthHeaderName		string		`mapstructure:"auth_header_name" bson:"auth_header_name" json:"auth_header_name"`
	UseCertificate		bool		`mapstructure:"use_certificate" bson:"use_certificate" json:"use_certificate"`
	ValidateSignature	bool		`mapstructure:"validate_signature" bson:"validate_signature" json:"validate_signature"`
	Signature		SignatureConfig	`mapstructure:"signature" bson:"signature" json:"signature,omitempty"`
}

AuthProviderCode

This type doesn't have documentation.

Field name Field type Comment
type

string

No comment on field.
type AuthProviderCode string

AuthProviderMeta

This type doesn't have documentation.

Field name Field type Comment
Name

AuthProviderCode

No comment on field.
StorageEngine

StorageEngineCode

No comment on field.
Meta

map[string]any

No comment on field.
type AuthProviderMeta struct {
	Name		AuthProviderCode	`bson:"name" json:"name"`
	StorageEngine	StorageEngineCode	`bson:"storage_engine" json:"storage_engine"`
	Meta		map[string]interface{}	`bson:"meta" json:"meta"`
}

AuthSource

AuthSource is a common type to be used for auth configurations.

Field name Field type Comment
Enabled

bool

Enabled enables the auth source.

Name

string

Name specifies the key to be used in the auth source.

type AuthSource struct {
	// Enabled enables the auth source.
	Enabled	bool	`bson:"enabled" json:"enabled"`
	// Name specifies the key to be used in the auth source.
	Name	string	`bson:"name" json:"name"`
}

AuthTypeEnum

This type doesn't have documentation.

Field name Field type Comment
type

string

No comment on field.
type AuthTypeEnum string

BundleManifest

This type doesn't have documentation.

Field name Field type Comment
FileList

[]string

No comment on field.
CustomMiddleware

MiddlewareSection

No comment on field.
Checksum

string

No comment on field.
Signature

string

No comment on field.
type BundleManifest struct {
	FileList		[]string		`bson:"file_list" json:"file_list"`
	CustomMiddleware	MiddlewareSection	`bson:"custom_middleware" json:"custom_middleware"`
	Checksum		string			`bson:"checksum" json:"checksum"`
	Signature		string			`bson:"signature" json:"signature"`
}

CORSConfig

This type doesn't have documentation.

Field name Field type Comment
Enable

bool

No comment on field.
AllowedOrigins

[]string

No comment on field.
AllowedMethods

[]string

No comment on field.
AllowedHeaders

[]string

No comment on field.
ExposedHeaders

[]string

No comment on field.
AllowCredentials

bool

No comment on field.
MaxAge

int

No comment on field.
OptionsPassthrough

bool

No comment on field.
Debug

bool

No comment on field.
type CORSConfig struct {
	Enable			bool		`bson:"enable" json:"enable"`
	AllowedOrigins		[]string	`bson:"allowed_origins" json:"allowed_origins"`
	AllowedMethods		[]string	`bson:"allowed_methods" json:"allowed_methods"`
	AllowedHeaders		[]string	`bson:"allowed_headers" json:"allowed_headers"`
	ExposedHeaders		[]string	`bson:"exposed_headers" json:"exposed_headers"`
	AllowCredentials	bool		`bson:"allow_credentials" json:"allow_credentials"`
	MaxAge			int		`bson:"max_age" json:"max_age"`
	OptionsPassthrough	bool		`bson:"options_passthrough" json:"options_passthrough"`
	Debug			bool		`bson:"debug" json:"debug"`
}

CacheMeta

This type doesn't have documentation.

Field name Field type Comment
Disabled

bool

No comment on field.
Method

string

No comment on field.
Path

string

No comment on field.
CacheKeyRegex

string

No comment on field.
CacheOnlyResponseCodes

[]int

No comment on field.
Timeout

int64

No comment on field.
type CacheMeta struct {
	Disabled		bool	`bson:"disabled" json:"disabled"`
	Method			string	`bson:"method" json:"method"`
	Path			string	`bson:"path" json:"path"`
	CacheKeyRegex		string	`bson:"cache_key_regex" json:"cache_key_regex"`
	CacheOnlyResponseCodes	[]int	`bson:"cache_response_codes" json:"cache_response_codes"`
	Timeout			int64	`bson:"timeout" json:"timeout"`
}

CacheOptions

This type doesn't have documentation.

Field name Field type Comment
CacheTimeout

int64

No comment on field.
EnableCache

bool

No comment on field.
CacheAllSafeRequests

bool

No comment on field.
CacheOnlyResponseCodes

[]int

No comment on field.
EnableUpstreamCacheControl

bool

No comment on field.
CacheControlTTLHeader

string

No comment on field.
CacheByHeaders

[]string

No comment on field.
type CacheOptions struct {
	CacheTimeout			int64		`bson:"cache_timeout" json:"cache_timeout"`
	EnableCache			bool		`bson:"enable_cache" json:"enable_cache"`
	CacheAllSafeRequests		bool		`bson:"cache_all_safe_requests" json:"cache_all_safe_requests"`
	CacheOnlyResponseCodes		[]int		`bson:"cache_response_codes" json:"cache_response_codes"`
	EnableUpstreamCacheControl	bool		`bson:"enable_upstream_cache_control" json:"enable_upstream_cache_control"`
	CacheControlTTLHeader		string		`bson:"cache_control_ttl_header" json:"cache_control_ttl_header"`
	CacheByHeaders			[]string	`bson:"cache_by_headers" json:"cache_by_headers"`
}

CheckCommand

UptimeTestCommand handles additional checks for tcp connections.

Field name Field type Comment
Name

string

No comment on field.
Message

string

No comment on field.
type CheckCommand struct {
	Name	string	`bson:"name" json:"name"`
	Message	string	`bson:"message" json:"message"`
}

CircuitBreakerMeta

This type doesn't have documentation.

Field name Field type Comment
Disabled

bool

No comment on field.
Path

string

No comment on field.
Method

string

No comment on field.
ThresholdPercent

float64

No comment on field.
Samples

int64

No comment on field.
ReturnToServiceAfter

int

No comment on field.
DisableHalfOpenState

bool

No comment on field.
type CircuitBreakerMeta struct {
	Disabled		bool	`bson:"disabled" json:"disabled"`
	Path			string	`bson:"path" json:"path"`
	Method			string	`bson:"method" json:"method"`
	ThresholdPercent	float64	`bson:"threshold_percent" json:"threshold_percent"`
	Samples			int64	`bson:"samples" json:"samples"`
	ReturnToServiceAfter	int	`bson:"return_to_service_after" json:"return_to_service_after"`
	DisableHalfOpenState	bool	`bson:"disable_half_open_state" json:"disable_half_open_state"`
}

ClientAuthData

ClientAuthData holds the client ID and secret for upstream OAuth2 authentication.

Field name Field type Comment
ClientID

string

ClientID is the application's ID.

ClientSecret

string

ClientSecret is the application's secret.

type ClientAuthData struct {
	// ClientID is the application's ID.
	ClientID	string	`bson:"client_id" json:"client_id"`
	// ClientSecret is the application's secret.
	ClientSecret	string	`bson:"client_secret,omitempty" json:"client_secret,omitempty"`	// client secret is optional for password flow
}

ClientCredentials

ClientCredentials holds the client credentials for upstream OAuth2 authentication.

Field name Field type Comment

ClientAuthData

No comment on field.
Header

AuthSource

Header holds the configuration for the custom header to be used for OAuth authentication.

TokenURL

string

TokenURL is the resource server's token endpoint URL. This is a constant specific to each server.

Scopes

[]string

Scopes specifies optional requested permissions.

ExtraMetadata

[]string

ExtraMetadata holds the keys that we want to extract from the token and pass to the upstream.

TokenProvider

oauth2.TokenSource

TokenProvider is the OAuth2 token provider for internal use.

type ClientCredentials struct {
	ClientAuthData
	// Header holds the configuration for the custom header to be used for OAuth authentication.
	Header	AuthSource	`bson:"header" json:"header"`
	// TokenURL is the resource server's token endpoint
	// URL. This is a constant specific to each server.
	TokenURL	string	`bson:"token_url" json:"token_url"`
	// Scopes specifies optional requested permissions.
	Scopes	[]string	`bson:"scopes" json:"scopes,omitempty"`
	// ExtraMetadata holds the keys that we want to extract from the token and pass to the upstream.
	ExtraMetadata	[]string	`bson:"extra_metadata" json:"extra_metadata,omitempty"`

	// TokenProvider is the OAuth2 token provider for internal use.
	TokenProvider	oauth2.TokenSource	`bson:"-" json:"-"`
}

DefRequest

This type doesn't have documentation.

Field name Field type Comment
OrgId

string

No comment on field.
Tags

[]string

No comment on field.
LoadOAS

bool

No comment on field.
type DefRequest struct {
	OrgId	string
	Tags	[]string
	LoadOAS	bool
}

EndPointMeta

This type doesn't have documentation.

Field name Field type Comment
Disabled

bool

No comment on field.
Path

string

No comment on field.
Method

string

No comment on field.
IgnoreCase

bool

No comment on field.
MethodActions

map[string]EndpointMethodMeta

Deprecated. Use Method instead.

type EndPointMeta struct {
	Disabled	bool	`bson:"disabled" json:"disabled"`
	Path		string	`bson:"path" json:"path"`
	Method		string	`bson:"method" json:"method"`
	IgnoreCase	bool	`bson:"ignore_case" json:"ignore_case"`
	// Deprecated. Use Method instead.
	MethodActions	map[string]EndpointMethodMeta	`bson:"method_actions,omitempty" json:"method_actions,omitempty"`
}

EndpointMethodAction

This type doesn't have documentation.

Field name Field type Comment
type

string

No comment on field.
type EndpointMethodAction string

EndpointMethodMeta

This type doesn't have documentation.

Field name Field type Comment
Action

EndpointMethodAction

No comment on field.
Code

int

No comment on field.
Data

string

No comment on field.
Headers

map[string]string

No comment on field.
type EndpointMethodMeta struct {
	Action	EndpointMethodAction	`bson:"action" json:"action"`
	Code	int			`bson:"code" json:"code"`
	Data	string			`bson:"data" json:"data"`
	Headers	map[string]string	`bson:"headers" json:"headers"`
}

EventHandlerMetaConfig

This type doesn't have documentation.

Field name Field type Comment
Events

map[TykEvent][]EventHandlerTriggerConfig

No comment on field.
type EventHandlerMetaConfig struct {
	Events map[TykEvent][]EventHandlerTriggerConfig `bson:"events" json:"events"`
}

EventHandlerTriggerConfig

This type doesn't have documentation.

Field name Field type Comment
Handler

TykEventHandlerName

No comment on field.
HandlerMeta

map[string]any

No comment on field.
type EventHandlerTriggerConfig struct {
	Handler		TykEventHandlerName	`bson:"handler_name" json:"handler_name"`
	HandlerMeta	map[string]interface{}	`bson:"handler_meta" json:"handler_meta"`
}

ExtendedPathsSet

This type doesn't have documentation.

Field name Field type Comment
Ignored

[]EndPointMeta

No comment on field.
WhiteList

[]EndPointMeta

No comment on field.
BlackList

[]EndPointMeta

No comment on field.
MockResponse

[]MockResponseMeta

No comment on field.
Cached

[]string

No comment on field.
AdvanceCacheConfig

[]CacheMeta

No comment on field.
Transform

[]TemplateMeta

No comment on field.
TransformResponse

[]TemplateMeta

No comment on field.
TransformJQ

[]TransformJQMeta

No comment on field.
TransformJQResponse

[]TransformJQMeta

No comment on field.
TransformHeader

[]HeaderInjectionMeta

No comment on field.
TransformResponseHeader

[]HeaderInjectionMeta

No comment on field.
HardTimeouts

[]HardTimeoutMeta

No comment on field.
CircuitBreaker

[]CircuitBreakerMeta

No comment on field.
URLRewrite

[]URLRewriteMeta

No comment on field.
Virtual

[]VirtualMeta

No comment on field.
SizeLimit

[]RequestSizeMeta

No comment on field.
MethodTransforms

[]MethodTransformMeta

No comment on field.
TrackEndpoints

[]TrackEndpointMeta

No comment on field.
DoNotTrackEndpoints

[]TrackEndpointMeta

No comment on field.
ValidateJSON

[]ValidatePathMeta

No comment on field.
ValidateRequest

[]ValidateRequestMeta

No comment on field.
Internal

[]InternalMeta

No comment on field.
GoPlugin

[]GoPluginMeta

No comment on field.
PersistGraphQL

[]PersistGraphQLMeta

No comment on field.
RateLimit

[]RateLimitMeta

No comment on field.
type ExtendedPathsSet struct {
	Ignored			[]EndPointMeta		`bson:"ignored" json:"ignored,omitempty"`
	WhiteList		[]EndPointMeta		`bson:"white_list" json:"white_list,omitempty"`
	BlackList		[]EndPointMeta		`bson:"black_list" json:"black_list,omitempty"`
	MockResponse		[]MockResponseMeta	`bson:"mock_response" json:"mock_response,omitempty"`
	Cached			[]string		`bson:"cache" json:"cache,omitempty"`
	AdvanceCacheConfig	[]CacheMeta		`bson:"advance_cache_config" json:"advance_cache_config,omitempty"`
	Transform		[]TemplateMeta		`bson:"transform" json:"transform,omitempty"`
	TransformResponse	[]TemplateMeta		`bson:"transform_response" json:"transform_response,omitempty"`
	TransformJQ		[]TransformJQMeta	`bson:"transform_jq" json:"transform_jq,omitempty"`
	TransformJQResponse	[]TransformJQMeta	`bson:"transform_jq_response" json:"transform_jq_response,omitempty"`
	TransformHeader		[]HeaderInjectionMeta	`bson:"transform_headers" json:"transform_headers,omitempty"`
	TransformResponseHeader	[]HeaderInjectionMeta	`bson:"transform_response_headers" json:"transform_response_headers,omitempty"`
	HardTimeouts		[]HardTimeoutMeta	`bson:"hard_timeouts" json:"hard_timeouts,omitempty"`
	CircuitBreaker		[]CircuitBreakerMeta	`bson:"circuit_breakers" json:"circuit_breakers,omitempty"`
	URLRewrite		[]URLRewriteMeta	`bson:"url_rewrites" json:"url_rewrites,omitempty"`
	Virtual			[]VirtualMeta		`bson:"virtual" json:"virtual,omitempty"`
	SizeLimit		[]RequestSizeMeta	`bson:"size_limits" json:"size_limits,omitempty"`
	MethodTransforms	[]MethodTransformMeta	`bson:"method_transforms" json:"method_transforms,omitempty"`
	TrackEndpoints		[]TrackEndpointMeta	`bson:"track_endpoints" json:"track_endpoints,omitempty"`
	DoNotTrackEndpoints	[]TrackEndpointMeta	`bson:"do_not_track_endpoints" json:"do_not_track_endpoints,omitempty"`
	ValidateJSON		[]ValidatePathMeta	`bson:"validate_json" json:"validate_json,omitempty"`
	ValidateRequest		[]ValidateRequestMeta	`bson:"validate_request" json:"validate_request,omitempty"`
	Internal		[]InternalMeta		`bson:"internal" json:"internal,omitempty"`
	GoPlugin		[]GoPluginMeta		`bson:"go_plugin" json:"go_plugin,omitempty"`
	PersistGraphQL		[]PersistGraphQLMeta	`bson:"persist_graphql" json:"persist_graphql"`
	RateLimit		[]RateLimitMeta		`bson:"rate_limit" json:"rate_limit"`
}

ExternalOAuth

ExternalOAuth support will be deprecated starting from 5.7.0. To avoid any disruptions, we recommend that you use JSON Web Token (JWT) instead, as explained in https://tyk.io/docs/basic-config-and-security/security/authentication-authorization/ext-oauth-middleware/.

Field name Field type Comment
Enabled

bool

No comment on field.
Providers

[]Provider

No comment on field.
type ExternalOAuth struct {
	Enabled		bool		`bson:"enabled" json:"enabled"`
	Providers	[]Provider	`bson:"providers" json:"providers"`
}

GWStats

This type doesn't have documentation.

Field name Field type Comment
APIsCount

int

No comment on field.
PoliciesCount

int

No comment on field.
type GWStats struct {
	APIsCount	int	`json:"apis_count"`
	PoliciesCount	int	`json:"policies_count"`
}

GlobalRateLimit

This type doesn't have documentation.

Field name Field type Comment
Disabled

bool

No comment on field.
Rate

float64

No comment on field.
Per

float64

No comment on field.
type GlobalRateLimit struct {
	Disabled	bool	`bson:"disabled" json:"disabled"`
	Rate		float64	`bson:"rate" json:"rate"`
	Per		float64	`bson:"per" json:"per"`
}

GoPluginMeta

This type doesn't have documentation.

Field name Field type Comment
Disabled

bool

No comment on field.
Path

string

No comment on field.
Method

string

No comment on field.
PluginPath

string

No comment on field.
SymbolName

string

No comment on field.
type GoPluginMeta struct {
	Disabled	bool	`bson:"disabled" json:"disabled"`
	Path		string	`bson:"path" json:"path"`
	Method		string	`bson:"method" json:"method"`
	PluginPath	string	`bson:"plugin_path" json:"plugin_path"`
	SymbolName	string	`bson:"func_name" json:"func_name"`
}

GraphQLConfig

GraphQLConfig is the root config object for a GraphQL API.

Field name Field type Comment
Enabled

bool

Enabled indicates if GraphQL should be enabled.

ExecutionMode

GraphQLExecutionMode

ExecutionMode is the mode to define how an api behaves.

Version

GraphQLConfigVersion

Version defines the version of the GraphQL config and engine to be used.

Schema

string

Schema is the GraphQL Schema exposed by the GraphQL API/Upstream/Engine.

LastSchemaUpdate

*time.Time

LastSchemaUpdate contains the date and time of the last triggered schema update to the upstream.

TypeFieldConfigurations

[]datasource.TypeFieldConfiguration

TypeFieldConfigurations is a rule set of data source and mapping of a schema field.

GraphQLPlayground

GraphQLPlayground

GraphQLPlayground is the Playground specific configuration.

Engine

GraphQLEngineConfig

Engine holds the configuration for engine v2 and upwards.

Proxy

GraphQLProxyConfig

Proxy holds the configuration for a proxy only api.

Subgraph

GraphQLSubgraphConfig

Subgraph holds the configuration for a GraphQL federation subgraph.

Supergraph

GraphQLSupergraphConfig

Supergraph holds the configuration for a GraphQL federation supergraph.

Introspection

GraphQLIntrospectionConfig

Introspection holds the configuration for GraphQL Introspection

type GraphQLConfig struct {
	// Enabled indicates if GraphQL should be enabled.
	Enabled	bool	`bson:"enabled" json:"enabled"`
	// ExecutionMode is the mode to define how an api behaves.
	ExecutionMode	GraphQLExecutionMode	`bson:"execution_mode" json:"execution_mode"`
	// Version defines the version of the GraphQL config and engine to be used.
	Version	GraphQLConfigVersion	`bson:"version" json:"version"`
	// Schema is the GraphQL Schema exposed by the GraphQL API/Upstream/Engine.
	Schema	string	`bson:"schema" json:"schema"`
	// LastSchemaUpdate contains the date and time of the last triggered schema update to the upstream.
	LastSchemaUpdate	*time.Time	`bson:"last_schema_update" json:"last_schema_update,omitempty"`
	// TypeFieldConfigurations is a rule set of data source and mapping of a schema field.
	TypeFieldConfigurations	[]datasource.TypeFieldConfiguration	`bson:"type_field_configurations" json:"type_field_configurations"`
	// GraphQLPlayground is the Playground specific configuration.
	GraphQLPlayground	GraphQLPlayground	`bson:"playground" json:"playground"`
	// Engine holds the configuration for engine v2 and upwards.
	Engine	GraphQLEngineConfig	`bson:"engine" json:"engine"`
	// Proxy holds the configuration for a proxy only api.
	Proxy	GraphQLProxyConfig	`bson:"proxy" json:"proxy"`
	// Subgraph holds the configuration for a GraphQL federation subgraph.
	Subgraph	GraphQLSubgraphConfig	`bson:"subgraph" json:"subgraph"`
	// Supergraph holds the configuration for a GraphQL federation supergraph.
	Supergraph	GraphQLSupergraphConfig	`bson:"supergraph" json:"supergraph"`
	// Introspection holds the configuration for GraphQL Introspection
	Introspection	GraphQLIntrospectionConfig	`bson:"introspection" json:"introspection"`
}

GraphQLConfigVersion

This type doesn't have documentation.

Field name Field type Comment
type

string

No comment on field.
type GraphQLConfigVersion string

GraphQLEngineConfig

This type doesn't have documentation.

Field name Field type Comment
FieldConfigs

[]GraphQLFieldConfig

No comment on field.
DataSources

[]GraphQLEngineDataSource

No comment on field.
GlobalHeaders

[]UDGGlobalHeader

No comment on field.
type GraphQLEngineConfig struct {
	FieldConfigs	[]GraphQLFieldConfig		`bson:"field_configs" json:"field_configs"`
	DataSources	[]GraphQLEngineDataSource	`bson:"data_sources" json:"data_sources"`
	GlobalHeaders	[]UDGGlobalHeader		`bson:"global_headers" json:"global_headers"`
}

GraphQLEngineDataSource

This type doesn't have documentation.

Field name Field type Comment
Kind

GraphQLEngineDataSourceKind

No comment on field.
Name

string

No comment on field.
Internal

bool

No comment on field.
RootFields

[]GraphQLTypeFields

No comment on field.
Config

json.RawMessage

No comment on field.
type GraphQLEngineDataSource struct {
	Kind		GraphQLEngineDataSourceKind	`bson:"kind" json:"kind"`
	Name		string				`bson:"name" json:"name"`
	Internal	bool				`bson:"internal" json:"internal"`
	RootFields	[]GraphQLTypeFields		`bson:"root_fields" json:"root_fields"`
	Config		json.RawMessage			`bson:"config" json:"config"`
}

GraphQLEngineDataSourceConfigGraphQL

This type doesn't have documentation.

Field name Field type Comment
URL

string

No comment on field.
Method

string

No comment on field.
Headers

map[string]string

No comment on field.
SubscriptionType

SubscriptionType

No comment on field.
HasOperation

bool

No comment on field.
Operation

string

No comment on field.
Variables

json.RawMessage

No comment on field.
type GraphQLEngineDataSourceConfigGraphQL struct {
	URL			string			`bson:"url" json:"url"`
	Method			string			`bson:"method" json:"method"`
	Headers			map[string]string	`bson:"headers" json:"headers"`
	SubscriptionType	SubscriptionType	`bson:"subscription_type" json:"subscription_type,omitempty"`
	HasOperation		bool			`bson:"has_operation" json:"has_operation"`
	Operation		string			`bson:"operation" json:"operation"`
	Variables		json.RawMessage		`bson:"variables" json:"variables"`
}

GraphQLEngineDataSourceConfigKafka

This type doesn't have documentation.

Field name Field type Comment
BrokerAddresses

[]string

No comment on field.
Topics

[]string

No comment on field.
GroupID

string

No comment on field.
ClientID

string

No comment on field.
KafkaVersion

string

No comment on field.
StartConsumingLatest

bool

No comment on field.
BalanceStrategy

string

No comment on field.
IsolationLevel

string

No comment on field.
SASL

GraphQLEngineKafkaSASL

No comment on field.
type GraphQLEngineDataSourceConfigKafka struct {
	BrokerAddresses		[]string		`bson:"broker_addresses" json:"broker_addresses"`
	Topics			[]string		`bson:"topics" json:"topics"`
	GroupID			string			`bson:"group_id" json:"group_id"`
	ClientID		string			`bson:"client_id" json:"client_id"`
	KafkaVersion		string			`bson:"kafka_version" json:"kafka_version"`
	StartConsumingLatest	bool			`json:"start_consuming_latest"`
	BalanceStrategy		string			`json:"balance_strategy"`
	IsolationLevel		string			`json:"isolation_level"`
	SASL			GraphQLEngineKafkaSASL	`json:"sasl"`
}

GraphQLEngineDataSourceConfigREST

This type doesn't have documentation.

Field name Field type Comment
URL

string

No comment on field.
Method

string

No comment on field.
Headers

map[string]string

No comment on field.
Query

[]QueryVariable

No comment on field.
Body

string

No comment on field.
type GraphQLEngineDataSourceConfigREST struct {
	URL	string			`bson:"url" json:"url"`
	Method	string			`bson:"method" json:"method"`
	Headers	map[string]string	`bson:"headers" json:"headers"`
	Query	[]QueryVariable		`bson:"query" json:"query"`
	Body	string			`bson:"body" json:"body"`
}

GraphQLEngineDataSourceKind

This type doesn't have documentation.

Field name Field type Comment
type

string

No comment on field.
type GraphQLEngineDataSourceKind string

GraphQLEngineKafkaSASL

This type doesn't have documentation.

Field name Field type Comment
Enable

bool

No comment on field.
User

string

No comment on field.
Password

string

No comment on field.
type GraphQLEngineKafkaSASL struct {
	Enable		bool	`json:"enable"`
	User		string	`json:"user"`
	Password	string	`json:"password"`
}

GraphQLExecutionMode

GraphQLExecutionMode is the mode in which the GraphQL Middleware should operate.

Field name Field type Comment
type

string

No comment on field.
type GraphQLExecutionMode string

GraphQLFieldConfig

This type doesn't have documentation.

Field name Field type Comment
TypeName

string

No comment on field.
FieldName

string

No comment on field.
DisableDefaultMapping

bool

No comment on field.
Path

[]string

No comment on field.
type GraphQLFieldConfig struct {
	TypeName		string		`bson:"type_name" json:"type_name"`
	FieldName		string		`bson:"field_name" json:"field_name"`
	DisableDefaultMapping	bool		`bson:"disable_default_mapping" json:"disable_default_mapping"`
	Path			[]string	`bson:"path" json:"path"`
}

GraphQLIntrospectionConfig

This type doesn't have documentation.

Field name Field type Comment
Disabled

bool

No comment on field.
type GraphQLIntrospectionConfig struct {
	Disabled bool `bson:"disabled" json:"disabled"`
}

GraphQLPlayground

GraphQLPlayground represents the configuration for the public playground which will be hosted alongside the api.

Field name Field type Comment
Enabled

bool

Enabled indicates if the playground should be enabled.

Path

string

Path sets the path on which the playground will be hosted if enabled.

type GraphQLPlayground struct {
	// Enabled indicates if the playground should be enabled.
	Enabled	bool	`bson:"enabled" json:"enabled"`
	// Path sets the path on which the playground will be hosted if enabled.
	Path	string	`bson:"path" json:"path"`
}

GraphQLProxyConfig

This type doesn't have documentation.

Field name Field type Comment
Features

GraphQLProxyFeaturesConfig

No comment on field.
AuthHeaders

map[string]string

No comment on field.
SubscriptionType

SubscriptionType

No comment on field.
RequestHeaders

map[string]string

No comment on field.
UseResponseExtensions

GraphQLResponseExtensions

No comment on field.
RequestHeadersRewrite

map[string]RequestHeadersRewriteConfig

No comment on field.
type GraphQLProxyConfig struct {
	Features		GraphQLProxyFeaturesConfig		`bson:"features" json:"features"`
	AuthHeaders		map[string]string			`bson:"auth_headers" json:"auth_headers"`
	SubscriptionType	SubscriptionType			`bson:"subscription_type" json:"subscription_type,omitempty"`
	RequestHeaders		map[string]string			`bson:"request_headers" json:"request_headers"`
	UseResponseExtensions	GraphQLResponseExtensions		`bson:"use_response_extensions" json:"use_response_extensions"`
	RequestHeadersRewrite	map[string]RequestHeadersRewriteConfig	`json:"request_headers_rewrite" bson:"request_headers_rewrite"`
}

GraphQLProxyFeaturesConfig

This type doesn't have documentation.

Field name Field type Comment
UseImmutableHeaders

bool

No comment on field.
type GraphQLProxyFeaturesConfig struct {
	UseImmutableHeaders bool `bson:"use_immutable_headers" json:"use_immutable_headers"`
}

GraphQLResponseExtensions

This type doesn't have documentation.

Field name Field type Comment
OnErrorForwarding

bool

No comment on field.
type GraphQLResponseExtensions struct {
	OnErrorForwarding bool `bson:"on_error_forwarding" json:"on_error_forwarding"`
}

GraphQLSubgraphConfig

This type doesn't have documentation.

Field name Field type Comment
SDL

string

No comment on field.
type GraphQLSubgraphConfig struct {
	SDL string `bson:"sdl" json:"sdl"`
}

GraphQLSubgraphEntity

This type doesn't have documentation.

Field name Field type Comment
APIID

string

No comment on field.
Name

string

No comment on field.
URL

string

No comment on field.
SDL

string

No comment on field.
Headers

map[string]string

No comment on field.
SubscriptionType

SubscriptionType

No comment on field.
type GraphQLSubgraphEntity struct {
	APIID			string			`bson:"api_id" json:"api_id"`
	Name			string			`bson:"name" json:"name"`
	URL			string			`bson:"url" json:"url"`
	SDL			string			`bson:"sdl" json:"sdl"`
	Headers			map[string]string	`bson:"headers" json:"headers"`
	SubscriptionType	SubscriptionType	`bson:"subscription_type" json:"subscription_type,omitempty"`
}

GraphQLSupergraphConfig

This type doesn't have documentation.

Field name Field type Comment
UpdatedAt

*time.Time

UpdatedAt contains the date and time of the last update of a supergraph API.

Subgraphs

[]GraphQLSubgraphEntity

No comment on field.
MergedSDL

string

No comment on field.
GlobalHeaders

map[string]string

No comment on field.
DisableQueryBatching

bool

No comment on field.
type GraphQLSupergraphConfig struct {
	// UpdatedAt contains the date and time of the last update of a supergraph API.
	UpdatedAt		*time.Time		`bson:"updated_at" json:"updated_at,omitempty"`
	Subgraphs		[]GraphQLSubgraphEntity	`bson:"subgraphs" json:"subgraphs"`
	MergedSDL		string			`bson:"merged_sdl" json:"merged_sdl"`
	GlobalHeaders		map[string]string	`bson:"global_headers" json:"global_headers"`
	DisableQueryBatching	bool			`bson:"disable_query_batching" json:"disable_query_batching"`
}

GraphQLTypeFields

This type doesn't have documentation.

Field name Field type Comment
Type

string

No comment on field.
Fields

[]string

No comment on field.
type GraphQLTypeFields struct {
	Type	string		`bson:"type" json:"type"`
	Fields	[]string	`bson:"fields" json:"fields"`
}

GroupKeySpaceRequest

This type doesn't have documentation.

Field name Field type Comment
OrgID

string

No comment on field.
GroupID

string

No comment on field.
type GroupKeySpaceRequest struct {
	OrgID	string
	GroupID	string
}

GroupLoginRequest

This type doesn't have documentation.

Field name Field type Comment
UserKey

string

No comment on field.
GroupID

string

No comment on field.
ForceSync

bool

No comment on field.
Node

[]byte

No comment on field.
type GroupLoginRequest struct {
	UserKey		string
	GroupID		string
	ForceSync	bool
	Node		[]byte
}

HardTimeoutMeta

This type doesn't have documentation.

Field name Field type Comment
Disabled

bool

No comment on field.
Path

string

No comment on field.
Method

string

No comment on field.
TimeOut

int

No comment on field.
type HardTimeoutMeta struct {
	Disabled	bool	`bson:"disabled" json:"disabled"`
	Path		string	`bson:"path" json:"path"`
	Method		string	`bson:"method" json:"method"`
	TimeOut		int	`bson:"timeout" json:"timeout"`
}

HeaderInjectionMeta

This type doesn't have documentation.

Field name Field type Comment
Disabled

bool

No comment on field.
DeleteHeaders

[]string

No comment on field.
AddHeaders

map[string]string

No comment on field.
Path

string

No comment on field.
Method

string

No comment on field.
ActOnResponse

bool

No comment on field.
type HeaderInjectionMeta struct {
	Disabled	bool			`bson:"disabled" json:"disabled"`
	DeleteHeaders	[]string		`bson:"delete_headers" json:"delete_headers"`
	AddHeaders	map[string]string	`bson:"add_headers" json:"add_headers"`
	Path		string			`bson:"path" json:"path"`
	Method		string			`bson:"method" json:"method"`
	ActOnResponse	bool			`bson:"act_on" json:"act_on"`
}

HealthCheckItem

This type doesn't have documentation.

Field name Field type Comment
Status

HealthCheckStatus

No comment on field.
Output

string

No comment on field.
ComponentType

string

No comment on field.
ComponentID

string

No comment on field.
Time

string

No comment on field.
type HealthCheckItem struct {
	Status		HealthCheckStatus	`json:"status"`
	Output		string			`json:"output,omitempty"`
	ComponentType	string			`json:"componentType,omitempty"`
	ComponentID	string			`json:"componentId,omitempty"`
	Time		string			`json:"time"`
}

HealthCheckResponse

This type doesn't have documentation.

Field name Field type Comment
Status

HealthCheckStatus

No comment on field.
Version

string

No comment on field.
Output

string

No comment on field.
Description

string

No comment on field.
Details

map[string]HealthCheckItem

No comment on field.
type HealthCheckResponse struct {
	Status		HealthCheckStatus		`json:"status"`
	Version		string				`json:"version,omitempty"`
	Output		string				`json:"output,omitempty"`
	Description	string				`json:"description,omitempty"`
	Details		map[string]HealthCheckItem	`json:"details,omitempty"`
}

HostCheckObject

HostCheckObject represents a single uptime test check.

Field name Field type Comment
CheckURL

string

No comment on field.
Protocol

string

No comment on field.
Timeout

time.Duration

No comment on field.
EnableProxyProtocol

bool

No comment on field.
Commands

[]CheckCommand

No comment on field.
Method

string

No comment on field.
Headers

map[string]string

No comment on field.
Body

string

No comment on field.
type HostCheckObject struct {
	CheckURL		string			`bson:"url" json:"url"`
	Protocol		string			`bson:"protocol" json:"protocol"`
	Timeout			time.Duration		`bson:"timeout" json:"timeout"`
	EnableProxyProtocol	bool			`bson:"enable_proxy_protocol" json:"enable_proxy_protocol"`
	Commands		[]CheckCommand		`bson:"commands" json:"commands"`
	Method			string			`bson:"method" json:"method"`
	Headers			map[string]string	`bson:"headers" json:"headers"`
	Body			string			`bson:"body" json:"body"`
}

HostDetails

HostDetails contains information about a host machine, including its hostname, process ID (PID), and IP address.

Field name Field type Comment
Hostname

string

No comment on field.
PID

int

No comment on field.
Address

string

No comment on field.
type HostDetails struct {
	Hostname	string
	PID		int
	Address		string
}

HostList

This type doesn't have documentation.

Field name Field type Comment
hMutex

sync.RWMutex

No comment on field.
hosts

[]string

No comment on field.
type HostList struct {
	hMutex	sync.RWMutex
	hosts	[]string
}

IDExtractor

This type doesn't have documentation.

Field name Field type Comment
type

any

No comment on field.
type IDExtractor interface{}

IDExtractorConfig

IDExtractorConfig specifies the configuration for ID extractor

Field name Field type Comment
HeaderName

string

HeaderName is the header name to extract ID from.

FormParamName

string

FormParamName is the form parameter name to extract ID from.

RegexExpression

string

RegexExpression is the regular expression to match ID.

RegexMatchIndex

int

RegexMatchIndex is the index from which ID to be extracted after a match.

XPathExpression

string

XPathExp is the xpath expression to match ID.

type IDExtractorConfig struct {
	// HeaderName is the header name to extract ID from.
	HeaderName	string	`mapstructure:"header_name" bson:"header_name" json:"header_name,omitempty"`
	// FormParamName is the form parameter name to extract ID from.
	FormParamName	string	`mapstructure:"param_name" bson:"param_name" json:"param_name,omitempty"`
	// RegexExpression is the regular expression to match ID.
	RegexExpression	string	`mapstructure:"regex_expression" bson:"regex_expression" json:"regex_expression,omitempty"`
	// RegexMatchIndex is the index from which ID to be extracted after a match.
	RegexMatchIndex	int	`mapstructure:"regex_match_index" bson:"regex_match_index" json:"regex_match_index,omitempty"`
	// XPathExp is the xpath expression to match ID.
	XPathExpression	string	`mapstructure:"xpath_expression" bson:"xpath_expression" json:"xpath_expression,omitempty"`
}

IdExtractorSource

This type doesn't have documentation.

Field name Field type Comment
type

string

No comment on field.
type IdExtractorSource string

IdExtractorType

This type doesn't have documentation.

Field name Field type Comment
type

string

No comment on field.
type IdExtractorType string

InboundData

This type doesn't have documentation.

Field name Field type Comment
KeyName

string

No comment on field.
Value

string

No comment on field.
SessionState

string

No comment on field.
Timeout

int64

No comment on field.
Per

int64

No comment on field.
Expire

int64

No comment on field.
type InboundData struct {
	KeyName		string
	Value		string
	SessionState	string
	Timeout		int64
	Per		int64
	Expire		int64
}

InternalMeta

This type doesn't have documentation.

Field name Field type Comment
Disabled

bool

No comment on field.
Path

string

No comment on field.
Method

string

No comment on field.
type InternalMeta struct {
	Disabled	bool	`bson:"disabled" json:"disabled"`
	Path		string	`bson:"path" json:"path"`
	Method		string	`bson:"method" json:"method"`
}

Introspection

This type doesn't have documentation.

Field name Field type Comment
Enabled

bool

No comment on field.
URL

string

No comment on field.
ClientID

string

No comment on field.
ClientSecret

string

No comment on field.
IdentityBaseField

string

No comment on field.
Cache

IntrospectionCache

No comment on field.
type Introspection struct {
	Enabled			bool			`bson:"enabled" json:"enabled"`
	URL			string			`bson:"url" json:"url"`
	ClientID		string			`bson:"client_id" json:"client_id"`
	ClientSecret		string			`bson:"client_secret" json:"client_secret"`
	IdentityBaseField	string			`bson:"identity_base_field" json:"identity_base_field"`
	Cache			IntrospectionCache	`bson:"cache" json:"cache"`
}

IntrospectionCache

This type doesn't have documentation.

Field name Field type Comment
Enabled

bool

No comment on field.
Timeout

int64

No comment on field.
type IntrospectionCache struct {
	Enabled	bool	`bson:"enabled" json:"enabled"`
	Timeout	int64	`bson:"timeout" json:"timeout"`
}

JSVMEventHandlerConf

JSVMEventHandlerConf represents the configuration for a JavaScript VM event handler in the API definition.

Field name Field type Comment
Disabled

bool

Disabled indicates whether the event handler is inactive.

ID

string

ID is the optional unique identifier for the event handler.

MethodName

string

MethodName specifies the JavaScript function name to be executed.

Path

string

Path refers to the file path of the JavaScript source code for the handler.

type JSVMEventHandlerConf struct {
	// Disabled indicates whether the event handler is inactive.
	Disabled	bool	`bson:"disabled" json:"disabled"`
	// ID is the optional unique identifier for the event handler.
	ID	string	`bson:"id" json:"id"`
	// MethodName specifies the JavaScript function name to be executed.
	MethodName	string	`bson:"name" json:"name"`
	// Path refers to the file path of the JavaScript source code for the handler.
	Path	string	`bson:"path" json:"path"`
}

JWK

This type doesn't have documentation.

Field name Field type Comment
URL

string

url is the jwk endpoint

type JWK struct {
	// url is the jwk endpoint
	URL string `json:"url"`
}

JWTValidation

This type doesn't have documentation.

Field name Field type Comment
Enabled

bool

No comment on field.
SigningMethod

string

No comment on field.
Source

string

No comment on field.
IssuedAtValidationSkew

uint64

No comment on field.
NotBeforeValidationSkew

uint64

No comment on field.
ExpiresAtValidationSkew

uint64

No comment on field.
IdentityBaseField

string

No comment on field.
type JWTValidation struct {
	Enabled			bool	`bson:"enabled" json:"enabled"`
	SigningMethod		string	`bson:"signing_method" json:"signing_method"`
	Source			string	`bson:"source" json:"source"`
	IssuedAtValidationSkew	uint64	`bson:"issued_at_validation_skew" json:"issued_at_validation_skew"`
	NotBeforeValidationSkew	uint64	`bson:"not_before_validation_skew" json:"not_before_validation_skew"`
	ExpiresAtValidationSkew	uint64	`bson:"expires_at_validation_skew" json:"expires_at_validation_skew"`
	IdentityBaseField	string	`bson:"identity_base_field" json:"identity_base_field"`
}

KeysValuesPair

This type doesn't have documentation.

Field name Field type Comment
Keys

[]string

No comment on field.
Values

[]string

No comment on field.
type KeysValuesPair struct {
	Keys	[]string
	Values	[]string
}

LogEventHandlerConf

LogEventHandlerConf represents the configuration for a log event handler.

Field name Field type Comment
Disabled

bool

Disabled indicates whether the handler is inactive.

Prefix

string

Prefix specifies the prefix used for log events.

type LogEventHandlerConf struct {
	// Disabled indicates whether the handler is inactive.
	Disabled	bool	`bson:"disabled" json:"disabled"`
	// Prefix specifies the prefix used for log events.
	Prefix	string	`bson:"prefix" json:"prefix"`
}

MethodTransformMeta

This type doesn't have documentation.

Field name Field type Comment
Disabled

bool

No comment on field.
Path

string

No comment on field.
Method

string

No comment on field.
ToMethod

string

No comment on field.
type MethodTransformMeta struct {
	Disabled	bool	`bson:"disabled" json:"disabled"`
	Path		string	`bson:"path" json:"path"`
	Method		string	`bson:"method" json:"method"`
	ToMethod	string	`bson:"to_method" json:"to_method"`
}

MiddlewareDefinition

This type doesn't have documentation.

Field name Field type Comment
Disabled

bool

No comment on field.
Name

string

No comment on field.
Path

string

No comment on field.
RequireSession

bool

No comment on field.
RawBodyOnly

bool

No comment on field.
type MiddlewareDefinition struct {
	Disabled	bool	`bson:"disabled" json:"disabled"`
	Name		string	`bson:"name" json:"name"`
	Path		string	`bson:"path" json:"path"`
	RequireSession	bool	`bson:"require_session" json:"require_session"`
	RawBodyOnly	bool	`bson:"raw_body_only" json:"raw_body_only"`
}

MiddlewareDriver

This type doesn't have documentation.

Field name Field type Comment
type

string

No comment on field.
type MiddlewareDriver string

MiddlewareIdExtractor

This type doesn't have documentation.

Field name Field type Comment
Disabled

bool

No comment on field.
ExtractFrom

IdExtractorSource

No comment on field.
ExtractWith

IdExtractorType

No comment on field.
ExtractorConfig

map[string]any

No comment on field.
Extractor

IDExtractor

No comment on field.
type MiddlewareIdExtractor struct {
	Disabled	bool			`bson:"disabled" json:"disabled"`
	ExtractFrom	IdExtractorSource	`bson:"extract_from" json:"extract_from"`
	ExtractWith	IdExtractorType		`bson:"extract_with" json:"extract_with"`
	ExtractorConfig	map[string]interface{}	`bson:"extractor_config" json:"extractor_config"`
	Extractor	IDExtractor		`bson:"-" json:"-"`
}

MiddlewareSection

This type doesn't have documentation.

Field name Field type Comment
Pre

[]MiddlewareDefinition

No comment on field.
Post

[]MiddlewareDefinition

No comment on field.
PostKeyAuth

[]MiddlewareDefinition

No comment on field.
AuthCheck

MiddlewareDefinition

No comment on field.
Response

[]MiddlewareDefinition

No comment on field.
Driver

MiddlewareDriver

No comment on field.
IdExtractor

MiddlewareIdExtractor

No comment on field.
type MiddlewareSection struct {
	Pre		[]MiddlewareDefinition	`bson:"pre" json:"pre"`
	Post		[]MiddlewareDefinition	`bson:"post" json:"post"`
	PostKeyAuth	[]MiddlewareDefinition	`bson:"post_key_auth" json:"post_key_auth"`
	AuthCheck	MiddlewareDefinition	`bson:"auth_check" json:"auth_check"`
	Response	[]MiddlewareDefinition	`bson:"response" json:"response"`
	Driver		MiddlewareDriver	`bson:"driver" json:"driver"`
	IdExtractor	MiddlewareIdExtractor	`bson:"id_extractor" json:"id_extractor"`
}

MockResponseMeta

This type doesn't have documentation.

Field name Field type Comment
Disabled

bool

No comment on field.
Path

string

No comment on field.
Method

string

No comment on field.
IgnoreCase

bool

No comment on field.
Code

int

No comment on field.
Body

string

No comment on field.
Headers

map[string]string

No comment on field.
type MockResponseMeta struct {
	Disabled	bool			`bson:"disabled" json:"disabled"`
	Path		string			`bson:"path" json:"path"`
	Method		string			`bson:"method" json:"method"`
	IgnoreCase	bool			`bson:"ignore_case" json:"ignore_case"`
	Code		int			`bson:"code" json:"code"`
	Body		string			`bson:"body" json:"body"`
	Headers		map[string]string	`bson:"headers" json:"headers"`
}

NodeData

This type doesn't have documentation.

Field name Field type Comment
NodeID

string

No comment on field.
APIKey

string

No comment on field.
GroupID

string

No comment on field.
NodeVersion

string

No comment on field.
TTL

int64

No comment on field.
NodeIsSegmented

bool

No comment on field.
Tags

[]string

No comment on field.
Health

map[string]HealthCheckItem

No comment on field.
Stats

GWStats

No comment on field.
HostDetails

HostDetails

No comment on field.
type NodeData struct {
	NodeID		string				`json:"node_id"`
	APIKey		string				`json:"api_key"`
	GroupID		string				`json:"group_id"`
	NodeVersion	string				`json:"node_version"`
	TTL		int64				`json:"ttl"`
	NodeIsSegmented	bool				`json:"node_is_segmented"`
	Tags		[]string			`json:"tags"`
	Health		map[string]HealthCheckItem	`json:"health"`
	Stats		GWStats				`json:"stats"`
	HostDetails	HostDetails			`json:"host_details"`
}

NotificationsManager

NotificationsManager handles sending notifications to OAuth endpoints to notify the provider of key changes. TODO: Make this more generic

Field name Field type Comment
SharedSecret

string

No comment on field.
OAuthKeyChangeURL

string

No comment on field.
type NotificationsManager struct {
	SharedSecret		string	`bson:"shared_secret" json:"shared_secret"`
	OAuthKeyChangeURL	string	`bson:"oauth_on_keychange_url" json:"oauth_on_keychange_url"`
}

OIDProviderConfig

This type doesn't have documentation.

Field name Field type Comment
Issuer

string

No comment on field.
ClientIDs

map[string]string

No comment on field.
type OIDProviderConfig struct {
	Issuer		string			`bson:"issuer" json:"issuer"`
	ClientIDs	map[string]string	`bson:"client_ids" json:"client_ids"`
}

OpenIDOptions

OpenID Connect middleware support will be deprecated starting from 5.7.0. To avoid any disruptions, we recommend that you use JSON Web Token (JWT) instead, as explained in https://tyk.io/docs/basic-config-and-security/security/authentication-authorization/openid-connect/.

Field name Field type Comment
Providers

[]OIDProviderConfig

No comment on field.
SegregateByClient

bool

No comment on field.
type OpenIDOptions struct {
	Providers		[]OIDProviderConfig	`bson:"providers" json:"providers"`
	SegregateByClient	bool			`bson:"segregate_by_client" json:"segregate_by_client"`
}

PasswordAuthentication

PasswordAuthentication holds the configuration for upstream OAuth2 password authentication flow.

Field name Field type Comment

ClientAuthData

No comment on field.
Header

AuthSource

Header holds the configuration for the custom header to be used for OAuth authentication.

Username

string

Username is the username to be used for upstream OAuth2 password authentication.

Password

string

Password is the password to be used for upstream OAuth2 password authentication.

TokenURL

string

TokenURL is the resource server's token endpoint URL. This is a constant specific to each server.

Scopes

[]string

Scopes specifies optional requested permissions.

ExtraMetadata

[]string

ExtraMetadata holds the keys that we want to extract from the token and pass to the upstream.

Token

*oauth2.Token

TokenProvider is the OAuth2 password authentication flow token for internal use.

type PasswordAuthentication struct {
	ClientAuthData
	// Header holds the configuration for the custom header to be used for OAuth authentication.
	Header	AuthSource	`bson:"header" json:"header"`
	// Username is the username to be used for upstream OAuth2 password authentication.
	Username	string	`bson:"username" json:"username"`
	// Password is the password to be used for upstream OAuth2 password authentication.
	Password	string	`bson:"password" json:"password"`
	// TokenURL is the resource server's token endpoint
	// URL. This is a constant specific to each server.
	TokenURL	string	`bson:"token_url" json:"token_url"`
	// Scopes specifies optional requested permissions.
	Scopes	[]string	`bson:"scopes" json:"scopes,omitempty"`
	// ExtraMetadata holds the keys that we want to extract from the token and pass to the upstream.
	ExtraMetadata	[]string	`bson:"extra_metadata" json:"extra_metadata,omitempty"`

	// TokenProvider is the OAuth2 password authentication flow token for internal use.
	Token	*oauth2.Token	`bson:"-" json:"-"`
}

PersistGraphQLMeta

This type doesn't have documentation.

Field name Field type Comment
Path

string

No comment on field.
Method

string

No comment on field.
Operation

string

No comment on field.
Variables

map[string]any

No comment on field.
type PersistGraphQLMeta struct {
	Path		string			`bson:"path" json:"path"`
	Method		string			`bson:"method" json:"method"`
	Operation	string			`bson:"operation" json:"operation"`
	Variables	map[string]interface{}	`bson:"variables" json:"variables"`
}

Provider

This type doesn't have documentation.

Field name Field type Comment
JWT

JWTValidation

No comment on field.
Introspection

Introspection

No comment on field.
type Provider struct {
	JWT		JWTValidation	`bson:"jwt" json:"jwt"`
	Introspection	Introspection	`bson:"introspection" json:"introspection"`
}

ProxyConfig

This type doesn't have documentation.

Field name Field type Comment
PreserveHostHeader

bool

No comment on field.
ListenPath

string

No comment on field.
TargetURL

string

No comment on field.
DisableStripSlash

bool

No comment on field.
StripListenPath

bool

No comment on field.
EnableLoadBalancing

bool

No comment on field.
Targets

[]string

No comment on field.
StructuredTargetList

*HostList

No comment on field.
CheckHostAgainstUptimeTests

bool

No comment on field.
ServiceDiscovery

ServiceDiscoveryConfiguration

No comment on field.
Transport

struct { SSLInsecureSkipVerify bool `bson:"ssl_insecure_skip_verify" json:"ssl_insecure_skip_verify"` SSLCipherSuites []string `bson:"ssl_ciphers" json:"ssl_ciphers"` SSLMinVersion uint16 `bson:"ssl_min_version" json:"ssl_min_version"` SSLMaxVersion uint16 `bson:"ssl_max_version" json:"ssl_max_version"` SSLForceCommonNameCheck bool `json:"ssl_force_common_name_check"` ProxyURL string `bson:"proxy_url" json:"proxy_url"` }

No comment on field.
type ProxyConfig struct {
	PreserveHostHeader		bool				`bson:"preserve_host_header" json:"preserve_host_header"`
	ListenPath			string				`bson:"listen_path" json:"listen_path"`
	TargetURL			string				`bson:"target_url" json:"target_url"`
	DisableStripSlash		bool				`bson:"disable_strip_slash" json:"disable_strip_slash"`
	StripListenPath			bool				`bson:"strip_listen_path" json:"strip_listen_path"`
	EnableLoadBalancing		bool				`bson:"enable_load_balancing" json:"enable_load_balancing"`
	Targets				[]string			`bson:"target_list" json:"target_list"`
	StructuredTargetList		*HostList			`bson:"-" json:"-"`
	CheckHostAgainstUptimeTests	bool				`bson:"check_host_against_uptime_tests" json:"check_host_against_uptime_tests"`
	ServiceDiscovery		ServiceDiscoveryConfiguration	`bson:"service_discovery" json:"service_discovery"`
	Transport			struct {
		SSLInsecureSkipVerify	bool		`bson:"ssl_insecure_skip_verify" json:"ssl_insecure_skip_verify"`
		SSLCipherSuites		[]string	`bson:"ssl_ciphers" json:"ssl_ciphers"`
		SSLMinVersion		uint16		`bson:"ssl_min_version" json:"ssl_min_version"`
		SSLMaxVersion		uint16		`bson:"ssl_max_version" json:"ssl_max_version"`
		SSLForceCommonNameCheck	bool		`json:"ssl_force_common_name_check"`
		ProxyURL		string		`bson:"proxy_url" json:"proxy_url"`
	}	`bson:"transport" json:"transport"`
}

QueryVariable

This type doesn't have documentation.

Field name Field type Comment
Name

string

No comment on field.
Value

string

No comment on field.
type QueryVariable struct {
	Name	string	`bson:"name" json:"name"`
	Value	string	`bson:"value" json:"value"`
}

RateLimitMeta

RateLimitMeta configures rate limits per API path.

Field name Field type Comment
Disabled

bool

No comment on field.
Path

string

No comment on field.
Method

string

No comment on field.
Rate

float64

No comment on field.
Per

float64

No comment on field.
type RateLimitMeta struct {
	Disabled	bool	`bson:"disabled" json:"disabled"`
	Path		string	`bson:"path" json:"path"`
	Method		string	`bson:"method" json:"method"`

	Rate	float64	`bson:"rate" json:"rate"`
	Per	float64	`bson:"per" json:"per"`
}

RateLimitSmoothing

RateLimitSmoothing holds the rate smoothing configuration.

Rate Limit Smoothing is a mechanism to dynamically adjust the request rate limits based on the current traffic patterns. It helps in managing request spikes by gradually increasing or decreasing the rate limit instead of making abrupt changes or blocking requests excessively.

Once the rate limit smoothing triggers an allowance change, one of the following events is emitted:

  • RateLimitSmoothingUp when the allowance increases
  • RateLimitSmoothingDown when the allowance decreases

Events are emitted based on the configuration:

  • enabled (boolean) to enable or disable rate limit smoothing
  • threshold after which to apply smoothing (minimum rate for window)
  • trigger configures at which fraction of a step a smoothing event is emitted
  • step is the value by which the rate allowance will get adjusted
  • delay is a hold-off in seconds providing a minimum period between rate allowance adjustments

To determine if the request rate is growing and needs to be smoothed, the step * trigger value is subtracted from the request allowance and, if the request rate goes above that, then a RateLimitSmoothingUp event is emitted and the rate allowance is increased by step.

Once the request allowance has been increased above the threshold, Tyk will start to check for decreasing request rate. When the request rate drops step * (1 + trigger) below the request allowance, a RateLimitSmoothingDown event is emitted and the rate allowance is decreased by step.

After the request allowance has been adjusted (up or down), the request rate will be checked again over the next delay seconds and, if required, further adjustment made to the rate allowance after the hold-off.

For any allowance, events are emitted based on the following calculations:

  • When the request rate rises above allowance - (step * trigger), a RateLimitSmoothingUp event is emitted and allowance increases by step.
  • When the request rate falls below allowance - (step + step * trigger), a RateLimitSmoothingDown event is emitted and allowance decreases by step.

Example: Threshold: 400, Request allowance: 600, Current rate: 500, Step: 100, Trigger: 0.5.

To trigger a RateLimitSmoothingUp event, the request rate must exceed:

  • Calculation: Allowance - (Step * Trigger).
  • Example: 600 - (100 * 0.5) = 550.

Exceeding a request rate of 550 will increase the allowance to 700 (Allowance + Step).

To trigger a RateLimitSmoothingDown event, the request rate must fall below:

  • Calculation: Allowance - (Step + (Step * Trigger)).
  • Example: 600 - (100 + (100 * 0.5)) = 450.

As the request rate falls below 450, that will decrease the allowance to 500 (Allowance - Step).

The request allowance will be smoothed between threshold, and the defined rate limit (maximum). The request allowance will be updated internally every delay seconds.

Field name Field type Comment
Enabled

bool

Enabled indicates if rate limit smoothing is active.

Threshold

int64

Threshold is the initial rate limit beyond which smoothing will be applied. It is a count of requests during the per interval and should be less than the maximum configured rate.

Trigger

float64

Trigger is a fraction (typically in the range 0.1-1.0) of the step at which point a smoothing event will be emitted as the request rate approaches the current allowance.

Step

int64

Step is the increment by which the current allowance will be increased or decreased each time a smoothing event is emitted.

Delay

int64

Delay is a hold-off between smoothing events and controls how frequently the current allowance will step up or down (in seconds).

type RateLimitSmoothing struct {
	// Enabled indicates if rate limit smoothing is active.
	Enabled	bool	`json:"enabled" bson:"enabled"`

	// Threshold is the initial rate limit beyond which smoothing will be applied. It is a count of requests during the `per` interval and should be less than the maximum configured `rate`.
	Threshold	int64	`json:"threshold" bson:"threshold"`

	// Trigger is a fraction (typically in the range 0.1-1.0) of the step at which point a smoothing event will be emitted as the request rate approaches the current allowance.
	Trigger	float64	`json:"trigger" bson:"trigger"`

	// Step is the increment by which the current allowance will be increased or decreased each time a smoothing event is emitted.
	Step	int64	`json:"step" bson:"step"`

	// Delay is a hold-off between smoothing events and controls how frequently the current allowance will step up or down (in seconds).
	Delay	int64	`json:"delay" bson:"delay"`
}

RequestHeadersRewriteConfig

This type doesn't have documentation.

Field name Field type Comment
Value

string

No comment on field.
Remove

bool

No comment on field.
type RequestHeadersRewriteConfig struct {
	Value	string	`json:"value" bson:"value"`
	Remove	bool	`json:"remove" bson:"remove"`
}

RequestInputType

This type doesn't have documentation.

Field name Field type Comment
type

string

No comment on field.
type RequestInputType string

RequestSigningMeta

This type doesn't have documentation.

Field name Field type Comment
IsEnabled

bool

No comment on field.
Secret

string

No comment on field.
KeyId

string

No comment on field.
Algorithm

string

No comment on field.
HeaderList

[]string

No comment on field.
CertificateId

string

No comment on field.
SignatureHeader

string

No comment on field.
type RequestSigningMeta struct {
	IsEnabled	bool		`bson:"is_enabled" json:"is_enabled"`
	Secret		string		`bson:"secret" json:"secret"`
	KeyId		string		`bson:"key_id" json:"key_id"`
	Algorithm	string		`bson:"algorithm" json:"algorithm"`
	HeaderList	[]string	`bson:"header_list" json:"header_list"`
	CertificateId	string		`bson:"certificate_id" json:"certificate_id"`
	SignatureHeader	string		`bson:"signature_header" json:"signature_header"`
}

RequestSizeMeta

This type doesn't have documentation.

Field name Field type Comment
Disabled

bool

No comment on field.
Path

string

No comment on field.
Method

string

No comment on field.
SizeLimit

int64

No comment on field.
type RequestSizeMeta struct {
	Disabled	bool	`bson:"disabled" json:"disabled"`
	Path		string	`bson:"path" json:"path"`
	Method		string	`bson:"method" json:"method"`
	SizeLimit	int64	`bson:"size_limit" json:"size_limit"`
}

ResponseProcessor

This type doesn't have documentation.

Field name Field type Comment
Name

string

No comment on field.
Options

any

No comment on field.
type ResponseProcessor struct {
	Name	string		`bson:"name" json:"name"`
	Options	interface{}	`bson:"options" json:"options"`
}

RoutingTrigger

This type doesn't have documentation.

Field name Field type Comment
On

RoutingTriggerOnType

No comment on field.
Options

RoutingTriggerOptions

No comment on field.
RewriteTo

string

No comment on field.
type RoutingTrigger struct {
	On		RoutingTriggerOnType	`bson:"on" json:"on"`
	Options		RoutingTriggerOptions	`bson:"options" json:"options"`
	RewriteTo	string			`bson:"rewrite_to" json:"rewrite_to"`
}

RoutingTriggerOnType

This type doesn't have documentation.

Field name Field type Comment
type

string

No comment on field.
type RoutingTriggerOnType string

RoutingTriggerOptions

This type doesn't have documentation.

Field name Field type Comment
HeaderMatches

map[string]StringRegexMap

No comment on field.
QueryValMatches

map[string]StringRegexMap

No comment on field.
PathPartMatches

map[string]StringRegexMap

No comment on field.
SessionMetaMatches

map[string]StringRegexMap

No comment on field.
RequestContextMatches

map[string]StringRegexMap

No comment on field.
PayloadMatches

StringRegexMap

No comment on field.
type RoutingTriggerOptions struct {
	HeaderMatches		map[string]StringRegexMap	`bson:"header_matches" json:"header_matches"`
	QueryValMatches		map[string]StringRegexMap	`bson:"query_val_matches" json:"query_val_matches"`
	PathPartMatches		map[string]StringRegexMap	`bson:"path_part_matches" json:"path_part_matches"`
	SessionMetaMatches	map[string]StringRegexMap	`bson:"session_meta_matches" json:"session_meta_matches"`
	RequestContextMatches	map[string]StringRegexMap	`bson:"request_context_matches" json:"request_context_matches"`
	PayloadMatches		StringRegexMap			`bson:"payload_matches" json:"payload_matches"`
}

RuleAtLeastEnableOneAuthSource

This type doesn't have documentation.

type RuleAtLeastEnableOneAuthSource struct{}

RuleUniqueDataSourceNames

This type doesn't have documentation.

type RuleUniqueDataSourceNames struct{}

RuleUpstreamAuth

RuleUpstreamAuth implements validations for upstream authentication configurations.

type RuleUpstreamAuth struct{}

RuleValidateEnforceTimeout

This type doesn't have documentation.

type RuleValidateEnforceTimeout struct{}

RuleValidateIPList

This type doesn't have documentation.

type RuleValidateIPList struct{}

ScopeClaim

This type doesn't have documentation.

Field name Field type Comment
ScopeClaimName

string

No comment on field.
ScopeToPolicy

map[string]string

No comment on field.
type ScopeClaim struct {
	ScopeClaimName	string			`bson:"scope_claim_name" json:"scope_claim_name,omitempty"`
	ScopeToPolicy	map[string]string	`json:"scope_to_policy,omitempty"`
}

Scopes

This type doesn't have documentation.

Field name Field type Comment
JWT

ScopeClaim

No comment on field.
OIDC

ScopeClaim

No comment on field.
type Scopes struct {
	JWT	ScopeClaim	`bson:"jwt" json:"jwt,omitempty"`
	OIDC	ScopeClaim	`bson:"oidc" json:"oidc,omitempty"`
}

ServiceDiscoveryConfiguration

This type doesn't have documentation.

Field name Field type Comment
UseDiscoveryService

bool

No comment on field.
QueryEndpoint

string

No comment on field.
UseNestedQuery

bool

No comment on field.
ParentDataPath

string

No comment on field.
DataPath

string

No comment on field.
PortDataPath

string

No comment on field.
TargetPath

string

No comment on field.
UseTargetList

bool

No comment on field.
CacheDisabled

bool

No comment on field.
CacheTimeout

int64

No comment on field.
EndpointReturnsList

bool

No comment on field.
type ServiceDiscoveryConfiguration struct {
	UseDiscoveryService	bool	`bson:"use_discovery_service" json:"use_discovery_service"`
	QueryEndpoint		string	`bson:"query_endpoint" json:"query_endpoint"`
	UseNestedQuery		bool	`bson:"use_nested_query" json:"use_nested_query"`
	ParentDataPath		string	`bson:"parent_data_path" json:"parent_data_path"`
	DataPath		string	`bson:"data_path" json:"data_path"`
	PortDataPath		string	`bson:"port_data_path" json:"port_data_path"`
	TargetPath		string	`bson:"target_path" json:"target_path"`
	UseTargetList		bool	`bson:"use_target_list" json:"use_target_list"`
	CacheDisabled		bool	`bson:"cache_disabled" json:"cache_disabled"`
	CacheTimeout		int64	`bson:"cache_timeout" json:"cache_timeout"`
	EndpointReturnsList	bool	`bson:"endpoint_returns_list" json:"endpoint_returns_list"`
}

SessionProviderCode

This type doesn't have documentation.

Field name Field type Comment
type

string

No comment on field.
type SessionProviderCode string

SessionProviderMeta

This type doesn't have documentation.

Field name Field type Comment
Name

SessionProviderCode

No comment on field.
StorageEngine

StorageEngineCode

No comment on field.
Meta

map[string]any

No comment on field.
type SessionProviderMeta struct {
	Name		SessionProviderCode	`bson:"name" json:"name"`
	StorageEngine	StorageEngineCode	`bson:"storage_engine" json:"storage_engine"`
	Meta		map[string]interface{}	`bson:"meta" json:"meta"`
}

SignatureConfig

This type doesn't have documentation.

Field name Field type Comment
Algorithm

string

No comment on field.
Header

string

No comment on field.
UseParam

bool

No comment on field.
ParamName

string

No comment on field.
Secret

string

No comment on field.
AllowedClockSkew

int64

No comment on field.
ErrorCode

int

No comment on field.
ErrorMessage

string

No comment on field.
type SignatureConfig struct {
	Algorithm		string	`mapstructure:"algorithm" bson:"algorithm" json:"algorithm"`
	Header			string	`mapstructure:"header" bson:"header" json:"header"`
	UseParam		bool	`mapstructure:"use_param" bson:"use_param" json:"use_param"`
	ParamName		string	`mapstructure:"param_name" bson:"param_name" json:"param_name"`
	Secret			string	`mapstructure:"secret" bson:"secret" json:"secret"`
	AllowedClockSkew	int64	`mapstructure:"allowed_clock_skew" bson:"allowed_clock_skew" json:"allowed_clock_skew"`
	ErrorCode		int	`mapstructure:"error_code" bson:"error_code" json:"error_code"`
	ErrorMessage		string	`mapstructure:"error_message" bson:"error_message" json:"error_message"`
}

SourceMode

This type doesn't have documentation.

Field name Field type Comment
type

string

No comment on field.
type SourceMode string

StorageEngineCode

This type doesn't have documentation.

Field name Field type Comment
type

string

No comment on field.
type StorageEngineCode string

StringRegexMap

This type doesn't have documentation.

Field name Field type Comment
MatchPattern

string

No comment on field.
Reverse

bool

No comment on field.
matchRegex

*regexp.Regexp

No comment on field.
type StringRegexMap struct {
	MatchPattern	string	`bson:"match_rx" json:"match_rx"`
	Reverse		bool	`bson:"reverse" json:"reverse"`
	matchRegex	*regexp.Regexp
}

SubscriptionType

This type doesn't have documentation.

Field name Field type Comment
type

string

No comment on field.
type SubscriptionType string

TemplateData

This type doesn't have documentation.

Field name Field type Comment
Input

RequestInputType

No comment on field.
Mode

SourceMode

No comment on field.
EnableSession

bool

No comment on field.
TemplateSource

string

No comment on field.
type TemplateData struct {
	Input		RequestInputType	`bson:"input_type" json:"input_type"`
	Mode		SourceMode		`bson:"template_mode" json:"template_mode"`
	EnableSession	bool			`bson:"enable_session" json:"enable_session"`
	TemplateSource	string			`bson:"template_source" json:"template_source"`
}

TemplateMeta

This type doesn't have documentation.

Field name Field type Comment
Disabled

bool

No comment on field.
TemplateData

TemplateData

No comment on field.
Path

string

No comment on field.
Method

string

No comment on field.
type TemplateMeta struct {
	Disabled	bool		`bson:"disabled" json:"disabled"`
	TemplateData	TemplateData	`bson:"template_data" json:"template_data"`
	Path		string		`bson:"path" json:"path"`
	Method		string		`bson:"method" json:"method"`
}

TrackEndpointMeta

This type doesn't have documentation.

Field name Field type Comment
Disabled

bool

No comment on field.
Path

string

No comment on field.
Method

string

No comment on field.
type TrackEndpointMeta struct {
	Disabled	bool	`bson:"disabled" json:"disabled"`
	Path		string	`bson:"path" json:"path"`
	Method		string	`bson:"method" json:"method"`
}

TransformJQMeta

This type doesn't have documentation.

Field name Field type Comment
Filter

string

No comment on field.
Path

string

No comment on field.
Method

string

No comment on field.
type TransformJQMeta struct {
	Filter	string	`bson:"filter" json:"filter"`
	Path	string	`bson:"path" json:"path"`
	Method	string	`bson:"method" json:"method"`
}

TykEvent

TykEvent is an alias maintained for backwards compatibility.

Field name Field type Comment
type

event.Event

No comment on field.
type TykEvent = event.Event

TykEventHandlerName

TykEventHandlerName is an alias maintained for backwards compatibility.

Field name Field type Comment
type

event.HandlerName

No comment on field.
type TykEventHandlerName = event.HandlerName

UDGGlobalHeader

This type doesn't have documentation.

Field name Field type Comment
Key

string

No comment on field.
Value

string

No comment on field.
type UDGGlobalHeader struct {
	Key	string	`bson:"key" json:"key"`
	Value	string	`bson:"value" json:"value"`
}

URLRewriteMeta

This type doesn't have documentation.

Field name Field type Comment
Disabled

bool

No comment on field.
Path

string

No comment on field.
Method

string

No comment on field.
MatchPattern

string

No comment on field.
RewriteTo

string

No comment on field.
Triggers

[]RoutingTrigger

No comment on field.
MatchRegexp

*regexp.Regexp

No comment on field.
type URLRewriteMeta struct {
	Disabled	bool			`bson:"disabled" json:"disabled"`
	Path		string			`bson:"path" json:"path"`
	Method		string			`bson:"method" json:"method"`
	MatchPattern	string			`bson:"match_pattern" json:"match_pattern"`
	RewriteTo	string			`bson:"rewrite_to" json:"rewrite_to"`
	Triggers	[]RoutingTrigger	`bson:"triggers" json:"triggers"`
	MatchRegexp	*regexp.Regexp		`json:"-"`
}

UpstreamAuth

UpstreamAuth holds the configurations related to upstream API authentication.

Field name Field type Comment
Enabled

bool

Enabled enables upstream API authentication.

BasicAuth

UpstreamBasicAuth

BasicAuth holds the basic authentication configuration for upstream API authentication.

OAuth

UpstreamOAuth

OAuth holds the OAuth2 configuration for the upstream client credentials API authentication.

type UpstreamAuth struct {
	// Enabled enables upstream API authentication.
	Enabled	bool	`bson:"enabled" json:"enabled"`
	// BasicAuth holds the basic authentication configuration for upstream API authentication.
	BasicAuth	UpstreamBasicAuth	`bson:"basic_auth" json:"basic_auth"`
	// OAuth holds the OAuth2 configuration for the upstream client credentials API authentication.
	OAuth	UpstreamOAuth	`bson:"oauth" json:"oauth"`
}

UpstreamBasicAuth

UpstreamBasicAuth holds upstream basic authentication configuration.

Field name Field type Comment
Enabled

bool

Enabled enables upstream basic authentication.

Username

string

Username is the username to be used for upstream basic authentication.

Password

string

Password is the password to be used for upstream basic authentication.

Header

AuthSource

Header holds the configuration for custom header name to be used for upstream basic authentication. Defaults to Authorization.

type UpstreamBasicAuth struct {
	// Enabled enables upstream basic authentication.
	Enabled	bool	`bson:"enabled" json:"enabled,omitempty"`
	// Username is the username to be used for upstream basic authentication.
	Username	string	`bson:"username" json:"username"`
	// Password is the password to be used for upstream basic authentication.
	Password	string	`bson:"password" json:"password"`
	// Header holds the configuration for custom header name to be used for upstream basic authentication.
	// Defaults to `Authorization`.
	Header	AuthSource	`bson:"header" json:"header"`
}

UpstreamOAuth

UpstreamOAuth holds upstream OAuth2 authentication configuration.

Field name Field type Comment
Enabled

bool

Enabled enables upstream OAuth2 authentication.

AllowedAuthorizeTypes

[]string

AllowedAuthorizeTypes specifies the allowed authorization types for upstream OAuth2 authentication.

ClientCredentials

ClientCredentials

ClientCredentials holds the client credentials for upstream OAuth2 authentication.

PasswordAuthentication

PasswordAuthentication

PasswordAuthentication holds the configuration for upstream OAauth password authentication flow.

type UpstreamOAuth struct {
	// Enabled enables upstream OAuth2 authentication.
	Enabled	bool	`bson:"enabled" json:"enabled"`
	// AllowedAuthorizeTypes specifies the allowed authorization types for upstream OAuth2 authentication.
	AllowedAuthorizeTypes	[]string	`bson:"allowed_authorize_types" json:"allowed_authorize_types"`
	// ClientCredentials holds the client credentials for upstream OAuth2 authentication.
	ClientCredentials	ClientCredentials	`bson:"client_credentials" json:"client_credentials"`
	// PasswordAuthentication holds the configuration for upstream OAauth password authentication flow.
	PasswordAuthentication	PasswordAuthentication	`bson:"password,omitempty" json:"password,omitempty"`
}

UptimeTests

UptimeTests holds the test configuration for uptime tests.

Field name Field type Comment
Disabled

bool

Disabled indicates whether the uptime test configuration is disabled.

CheckList

[]HostCheckObject

CheckList represents a collection of HostCheckObject used to define multiple checks in uptime test configurations.

Config

UptimeTestsConfig

Config defines the configuration settings for uptime tests, including analytics expiration and service discovery.

type UptimeTests struct {
	// Disabled indicates whether the uptime test configuration is disabled.
	Disabled	bool	`bson:"disabled" json:"disabled"`
	// CheckList represents a collection of HostCheckObject used to define multiple checks in uptime test configurations.
	CheckList	[]HostCheckObject	`bson:"check_list" json:"check_list"`
	// Config defines the configuration settings for uptime tests, including analytics expiration and service discovery.
	Config	UptimeTestsConfig	`bson:"config" json:"config"`
}

UptimeTestsConfig

This type doesn't have documentation.

Field name Field type Comment
ExpireUptimeAnalyticsAfter

int64

No comment on field.
ServiceDiscovery

ServiceDiscoveryConfiguration

No comment on field.
RecheckWait

int

No comment on field.
type UptimeTestsConfig struct {
	ExpireUptimeAnalyticsAfter	int64				`bson:"expire_utime_after" json:"expire_utime_after"`	// must have an expireAt TTL index set (http://docs.mongodb.org/manual/tutorial/expire-data/)
	ServiceDiscovery		ServiceDiscoveryConfiguration	`bson:"service_discovery" json:"service_discovery"`
	RecheckWait			int				`bson:"recheck_wait" json:"recheck_wait"`
}

ValidatePathMeta

This type doesn't have documentation.

Field name Field type Comment
Disabled

bool

No comment on field.
Path

string

No comment on field.
Method

string

No comment on field.
Schema

map[string]any

No comment on field.
SchemaB64

string

No comment on field.
SchemaCache

gojsonschema.JSONLoader

No comment on field.
ErrorResponseCode

int

Allows override of default 422 Unprocessible Entity response code for validation errors.

type ValidatePathMeta struct {
	Disabled	bool			`bson:"disabled" json:"disabled"`
	Path		string			`bson:"path" json:"path"`
	Method		string			`bson:"method" json:"method"`
	Schema		map[string]interface{}	`bson:"-" json:"schema"`
	SchemaB64	string			`bson:"schema_b64" json:"schema_b64,omitempty"`
	SchemaCache	gojsonschema.JSONLoader	`bson:"-" json:"-"`
	// Allows override of default 422 Unprocessible Entity response code for validation errors.
	ErrorResponseCode	int	`bson:"error_response_code" json:"error_response_code"`
}

ValidateRequestMeta

This type doesn't have documentation.

Field name Field type Comment
Enabled

bool

No comment on field.
Path

string

No comment on field.
Method

string

No comment on field.
ErrorResponseCode

int

Allows override of default 422 Unprocessible Entity response code for validation errors.

type ValidateRequestMeta struct {
	Enabled	bool	`bson:"enabled" json:"enabled"`
	Path	string	`bson:"path" json:"path"`
	Method	string	`bson:"method" json:"method"`
	// Allows override of default 422 Unprocessible Entity response code for validation errors.
	ErrorResponseCode	int	`bson:"error_response_code" json:"error_response_code"`
}

ValidationResult

This type doesn't have documentation.

Field name Field type Comment
IsValid

bool

No comment on field.
Errors

[]error

No comment on field.
type ValidationResult struct {
	IsValid	bool
	Errors	[]error
}

ValidationRule

This type doesn't have documentation.

Field name Field type Comment
type

any

No comment on field.
type ValidationRule interface {
	Validate(apiDef *APIDefinition, validationResult *ValidationResult)
}

ValidationRuleSet

This type doesn't have documentation.

Field name Field type Comment
type

[]ValidationRule

No comment on field.
type ValidationRuleSet []ValidationRule

VersionData

This type doesn't have documentation.

Field name Field type Comment
NotVersioned

bool

No comment on field.
DefaultVersion

string

No comment on field.
Versions

map[string]VersionInfo

No comment on field.
type VersionData struct {
	NotVersioned	bool			`bson:"not_versioned" json:"not_versioned"`
	DefaultVersion	string			`bson:"default_version" json:"default_version"`
	Versions	map[string]VersionInfo	`bson:"versions" json:"versions"`
}

VersionDefinition

VersionDefinition is a struct that holds the versioning information for an API.

Field name Field type Comment
Enabled

bool

Enabled indicates whether this version is enabled or not.

Name

string

Name is the name of this version.

Default

string

Default is the default version to use if no version is specified in the request.

Location

string

Location is the location in the request where the version information can be found.

Key

string

Key is the key to use to extract the version information from the specified location.

StripPath

bool

StripPath is a deprecated field. Use StripVersioningData instead.

StripVersioningData

bool

StripVersioningData indicates whether to strip the versioning data from the request.

UrlVersioningPattern

string

UrlVersioningPattern is the regex pattern to match in the URL for versioning.

FallbackToDefault

bool

FallbackToDefault indicates whether to fallback to the default version if the version in the request does not exist.

Versions

map[string]string

Versions is a map of version names to version ApiIDs.

BaseID

string

BaseID is a hidden field used internally that represents the ApiID of the base API.

type VersionDefinition struct {
	// Enabled indicates whether this version is enabled or not.
	Enabled	bool	`bson:"enabled" json:"enabled"`

	// Name is the name of this version.
	Name	string	`bson:"name" json:"name"`

	// Default is the default version to use if no version is specified in the request.
	Default	string	`bson:"default" json:"default"`

	// Location is the location in the request where the version information can be found.
	Location	string	`bson:"location" json:"location"`

	// Key is the key to use to extract the version information from the specified location.
	Key	string	`bson:"key" json:"key"`

	// StripPath is a deprecated field. Use StripVersioningData instead.
	StripPath	bool	`bson:"strip_path" json:"strip_path"`	// Deprecated. Use StripVersioningData instead.

	// StripVersioningData indicates whether to strip the versioning data from the request.
	StripVersioningData	bool	`bson:"strip_versioning_data" json:"strip_versioning_data"`

	// UrlVersioningPattern is the regex pattern to match in the URL for versioning.
	UrlVersioningPattern	string	`bson:"url_versioning_pattern" json:"url_versioning_pattern"`

	// FallbackToDefault indicates whether to fallback to the default version if the version in the request does not exist.
	FallbackToDefault	bool	`bson:"fallback_to_default" json:"fallback_to_default"`

	// Versions is a map of version names to version ApiIDs.
	Versions	map[string]string	`bson:"versions" json:"versions"`

	// BaseID is a hidden field used internally that represents the ApiID of the base API.
	BaseID	string	`bson:"base_id" json:"-"`	// json tag is `-` because we want this to be hidden to user
}

VersionInfo

This type doesn't have documentation.

Field name Field type Comment
Name

string

No comment on field.
Expires

string

No comment on field.
ExpiresTs

time.Time

No comment on field.
Paths

struct { Ignored []string `bson:"ignored" json:"ignored"` WhiteList []string `bson:"white_list" json:"white_list"` BlackList []string `bson:"black_list" json:"black_list"` }

No comment on field.
UseExtendedPaths

bool

No comment on field.
ExtendedPaths

ExtendedPathsSet

No comment on field.
GlobalHeaders

map[string]string

No comment on field.
GlobalHeadersRemove

[]string

No comment on field.
GlobalHeadersDisabled

bool

No comment on field.
GlobalResponseHeaders

map[string]string

No comment on field.
GlobalResponseHeadersRemove

[]string

No comment on field.
GlobalResponseHeadersDisabled

bool

No comment on field.
IgnoreEndpointCase

bool

No comment on field.
GlobalSizeLimit

int64

No comment on field.
GlobalSizeLimitDisabled

bool

No comment on field.
OverrideTarget

string

No comment on field.
type VersionInfo struct {
	Name		string		`bson:"name" json:"name"`
	Expires		string		`bson:"expires" json:"expires"`
	ExpiresTs	time.Time	`bson:"-" json:"-"`
	Paths		struct {
		Ignored		[]string	`bson:"ignored" json:"ignored"`
		WhiteList	[]string	`bson:"white_list" json:"white_list"`
		BlackList	[]string	`bson:"black_list" json:"black_list"`
	}	`bson:"paths" json:"paths"`
	UseExtendedPaths		bool			`bson:"use_extended_paths" json:"use_extended_paths"`
	ExtendedPaths			ExtendedPathsSet	`bson:"extended_paths" json:"extended_paths"`
	GlobalHeaders			map[string]string	`bson:"global_headers" json:"global_headers"`
	GlobalHeadersRemove		[]string		`bson:"global_headers_remove" json:"global_headers_remove"`
	GlobalHeadersDisabled		bool			`bson:"global_headers_disabled" json:"global_headers_disabled"`
	GlobalResponseHeaders		map[string]string	`bson:"global_response_headers" json:"global_response_headers"`
	GlobalResponseHeadersRemove	[]string		`bson:"global_response_headers_remove" json:"global_response_headers_remove"`
	GlobalResponseHeadersDisabled	bool			`bson:"global_response_headers_disabled" json:"global_response_headers_disabled"`
	IgnoreEndpointCase		bool			`bson:"ignore_endpoint_case" json:"ignore_endpoint_case"`
	GlobalSizeLimit			int64			`bson:"global_size_limit" json:"global_size_limit"`
	GlobalSizeLimitDisabled		bool			`bson:"global_size_limit_disabled" json:"global_size_limit_disabled"`
	OverrideTarget			string			`bson:"override_target" json:"override_target"`
}

VirtualMeta

This type doesn't have documentation.

Field name Field type Comment
Disabled

bool

No comment on field.
ResponseFunctionName

string

No comment on field.
FunctionSourceType

SourceMode

No comment on field.
FunctionSourceURI

string

No comment on field.
Path

string

No comment on field.
Method

string

No comment on field.
UseSession

bool

No comment on field.
ProxyOnError

bool

No comment on field.
type VirtualMeta struct {
	Disabled		bool		`bson:"disabled" json:"disabled"`
	ResponseFunctionName	string		`bson:"response_function_name" json:"response_function_name"`
	FunctionSourceType	SourceMode	`bson:"function_source_type" json:"function_source_type"`
	FunctionSourceURI	string		`bson:"function_source_uri" json:"function_source_uri"`
	Path			string		`bson:"path" json:"path"`
	Method			string		`bson:"method" json:"method"`
	UseSession		bool		`bson:"use_session" json:"use_session"`
	ProxyOnError		bool		`bson:"proxy_on_error" json:"proxy_on_error"`
}

WebHookHandlerConf

WebHookHandlerConf holds configuration related to webhook event handler.

Field name Field type Comment
Disabled

bool

Disabled enables/disables this webhook.

ID

string

ID optional ID of the webhook, to be used in pro mode.

Name

string

Name is the name of webhook.

Method

string

The method to use for the webhook.

TargetPath

string

The target path on which to send the request.

TemplatePath

string

The template to load in order to format the request.

HeaderList

map[string]string

Headers to set when firing the webhook.

EventTimeout

int64

The cool-down for the event so it does not trigger again (in seconds).

type WebHookHandlerConf struct {
	// Disabled enables/disables this webhook.
	Disabled	bool	`bson:"disabled" json:"disabled"`
	// ID optional ID of the webhook, to be used in pro mode.
	ID	string	`bson:"id" json:"id"`
	// Name is the name of webhook.
	Name	string	`bson:"name" json:"name"`
	// The method to use for the webhook.
	Method	string	`bson:"method" json:"method"`
	// The target path on which to send the request.
	TargetPath	string	`bson:"target_path" json:"target_path"`
	// The template to load in order to format the request.
	TemplatePath	string	`bson:"template_path" json:"template_path"`
	// Headers to set when firing the webhook.
	HeaderList	map[string]string	`bson:"header_map" json:"header_map"`
	// The cool-down for the event so it does not trigger again (in seconds).
	EventTimeout	int64	`bson:"event_timeout" json:"event_timeout"`
}

HealthCheckStatus, HealthCheckComponentType

This type doesn't have documentation.

Field name Field type Comment
type

string

No comment on field.
type

string

No comment on field.
type (
	HealthCheckStatus	string

	HealthCheckComponentType	string
)

Functions

func DummyAPI

func DummyAPI() APIDefinition {
	endpointMeta := EndPointMeta{
		Path:	"abc",
		MethodActions: map[string]EndpointMethodMeta{
			"GET": {
				Action:		Reply,
				Code:		200,
				Data:		"testdata",
				Headers:	map[string]string{"header": "value"},
			},
		},
	}
	templateMeta := TemplateMeta{
		TemplateData: TemplateData{Input: RequestJSON, Mode: UseBlob},
	}
	transformJQMeta := TransformJQMeta{
		Filter:	"filter",
		Path:	"path",
		Method:	"method",
	}
	headerInjectionMeta := HeaderInjectionMeta{
		DeleteHeaders:	[]string{"header1", "header2"},
		AddHeaders:	map[string]string{},
		Path:		"path",
		Method:		"method",
	}
	hardTimeoutMeta := HardTimeoutMeta{Path: "path", Method: "method", TimeOut: 0}
	circuitBreakerMeta := CircuitBreakerMeta{
		Path:			"path",
		Method:			"method",
		ThresholdPercent:	0.0,
		Samples:		0,
		ReturnToServiceAfter:	0,
	}
	// TODO: Extend triggers
	urlRewriteMeta := URLRewriteMeta{
		Path:		"",
		Method:		"method",
		MatchPattern:	"matchpattern",
		RewriteTo:	"rewriteto",
		Triggers:	[]RoutingTrigger{},
	}
	virtualMeta := VirtualMeta{
		ResponseFunctionName:	"responsefunctioname",
		FunctionSourceType:	"functionsourcetype",
		FunctionSourceURI:	"functionsourceuri",
		Path:			"path",
		Method:			"method",
	}
	sizeLimit := RequestSizeMeta{
		Path:		"path",
		Method:		"method",
		SizeLimit:	0,
	}
	methodTransformMeta := MethodTransformMeta{Path: "path", Method: "method", ToMethod: "tomethod"}
	trackEndpointMeta := TrackEndpointMeta{Path: "path", Method: "method"}
	internalMeta := InternalMeta{Path: "path", Method: "method"}
	validatePathMeta := ValidatePathMeta{Path: "path", Method: "method", Schema: map[string]interface{}{}, SchemaB64: ""}
	paths := struct {
		Ignored		[]string	`bson:"ignored" json:"ignored"`
		WhiteList	[]string	`bson:"white_list" json:"white_list"`
		BlackList	[]string	`bson:"black_list" json:"black_list"`
	}{
		Ignored:	[]string{},
		WhiteList:	[]string{},
		BlackList:	[]string{},
	}
	versionInfo := VersionInfo{
		Name:			"Default",
		UseExtendedPaths:	true,
		Paths:			paths,
		ExtendedPaths: ExtendedPathsSet{
			Ignored:			[]EndPointMeta{endpointMeta},
			WhiteList:			[]EndPointMeta{endpointMeta},
			BlackList:			[]EndPointMeta{endpointMeta},
			Cached:				[]string{},
			Transform:			[]TemplateMeta{templateMeta},
			TransformResponse:		[]TemplateMeta{templateMeta},
			TransformJQ:			[]TransformJQMeta{transformJQMeta},
			TransformJQResponse:		[]TransformJQMeta{transformJQMeta},
			TransformHeader:		[]HeaderInjectionMeta{headerInjectionMeta},
			TransformResponseHeader:	[]HeaderInjectionMeta{headerInjectionMeta},
			HardTimeouts:			[]HardTimeoutMeta{hardTimeoutMeta},
			CircuitBreaker:			[]CircuitBreakerMeta{circuitBreakerMeta},
			URLRewrite:			[]URLRewriteMeta{urlRewriteMeta},
			Virtual:			[]VirtualMeta{virtualMeta},
			SizeLimit:			[]RequestSizeMeta{sizeLimit},
			MethodTransforms:		[]MethodTransformMeta{methodTransformMeta},
			TrackEndpoints:			[]TrackEndpointMeta{trackEndpointMeta},
			DoNotTrackEndpoints:		[]TrackEndpointMeta{trackEndpointMeta},
			Internal:			[]InternalMeta{internalMeta},
			ValidateJSON:			[]ValidatePathMeta{validatePathMeta},
		},
	}
	versionData := struct {
		NotVersioned	bool			`bson:"not_versioned" json:"not_versioned"`
		DefaultVersion	string			`bson:"default_version" json:"default_version"`
		Versions	map[string]VersionInfo	`bson:"versions" json:"versions"`
	}{
		NotVersioned:	true,
		DefaultVersion:	"",
		Versions: map[string]VersionInfo{
			"Default": versionInfo,
		},
	}

	defaultCORSConfig := CORSConfig{
		Enable:		false,
		AllowedOrigins:	[]string{"*"},
		AllowedMethods:	[]string{http.MethodGet, http.MethodPost, http.MethodHead},
		AllowedHeaders:	[]string{"Origin", "Accept", "Content-Type", "X-Requested-With", "Authorization"},
	}

	graphql := GraphQLConfig{
		Enabled:		false,
		ExecutionMode:		GraphQLExecutionModeProxyOnly,
		Version:		GraphQLConfigVersion2,
		LastSchemaUpdate:	nil,
		Proxy: GraphQLProxyConfig{
			Features: GraphQLProxyFeaturesConfig{
				UseImmutableHeaders: true,
			},
			AuthHeaders:	map[string]string{},
		},
	}

	return APIDefinition{
		VersionData:		versionData,
		ConfigData:		map[string]interface{}{},
		AllowedIPs:		[]string{},
		PinnedPublicKeys:	map[string]string{},
		ResponseProcessors:	[]ResponseProcessor{},
		ClientCertificates:	[]string{},
		BlacklistedIPs:		[]string{},
		TagHeaders:		[]string{},
		UpstreamCertificates:	map[string]string{},
		Scopes: Scopes{
			JWT: ScopeClaim{
				ScopeToPolicy: map[string]string{},
			},
			OIDC: ScopeClaim{
				ScopeToPolicy: map[string]string{},
			},
		},
		HmacAllowedAlgorithms:	[]string{},
		CustomMiddleware: MiddlewareSection{
			Post:		[]MiddlewareDefinition{},
			Pre:		[]MiddlewareDefinition{},
			PostKeyAuth:	[]MiddlewareDefinition{},
			AuthCheck:	MiddlewareDefinition{},
			IdExtractor: MiddlewareIdExtractor{
				ExtractorConfig: map[string]interface{}{},
			},
		},
		Proxy: ProxyConfig{
			DisableStripSlash: true,
		},
		CORS:		defaultCORSConfig,
		Tags:		[]string{},
		GraphQL:	graphql,
	}
}

Cognitive complexity: 86, Cyclomatic complexity: 1

Uses: http.MethodGet, http.MethodHead, http.MethodPost.

func NewHostList

func NewHostList() *HostList {
	hl := HostList{}
	hl.hosts = make([]string, 0)
	return &hl
}

Cognitive complexity: 1, Cyclomatic complexity: 1

func NewHostListFromList

func NewHostListFromList(newList []string) *HostList {
	hl := NewHostList()
	hl.Set(newList)
	return hl
}

Cognitive complexity: 0, Cyclomatic complexity: 1

func NewRoutingTriggerOptions

NewRoutingTriggerOptions allocates the maps inside RoutingTriggerOptions.

func NewRoutingTriggerOptions() RoutingTriggerOptions {
	return RoutingTriggerOptions{
		HeaderMatches:		make(map[string]StringRegexMap),
		QueryValMatches:	make(map[string]StringRegexMap),
		PathPartMatches:	make(map[string]StringRegexMap),
		SessionMetaMatches:	make(map[string]StringRegexMap),
		RequestContextMatches:	make(map[string]StringRegexMap),
		PayloadMatches:		StringRegexMap{},
	}
}

Cognitive complexity: 2, Cyclomatic complexity: 1

func Validate

func Validate(definition *APIDefinition, ruleSet ValidationRuleSet) ValidationResult {
	result := ValidationResult{
		IsValid:	true,
		Errors:		nil,
	}

	for _, rule := range ruleSet {
		rule.Validate(definition, &result)
	}

	return result
}

Cognitive complexity: 4, Cyclomatic complexity: 2

func (*APIDefinition) DecodeFromDB

func (a *APIDefinition) DecodeFromDB() {
	newVersion := make(map[string]VersionInfo)
	for k, v := range a.VersionData.Versions {
		newK, err := base64.StdEncoding.DecodeString(k)
		if err != nil {
			log.Error("Couldn't Decode, leaving as it may be legacy...")
			newVersion[k] = v
		} else {
			v.Name = string(newK)
			newVersion[string(newK)] = v
		}
	}
	a.VersionData.Versions = newVersion

	newUpstreamCerts := make(map[string]string)
	for domain, cert := range a.UpstreamCertificates {
		newD, err := base64.StdEncoding.DecodeString(domain)
		if err != nil {
			log.Error("Couldn't Decode, leaving as it may be legacy...")
			newUpstreamCerts[domain] = cert
		} else {
			newUpstreamCerts[string(newD)] = cert
		}
	}
	a.UpstreamCertificates = newUpstreamCerts

	newPinnedPublicKeys := make(map[string]string)
	for domain, cert := range a.PinnedPublicKeys {
		newD, err := base64.StdEncoding.DecodeString(domain)
		if err != nil {
			log.Error("Couldn't Decode, leaving as it may be legacy...")
			newPinnedPublicKeys[domain] = cert
		} else {
			newPinnedPublicKeys[string(newD)] = cert
		}
	}
	a.PinnedPublicKeys = newPinnedPublicKeys

	for i, version := range a.VersionData.Versions {
		for j, oldSchema := range version.ExtendedPaths.ValidateJSON {
			jsBytes, _ := base64.StdEncoding.DecodeString(oldSchema.SchemaB64)

			json.Unmarshal(jsBytes, &oldSchema.Schema)
			oldSchema.SchemaB64 = ""

			a.VersionData.Versions[i].ExtendedPaths.ValidateJSON[j] = oldSchema
		}
	}

	// Auth is deprecated so this code tries to maintain backward compatibility
	makeCompatible := func(authType string, enabled bool) {
		if a.AuthConfigs == nil {
			a.AuthConfigs = make(map[string]AuthConfig)
		}

		_, ok := a.AuthConfigs[authType]

		if !ok && enabled {
			a.AuthConfigs[authType] = a.Auth
		}
	}

	makeCompatible("authToken", a.UseStandardAuth)
	makeCompatible("jwt", a.EnableJWT)
}

Cognitive complexity: 32, Cyclomatic complexity: 12

Uses: base64.StdEncoding, json.Unmarshal.

func (*APIDefinition) EncodeForDB

EncodeForDB will encode map[string]struct variables for saving in URL format

func (a *APIDefinition) EncodeForDB() {
	newVersion := make(map[string]VersionInfo)
	for k, v := range a.VersionData.Versions {
		newK := base64.StdEncoding.EncodeToString([]byte(k))
		v.Name = newK
		newVersion[newK] = v
	}
	a.VersionData.Versions = newVersion

	newUpstreamCerts := make(map[string]string)
	for domain, cert := range a.UpstreamCertificates {
		newD := base64.StdEncoding.EncodeToString([]byte(domain))
		newUpstreamCerts[newD] = cert
	}
	a.UpstreamCertificates = newUpstreamCerts

	newPinnedPublicKeys := make(map[string]string)
	for domain, cert := range a.PinnedPublicKeys {
		newD := base64.StdEncoding.EncodeToString([]byte(domain))
		newPinnedPublicKeys[newD] = cert
	}
	a.PinnedPublicKeys = newPinnedPublicKeys

	for i, version := range a.VersionData.Versions {
		for j, oldSchema := range version.ExtendedPaths.ValidateJSON {

			jsBytes, _ := json.Marshal(oldSchema.Schema)
			oldSchema.SchemaB64 = base64.StdEncoding.EncodeToString(jsBytes)

			a.VersionData.Versions[i].ExtendedPaths.ValidateJSON[j] = oldSchema
		}
	}

	// Auth is deprecated so this code tries to maintain backward compatibility
	if a.Auth.AuthHeaderName == "" {
		a.Auth = a.AuthConfigs["authToken"]
	}
}

Cognitive complexity: 17, Cyclomatic complexity: 7

Uses: base64.StdEncoding, json.Marshal.

func (*APIDefinition) GenerateAPIID

func (a *APIDefinition) GenerateAPIID() {
	a.APIID = uuid.NewHex()
}

Cognitive complexity: 0, Cyclomatic complexity: 1

Uses: uuid.NewHex.

func (*APIDefinition) GetAPIDomain

func (a *APIDefinition) GetAPIDomain() string {
	if a.DomainDisabled {
		return ""
	}
	return a.Domain
}

Cognitive complexity: 2, Cyclomatic complexity: 2

func (*APIDefinition) GetScopeClaimName

func (a *APIDefinition) GetScopeClaimName() string {
	if reflect.IsEmpty(a.Scopes) {
		return a.JWTScopeClaimName
	}

	if a.UseOpenID {
		return a.Scopes.OIDC.ScopeClaimName
	}

	return a.Scopes.JWT.ScopeClaimName
}

Cognitive complexity: 4, Cyclomatic complexity: 3

Uses: reflect.IsEmpty.

func (*APIDefinition) GetScopeToPolicyMapping

func (a *APIDefinition) GetScopeToPolicyMapping() map[string]string {
	if reflect.IsEmpty(a.Scopes) {
		return a.JWTScopeToPolicyMapping
	}

	if a.UseOpenID {
		return a.Scopes.OIDC.ScopeToPolicy
	}

	return a.Scopes.JWT.ScopeToPolicy
}

Cognitive complexity: 4, Cyclomatic complexity: 3

Uses: reflect.IsEmpty.

func (*APIDefinition) Migrate

func (a *APIDefinition) Migrate() (versions []APIDefinition, err error) {
	a.migrateCustomPluginAuth()
	a.MigrateAuthentication()
	a.migratePluginBundle()
	a.migratePluginConfigData()
	a.migrateMutualTLS()
	a.migrateCertificatePinning()
	a.migrateGatewayTags()
	a.migrateAuthenticationPlugin()
	a.migrateIDExtractor()
	a.migrateCustomDomain()
	a.migrateScopeToPolicy()
	a.migrateResponseProcessors()
	a.migrateGlobalRateLimit()
	a.migrateIPAccessControl()

	versions, err = a.MigrateVersioning()
	if err != nil {
		return nil, err
	}

	a.MigrateEndpointMeta()
	a.MigrateCachePlugin()
	a.migrateGlobalHeaders()
	a.migrateGlobalResponseHeaders()
	for i := 0; i < len(versions); i++ {
		versions[i].MigrateEndpointMeta()
		versions[i].MigrateCachePlugin()
		versions[i].migrateGlobalHeaders()
		versions[i].migrateGlobalResponseHeaders()
	}

	return versions, nil
}

Cognitive complexity: 4, Cyclomatic complexity: 3

func (*APIDefinition) MigrateAuthentication

func (a *APIDefinition) MigrateAuthentication() {
	a.deleteAuthConfigsNotUsed()
	for k, v := range a.AuthConfigs {
		v.Name = k
		a.AuthConfigs[k] = v
	}
}

Cognitive complexity: 3, Cyclomatic complexity: 2

func (*APIDefinition) MigrateCachePlugin

func (a *APIDefinition) MigrateCachePlugin() {
	vInfo := a.VersionData.Versions[""]
	list := vInfo.ExtendedPaths.Cached

	if vInfo.UseExtendedPaths && len(list) > 0 {
		var advCacheMethods []CacheMeta
		for _, cache := range list {
			newGetMethodCache := createAdvancedCacheConfig(a.CacheOptions, cache, http.MethodGet)
			newHeadMethodCache := createAdvancedCacheConfig(a.CacheOptions, cache, http.MethodHead)
			newOptionsMethodCache := createAdvancedCacheConfig(a.CacheOptions, cache, http.MethodOptions)

			advCacheMethods = append(advCacheMethods, newGetMethodCache, newHeadMethodCache, newOptionsMethodCache)
		}

		// Combine the new method-specific cache configs with any existing advanced configs
		// Note: existing configs are added last so they have higher priority (last wins)
		vInfo.ExtendedPaths.AdvanceCacheConfig = append(advCacheMethods, vInfo.ExtendedPaths.AdvanceCacheConfig...)

		// Clear the old simple cache paths since they've been migrated to the advanced configuration
		vInfo.ExtendedPaths.Cached = nil
	}

	a.VersionData.Versions[""] = vInfo
}

Cognitive complexity: 5, Cyclomatic complexity: 4

Uses: http.MethodGet, http.MethodHead, http.MethodOptions.

func (*APIDefinition) MigrateEndpointMeta

func (a *APIDefinition) MigrateEndpointMeta() {
	a.migrateEndpointMetaByType(typeIgnore)
	a.migrateEndpointMetaByType(typeBlacklist)
	a.migrateEndpointMetaByType(typeWhitelist)
}

Cognitive complexity: 0, Cyclomatic complexity: 1

func (*APIDefinition) MigrateVersioning

func (a *APIDefinition) MigrateVersioning() (versions []APIDefinition, err error) {
	if a.VersionDefinition.Enabled || len(a.VersionDefinition.Versions) != 0 {
		return nil, ErrMigrationNewVersioningEnabled
	}

	if a.VersionData.NotVersioned && len(a.VersionData.Versions) > 1 {
		return nil, errors.New("not migratable - if not versioned, there should be just one version info in versions map")
	}

	a.VersionDefinition.Enabled = !a.VersionData.NotVersioned
	if a.VersionDefinition.Enabled {
		a.VersionDefinition.Default = Self
	}

	base := a.VersionData.DefaultVersion
	var baseVInfo VersionInfo
	var found bool
	if baseVInfo, found = a.VersionData.Versions[base]; !found {
		a.VersionDefinition.Default = ""
		base = "Default"
		if baseVInfo, found = a.VersionData.Versions[base]; !found {
			var sortedVersionNames []string
			for vName := range a.VersionData.Versions {
				sortedVersionNames = append(sortedVersionNames, vName)
			}

			sort.Strings(sortedVersionNames)
			if len(sortedVersionNames) > 0 {
				base = sortedVersionNames[0]
			}

			baseVInfo = a.VersionData.Versions[base]
		}
	}

	delete(a.VersionData.Versions, base)
	a.VersionName = base

	if a.VersionDefinition.Enabled {
		a.VersionDefinition.Name = base

		for vName, vInfo := range a.VersionData.Versions {
			newAPI := *a

			apiID := uuid.NewHex()

			newAPI.APIID = apiID
			newAPI.Id = ""
			newAPI.Name += "-" + url.QueryEscape(vName)
			newAPI.Internal = true

			listenPathClean := strings.TrimSuffix(newAPI.Proxy.ListenPath, "/")
			if listenPathClean == "" {
				listenPathClean = "/" + url.QueryEscape(vName) + "/"
			} else {
				listenPathClean += "-" + url.QueryEscape(vName) + "/"
			}

			newAPI.Proxy.ListenPath = listenPathClean

			newAPI.VersionDefinition = VersionDefinition{BaseID: a.APIID}
			newAPI.VersionName = vName

			// Version API Expires migration
			newAPI.Expiration = vInfo.Expires
			vInfo.Expires = ""

			// Version API OverrideTarget migration
			if vInfo.OverrideTarget != "" {
				newAPI.Proxy.TargetURL = vInfo.OverrideTarget
				vInfo.OverrideTarget = ""
			}

			newAPI.VersionData = VersionData{
				NotVersioned:	true,
				Versions: map[string]VersionInfo{
					"": vInfo,
				},
			}

			if a.VersionDefinition.Versions == nil {
				a.VersionDefinition.Versions = make(map[string]string)
			}

			a.VersionDefinition.Versions[vName] = newAPI.APIID

			versions = append(versions, newAPI)
		}

		sort.Slice(versions, func(i, j int) bool {
			return versions[i].VersionName < versions[j].VersionName
		})
	}

	// Base API StripPath migration
	if a.VersionDefinition.Location == URLLocation {
		a.VersionDefinition.StripVersioningData = a.VersionDefinition.StripPath
	}

	a.VersionDefinition.StripPath = false

	// Base API Expires migration
	if a.VersionDefinition.Enabled {
		a.Expiration = baseVInfo.Expires
	}

	baseVInfo.Expires = ""

	// Base API OverrideTarget migration
	if baseVInfo.OverrideTarget != "" {
		a.Proxy.TargetURL = baseVInfo.OverrideTarget
		baseVInfo.OverrideTarget = ""
	}

	a.VersionData = VersionData{
		NotVersioned:	true,
		Versions: map[string]VersionInfo{
			"": baseVInfo,
		},
	}

	// If versioning is not enabled and versions list are empty at this point, ignore key and location and drop them too.
	if !a.VersionDefinition.Enabled && len(versions) == 0 {
		a.VersionDefinition = VersionDefinition{}
	}

	return
}

Cognitive complexity: 43, Cyclomatic complexity: 20

Uses: errors.New, sort.Slice, sort.Strings, strings.TrimSuffix, url.QueryEscape, uuid.NewHex.

func (*APIDefinition) SetDisabledFlags

SetDisabledFlags set disabled flags to true, since by default they are not enabled in OAS API definition.

func (a *APIDefinition) SetDisabledFlags() {
	a.CustomMiddleware.AuthCheck.Disabled = true
	a.TagsDisabled = true
	a.UpstreamCertificatesDisabled = true
	a.CertificatePinningDisabled = true
	a.DomainDisabled = true
	a.CustomMiddlewareBundleDisabled = true
	a.CustomMiddleware.IdExtractor.Disabled = true
	a.ConfigDataDisabled = true
	a.Proxy.ServiceDiscovery.CacheDisabled = true
	a.UptimeTests.Config.ServiceDiscovery.CacheDisabled = true
	for i := 0; i < len(a.CustomMiddleware.Pre); i++ {
		a.CustomMiddleware.Pre[i].Disabled = true
	}

	for i := 0; i < len(a.CustomMiddleware.PostKeyAuth); i++ {
		a.CustomMiddleware.PostKeyAuth[i].Disabled = true
	}

	for i := 0; i < len(a.CustomMiddleware.Post); i++ {
		a.CustomMiddleware.Post[i].Disabled = true
	}

	for i := 0; i < len(a.CustomMiddleware.Response); i++ {
		a.CustomMiddleware.Response[i].Disabled = true
	}

	for version := range a.VersionData.Versions {
		for i := 0; i < len(a.VersionData.Versions[version].ExtendedPaths.Virtual); i++ {
			a.VersionData.Versions[version].ExtendedPaths.Virtual[i].Disabled = true
		}

		for i := 0; i < len(a.VersionData.Versions[version].ExtendedPaths.GoPlugin); i++ {
			a.VersionData.Versions[version].ExtendedPaths.GoPlugin[i].Disabled = true
		}
	}

	if a.GlobalRateLimit.Per <= 0 || a.GlobalRateLimit.Rate <= 0 {
		a.GlobalRateLimit.Disabled = true
	}

	a.DoNotTrack = true

	a.setEventHandlersDisabledFlags()
}

Cognitive complexity: 17, Cyclomatic complexity: 10

func (*ExtendedPathsSet) Clear

Clear omits values that have OAS API definition conversions in place.

func (e *ExtendedPathsSet) Clear() {
	// The values listed within don't have a conversion from OAS in place.
	// When the conversion is added, delete the individual field to clear it.
	*e = ExtendedPathsSet{
		TransformJQ:		e.TransformJQ,
		TransformJQResponse:	e.TransformJQResponse,
		PersistGraphQL:		e.PersistGraphQL,
	}
}

Cognitive complexity: 1, Cyclomatic complexity: 1

func (*HeaderInjectionMeta) Enabled

func (h *HeaderInjectionMeta) Enabled() bool {
	return !h.Disabled && (len(h.AddHeaders) > 0 || len(h.DeleteHeaders) > 0)
}

Cognitive complexity: 0, Cyclomatic complexity: 3

func (*HostCheckObject) AddCommand

AddCommand will append a new command to the test.

func (h *HostCheckObject) AddCommand(name, message string) {
	command := CheckCommand{
		Name:		name,
		Message:	message,
	}

	h.Commands = append(h.Commands, command)
}

Cognitive complexity: 1, Cyclomatic complexity: 1

func (*HostList) All

func (h *HostList) All() []string {
	return h.hosts
}

Cognitive complexity: 0, Cyclomatic complexity: 1

func (*HostList) GetIndex

func (h *HostList) GetIndex(i int) (string, error) {
	if i < 0 {
		return "", errors.New("index must be positive int")
	}
	h.hMutex.RLock()
	defer h.hMutex.RUnlock()

	if i > len(h.hosts)-1 {
		return "", errors.New("index out of range")
	}

	return h.hosts[i], nil
}

Cognitive complexity: 4, Cyclomatic complexity: 3

Uses: errors.New.

func (*HostList) Len

func (h *HostList) Len() int {
	h.hMutex.RLock()
	defer h.hMutex.RUnlock()
	return len(h.hosts)
}

Cognitive complexity: 0, Cyclomatic complexity: 1

func (*HostList) Set

func (h *HostList) Set(newList []string) {
	h.hMutex.Lock()
	defer h.hMutex.Unlock()

	h.hosts = newList
}

Cognitive complexity: 0, Cyclomatic complexity: 1

func (*JSVMEventHandlerConf) Scan

Scan populates the JSVMEventHandlerConf struct by casting and copying data from the provided input.

func (j *JSVMEventHandlerConf) Scan(in any) error {
	conf, err := reflect.Cast[JSVMEventHandlerConf](in)
	if err != nil {
		return err
	}

	*j = *conf
	return nil
}

Cognitive complexity: 2, Cyclomatic complexity: 2

Uses: reflect.Cast.

func (*LogEventHandlerConf) Scan

Scan extracts data from the input into the LogEventHandlerConf struct by performing type conversion.

func (l *LogEventHandlerConf) Scan(in any) error {
	conf, err := reflect.Cast[LogEventHandlerConf](in)
	if err != nil {
		return err
	}
	*l = *conf
	return nil
}

Cognitive complexity: 2, Cyclomatic complexity: 2

Uses: reflect.Cast.

func (*RateLimitMeta) Err

Err checks the rate limit configuration for validity and returns an error if it is not valid. It checks for a nil value, the enabled flag and valid values for each setting.

func (r *RateLimitMeta) Err() error {
	if r == nil || r.Disabled {
		return errors.New("rate limit disabled")
	}
	if r.Per <= 0 {
		return fmt.Errorf("rate limit disabled: per invalid")
	}
	if r.Rate == 0 {
		return fmt.Errorf("rate limit disabled: rate zero")
	}
	return nil
}

Cognitive complexity: 6, Cyclomatic complexity: 5

Uses: errors.New, fmt.Errorf.

func (*RateLimitMeta) Valid

Valid will return true if the rate limit should be applied.

func (r *RateLimitMeta) Valid() bool {
	if err := r.Err(); err != nil {
		return false
	}
	return true
}

Cognitive complexity: 2, Cyclomatic complexity: 2

func (*RateLimitSmoothing) Err

Err checks the rate limit smoothing configuration for validity and returns an error if it is not valid. It checks for a nil value, the enabled flag and valid values for each setting.

func (r *RateLimitSmoothing) Err() error {
	if r == nil || !r.Enabled {
		return errors.New("rate limit smoothing disabled")
	}

	if r.Step <= 0 {
		return fmt.Errorf("rate limit smoothing disabled: step invalid")
	}
	if r.Delay <= 0 {
		return fmt.Errorf("rate limit smoothing disabled: delay invalid")
	}
	if r.Threshold <= 0 {
		return fmt.Errorf("rate limit smoothing disabled: threshold invalid")
	}
	if r.Trigger <= 0 {
		return fmt.Errorf("rate limit smoothing disabled: trigger invalid")
	}

	return nil
}

Cognitive complexity: 10, Cyclomatic complexity: 7

Uses: errors.New, fmt.Errorf.

func (*RateLimitSmoothing) Valid

Valid will return true if the rate limit smoothing should be applied.

func (r *RateLimitSmoothing) Valid() bool {
	if err := r.Err(); err != nil {
		return false
	}
	return true
}

Cognitive complexity: 2, Cyclomatic complexity: 2

func (*RuleAtLeastEnableOneAuthSource) Validate

func (r *RuleAtLeastEnableOneAuthSource) Validate(apiDef *APIDefinition, validationResult *ValidationResult) {
	authConfigs := make([]string, len(apiDef.AuthConfigs))
	i := 0
	for name := range apiDef.AuthConfigs {
		authConfigs[i] = name
		i++
	}

	sort.Strings(authConfigs)

	for _, name := range authConfigs {
		if shouldValidateAuthSource(name, apiDef) &&
			!(apiDef.AuthConfigs[name].UseParam || apiDef.AuthConfigs[name].UseCookie || !apiDef.AuthConfigs[name].DisableHeader) {
			validationResult.IsValid = false
			validationResult.AppendError(fmt.Errorf(ErrAllAuthSourcesDisabled, name))
		}
	}

}

Cognitive complexity: 8, Cyclomatic complexity: 7

Uses: fmt.Errorf, sort.Strings.

func (*RuleUniqueDataSourceNames) Validate

func (r *RuleUniqueDataSourceNames) Validate(apiDef *APIDefinition, validationResult *ValidationResult) {
	if apiDef.GraphQL.Engine.DataSources == nil || len(apiDef.GraphQL.Engine.DataSources) <= 1 {
		return
	}

	usedNames := map[string]bool{}
	for _, ds := range apiDef.GraphQL.Engine.DataSources {
		trimmedName := strings.TrimSpace(strings.ToLower(ds.Name))
		if usedNames[trimmedName] {
			validationResult.IsValid = false
			validationResult.AppendError(ErrDuplicateDataSourceName)
			return
		}

		usedNames[trimmedName] = true
	}
}

Cognitive complexity: 8, Cyclomatic complexity: 5

Uses: strings.ToLower, strings.TrimSpace.

func (*RuleUpstreamAuth) Validate

Validate validates api definition upstream authentication configurations.

func (r *RuleUpstreamAuth) Validate(apiDef *APIDefinition, validationResult *ValidationResult) {
	upstreamAuth := apiDef.UpstreamAuth

	if !upstreamAuth.IsEnabled() {
		return
	}

	if upstreamAuth.BasicAuth.Enabled && upstreamAuth.OAuth.Enabled {
		validationResult.IsValid = false
		validationResult.AppendError(ErrMultipleUpstreamAuthEnabled)
	}

	upstreamOAuth := upstreamAuth.OAuth
	// only OAuth checks moving forward
	if !upstreamOAuth.IsEnabled() {
		return
	}

	if len(upstreamOAuth.AllowedAuthorizeTypes) == 0 {
		validationResult.IsValid = false
		validationResult.AppendError(ErrUpstreamOAuthAuthorizationTypeRequired)
		return
	}

	if len(upstreamAuth.OAuth.AllowedAuthorizeTypes) > 1 {
		validationResult.IsValid = false
		validationResult.AppendError(ErrMultipleUpstreamOAuthAuthorizationType)
	}

	if authType := upstreamAuth.OAuth.AllowedAuthorizeTypes[0]; authType != OAuthAuthorizationTypeClientCredentials && authType != OAuthAuthorizationTypePassword {
		validationResult.IsValid = false
		validationResult.AppendError(ErrInvalidUpstreamOAuthAuthorizationType)
	}
}

Cognitive complexity: 12, Cyclomatic complexity: 9

func (*RuleValidateEnforceTimeout) Validate

func (r *RuleValidateEnforceTimeout) Validate(apiDef *APIDefinition, validationResult *ValidationResult) {
	if apiDef.VersionData.Versions != nil {
		for _, vInfo := range apiDef.VersionData.Versions {
			for _, hardTimeOutMeta := range vInfo.ExtendedPaths.HardTimeouts {
				if hardTimeOutMeta.TimeOut < 0 {
					validationResult.IsValid = false
					validationResult.AppendError(ErrInvalidTimeoutValue)
					return
				}
			}
		}
	}
}

Cognitive complexity: 10, Cyclomatic complexity: 5

func (*RuleValidateIPList) Validate

func (r *RuleValidateIPList) Validate(apiDef *APIDefinition, validationResult *ValidationResult) {
	if apiDef.EnableIpWhiteListing {
		if errs := r.validateIPAddr(apiDef.AllowedIPs); len(errs) > 0 {
			validationResult.IsValid = false
			validationResult.Errors = append(validationResult.Errors, errs...)
		}
	}

	if apiDef.EnableIpBlacklisting {
		if errs := r.validateIPAddr(apiDef.BlacklistedIPs); len(errs) > 0 {
			validationResult.IsValid = false
			validationResult.Errors = append(validationResult.Errors, errs...)
		}
	}
}

Cognitive complexity: 8, Cyclomatic complexity: 5

func (*ServiceDiscoveryConfiguration) CacheOptions

CacheOptions returns the timeout value in effect, and a bool if cache is enabled.

func (sd *ServiceDiscoveryConfiguration) CacheOptions() (int64, bool) {
	return sd.CacheTimeout, !sd.CacheDisabled
}

Cognitive complexity: 0, Cyclomatic complexity: 1

func (*StringRegexMap) Check

func (s *StringRegexMap) Check(value string) (match string) {
	if s.matchRegex == nil {
		return
	}

	return s.matchRegex.FindString(value)
}

Cognitive complexity: 2, Cyclomatic complexity: 2

func (*StringRegexMap) FindAllStringSubmatch

func (s *StringRegexMap) FindAllStringSubmatch(value string, n int) (matched bool, matches [][]string) {
	matches = s.matchRegex.FindAllStringSubmatch(value, n)
	if !s.Reverse {
		matched = len(matches) > 0
	} else {
		matched = len(matches) == 0
	}

	return
}

Cognitive complexity: 4, Cyclomatic complexity: 2

func (*StringRegexMap) FindStringSubmatch

func (s *StringRegexMap) FindStringSubmatch(value string) (matched bool, match []string) {
	if s.matchRegex == nil {
		return
	}

	match = s.matchRegex.FindStringSubmatch(value)
	if !s.Reverse {
		matched = len(match) > 0
	} else {
		matched = len(match) == 0
	}

	return
}

Cognitive complexity: 6, Cyclomatic complexity: 3

func (*StringRegexMap) Init

func (s *StringRegexMap) Init() error {
	var err error
	if s.matchRegex, err = regexp.Compile(s.MatchPattern); err != nil {
		log.WithError(err).WithField("MatchPattern", s.MatchPattern).
			Error("Could not compile matchRegex for StringRegexMap")
		return err
	}

	return nil
}

Cognitive complexity: 2, Cyclomatic complexity: 2

Uses: regexp.Compile.

func (*UpstreamAuth) IsEnabled

IsEnabled checks if UpstreamAuthentication is enabled for the API.

func (u *UpstreamAuth) IsEnabled() bool {
	return u.Enabled && (u.BasicAuth.Enabled || u.OAuth.Enabled)
}

Cognitive complexity: 0, Cyclomatic complexity: 3

func (*ValidationResult) AppendError

func (v *ValidationResult) AppendError(err error) {
	v.Errors = append(v.Errors, err)
}

Cognitive complexity: 0, Cyclomatic complexity: 1

func (*ValidationResult) ErrorAt

func (v *ValidationResult) ErrorAt(i int) error {
	if v.ErrorCount() < i {
		return nil
	}

	return v.Errors[i]
}

Cognitive complexity: 2, Cyclomatic complexity: 2

func (*ValidationResult) ErrorCount

func (v *ValidationResult) ErrorCount() int {
	return len(v.Errors)
}

Cognitive complexity: 0, Cyclomatic complexity: 1

func (*ValidationResult) ErrorStrings

func (v *ValidationResult) ErrorStrings() []string {
	var errorStrings []string
	for _, err := range v.Errors {
		errorStrings = append(errorStrings, err.Error())
	}

	return errorStrings
}

Cognitive complexity: 3, Cyclomatic complexity: 2

func (*ValidationResult) FirstError

func (v *ValidationResult) FirstError() error {
	if v.ErrorCount() == 0 {
		return nil
	}

	return v.ErrorAt(0)
}

Cognitive complexity: 2, Cyclomatic complexity: 2

func (*ValidationResult) HasErrors

func (v *ValidationResult) HasErrors() bool {
	return v.ErrorCount() > 0
}

Cognitive complexity: 0, Cyclomatic complexity: 1

func (*VersionInfo) Expired

Expired returns true if this Version has expired and false if it has not expired (or does not have any expiry)

func (v *VersionInfo) Expired() bool {
	// Never expires
	if v.Expires == "" || v.Expires == "-1" {
		return false
	}

	// otherwise use parsed timestamp
	if v.ExpiresTs.IsZero() {
		log.Error("Could not parse expiry date, disallow")
		return true
	}

	return time.Since(v.ExpiresTs) >= 0
}

Cognitive complexity: 4, Cyclomatic complexity: 4

Uses: time.Since.

func (*VersionInfo) ExpiryTime

ExpiryTime returns the time that this version is due to expire

func (v *VersionInfo) ExpiryTime() (exp time.Time) {
	if v.Expired() {
		return exp
	}
	exp = v.ExpiresTs
	return
}

Cognitive complexity: 2, Cyclomatic complexity: 2

func (*VersionInfo) GlobalHeadersEnabled

func (v *VersionInfo) GlobalHeadersEnabled() bool {
	return !v.GlobalHeadersDisabled && (len(v.GlobalHeaders) > 0 || len(v.GlobalHeadersRemove) > 0)
}

Cognitive complexity: 0, Cyclomatic complexity: 3

func (*VersionInfo) GlobalResponseHeadersEnabled

func (v *VersionInfo) GlobalResponseHeadersEnabled() bool {
	return !v.GlobalResponseHeadersDisabled && (len(v.GlobalResponseHeaders) > 0 || len(v.GlobalResponseHeadersRemove) > 0)
}

Cognitive complexity: 0, Cyclomatic complexity: 3

func (*VersionInfo) HasEndpointReqHeader

func (v *VersionInfo) HasEndpointReqHeader() bool {
	if !v.UseExtendedPaths {
		return false
	}

	for _, trh := range v.ExtendedPaths.TransformHeader {
		if trh.Enabled() {
			return true
		}
	}

	return false
}

Cognitive complexity: 7, Cyclomatic complexity: 4

func (*VersionInfo) HasEndpointResHeader

func (v *VersionInfo) HasEndpointResHeader() bool {
	if !v.UseExtendedPaths {
		return false
	}

	for _, trh := range v.ExtendedPaths.TransformResponseHeader {
		if trh.Enabled() {
			return true
		}
	}

	return false
}

Cognitive complexity: 7, Cyclomatic complexity: 4

func (*WebHookHandlerConf) Scan

Scan scans WebHookHandlerConf from any in.

func (w *WebHookHandlerConf) Scan(in any) error {
	conf, err := reflect.Cast[WebHookHandlerConf](in)
	if err != nil {
		return err
	}

	*w = *conf
	return nil
}

Cognitive complexity: 2, Cyclomatic complexity: 2

Uses: reflect.Cast.

func (AuthSource) AuthKeyName

AuthKeyName returns the key name to be used for the auth source.

func (a AuthSource) AuthKeyName() string {
	if !a.IsEnabled() {
		return ""
	}

	return a.Name
}

Cognitive complexity: 2, Cyclomatic complexity: 2

func (AuthSource) IsEnabled

IsEnabled returns the enabled status of the auth source.

func (a AuthSource) IsEnabled() bool {
	return a.Enabled
}

Cognitive complexity: 0, Cyclomatic complexity: 1

func (NotificationsManager) SendRequest

SendRequest sends the requested package (as a POST) to the defined

func (n NotificationsManager) SendRequest(wait bool, count int, notification interface{}) {
	if n.OAuthKeyChangeURL == "" {
		return
	}

	if wait {
		if count < 3 {
			time.Sleep(10 * time.Second)
		} else {
			log.Error("Too many notification attempts, aborting.")
			return
		}
	}

	var req *http.Request
	var resp *http.Response
	var postBody []byte
	var err error

	postBody, err = json.Marshal(notification)
	if err != nil {
		log.Error("Error Marshaling the notification body:", err)
		return
	}
	responseBody := bytes.NewBuffer(postBody)

	req, err = http.NewRequest("POST", n.OAuthKeyChangeURL, responseBody)
	if err != nil {
		log.Error("Cannot create a new notification request:", err)
		return
	}
	req.Header.Set("User-Agent", "Tyk-Gatewy-Notifications")
	req.Header.Set("Content-Type", "application/json")
	req.Header.Set("X-Tyk-Shared-Secret", n.SharedSecret)

	resp, err = httpClient.Do(req)
	if err != nil {
		log.Error("Request failed, trying again in 10s. Error was: ", err)
		count++
		n.SendRequest(true, count, notification)
		return
	}
	defer resp.Body.Close()
	_, err = ioutil.ReadAll(resp.Body)
	if err != nil {
		log.Error("Request failed, trying again in 10s. Error was: ", err)
		count++
		n.SendRequest(true, count, notification)
		return
	}

	if resp.StatusCode != 200 {
		log.Error("Request returned non-200 status, trying again in 10s.")
		count++
		n.SendRequest(true, count, notification)
		return
	}
}

Cognitive complexity: 19, Cyclomatic complexity: 9

Uses: bytes.NewBuffer, http.NewRequest, http.Request, http.Response, ioutil.ReadAll, json.Marshal, time.Second, time.Sleep.

func (StringRegexMap) Empty

Empty is a utility function that returns true if the value is empty.

func (r StringRegexMap) Empty() bool {
	return r.MatchPattern == "" && !r.Reverse
}

Cognitive complexity: 0, Cyclomatic complexity: 2

func (UpstreamOAuth) IsEnabled

IsEnabled checks if UpstreamOAuth is enabled for the API.

func (u UpstreamOAuth) IsEnabled() bool {
	return u.Enabled
}

Cognitive complexity: 0, Cyclomatic complexity: 1

Private functions

func createAdvancedCacheConfig

createAdvancedCacheConfig creates a new CacheMeta configuration for advanced caching.

createAdvancedCacheConfig (cacheOpts CacheOptions, path string, method string) CacheMeta

func initHttpNotificationClient

initHttpNotificationClient () *http.Client
References: http.Client, http.Transport, net.Dialer, time.Second.

func shouldValidateAuthSource

shouldValidateAuthSource (authType string, apiDef *APIDefinition) bool

func deleteAuthConfigsNotUsed

deleteAuthConfigsNotUsed ()

func isAuthTokenEnabled

isAuthTokenEnabled () bool

func migrateAuthenticationPlugin

migrateAuthenticationPlugin ()
References: reflect.IsEmpty.

func migrateCertificatePinning

migrateCertificatePinning ()

func migrateCustomDomain

migrateCustomDomain ()

func migrateCustomPluginAuth

migrateCustomPluginAuth deprecates UseGoPluginAuth and EnableCoProcessAuth in favour of CustomPluginAuthEnabled.

migrateCustomPluginAuth ()

func migrateEndpointMetaByType

migrateEndpointMetaByType (typ int)
References: sort.Slice.

func migrateGatewayTags

migrateGatewayTags ()

func migrateGlobalHeaders

migrateGlobalHeaders ()

func migrateGlobalRateLimit

migrateGlobalRateLimit ()

func migrateGlobalResponseHeaders

migrateGlobalResponseHeaders ()

func migrateIDExtractor

migrateIDExtractor ()
References: reflect.IsEmpty.

func migrateIPAccessControl

migrateIPAccessControl ()

func migrateMutualTLS

migrateMutualTLS ()

func migratePluginBundle

migratePluginBundle ()

func migratePluginConfigData

migratePluginConfigData ()
References: reflect.IsEmpty.

func migrateResponseProcessors

migrateResponseProcessors ()

func migrateScopeToPolicy

migrateScopeToPolicy ()

func setEventHandlersDisabledFlags

setEventHandlersDisabledFlags ()

func validateIPAddr

validateIPAddr (ips []string) []error
References: fmt.Errorf, net.ParseCIDR, net.ParseIP, strings.Count.


Tests

Files: 4. Third party imports: 1. Imports from organisation: 0. Tests: 44. Benchmarks: 0.

Constants

const (
	dbID		= "dbID"
	apiID		= "apiID"
	listenPath	= "listenPath"
	baseTarget	= "base.com"
	baseAPIName	= "base-api"
	v1Target	= "v1.com"
	v2Target	= "v2.com"
	v1		= "v1"
	v2		= "v2"
	exp1		= "exp1"
	exp2		= "exp2"
	key		= "version"
)

Vars

var testV1ExtendedPaths = ExtendedPathsSet{
	WhiteList: []EndPointMeta{
		{Method: http.MethodGet, Path: "/get1"},
	},
	TransformResponse: []TemplateMeta{
		{
			Method:	http.MethodGet, Path: "/transform1",
			TemplateData: TemplateData{
				EnableSession:	true,
				Mode:		UseBlob,
				TemplateSource:	`{"http_method":"{{.Method}}"}`,
				Input:		RequestJSON,
			}},
	},
}
var testV2ExtendedPaths = ExtendedPathsSet{
	WhiteList: []EndPointMeta{
		{Method: http.MethodGet, Path: "/get2"},
	},
	TransformResponse: []TemplateMeta{
		{
			Method:	http.MethodGet, Path: "/transform2",
			TemplateData: TemplateData{
				EnableSession:	true,
				Mode:		UseBlob,
				TemplateSource:	`{"http_method":"{{.Method}}"}`,
				Input:		RequestJSON,
			}},
	},
}

Test functions

TestAPIDefinition_DecodeFromDB_AuthDeprecation

References: assert.Equal.

TestAPIDefinition_GenerateAPIID

References: assert.NotEmpty.

TestAPIDefinition_GetScopeClaimName

References: assert.Equal, testing.T.

TestAPIDefinition_GetScopeToPolicyMapping

References: assert.Equal, testing.T.

TestAPIDefinition_MigrateAuthConfigNames

References: assert.Equal, assert.NoError.

TestAPIDefinition_MigrateAuthentication

References: assert.Contains, assert.Len, assert.NoError.

TestAPIDefinition_MigrateCachePlugin

References: assert.Empty, assert.Equal, http.MethodGet, http.MethodHead, http.MethodOptions.

TestAPIDefinition_MigrateCachePlugin_MultipleMethods

References: http.MethodGet, http.MethodHead, http.MethodOptions, http.MethodPost, reflect.DeepEqual, testing.T.

TestAPIDefinition_MigrateEndpointMeta

References: assert.Equal, assert.NoError, http.MethodGet, http.MethodPost, http.StatusOK, http.StatusTeapot.

TestAPIDefinition_MigrateVersioning

References: assert.Equal, assert.Len, assert.NoError.

TestAPIDefinition_MigrateVersioning_DefaultEmpty

References: assert.Contains, assert.Empty, assert.Equal, assert.Len, assert.NoError, testing.T.

TestAPIDefinition_MigrateVersioning_Disabled

References: assert.Equal, assert.EqualError, assert.Nil, assert.NoError, testing.T.

TestAPIDefinition_MigrateVersioning_Expires

References: assert.Empty, assert.Equal, assert.NoError, testing.T.

TestAPIDefinition_MigrateVersioning_OverrideTarget

References: assert.Equal, assert.NoError, testing.T.

TestAPIDefinition_MigrateVersioning_StripPath

References: assert.Equal, assert.False, assert.Len, assert.NoError, testing.T.

TestAPIDefinition_deleteAuthConfigsNotUsed

References: assert.Len.

TestAPIDefinition_isAuthTokenEnabled

References: assert.False, assert.True.

TestAPIDefinition_migrateCustomPluginAuth

References: assert.Equal, testing.T.

TestAPIDefinition_migrateGlobalRateLimit

References: assert.False, assert.NoError, assert.True, testing.T.

TestAPIDefinition_migrateIDExtractor

References: assert.NoError, assert.True.

TestAPIDefinition_migrateIPAccessControl

References: assert.False, assert.NoError, assert.True, testing.T.

TestAPIDefinition_migratePluginConfigData

References: assert.NoError, assert.True.

TestAPIDefinition_migrateResponseProcessors

References: assert.Empty, assert.NoError.

TestAPIDefinition_migrateScopeToPolicy

References: assert.Empty, assert.Equal, assert.Nil, assert.NoError, testing.T.

TestCreateAdvancedCacheConfig

References: reflect.DeepEqual, testing.T.

TestDecodeFromDB

References: assert.Empty, assert.Equal, assert.NoError, base64.StdEncoding, http.MethodPost, json.Unmarshal, testing.T.

TestEncodeForDB

References: assert.True, testing.T.

TestJSVMEventHandlerConf_Scan

References: assert.Equal, assert.NoError.

TestLogEventHandlerConf_Scan

References: assert.Equal, assert.NoError.

TestRateLimitSmoothing_Err

References: testing.T.

TestRateLimitSmoothing_Valid

References: assert.False, assert.True, testing.T.

TestRoutingTriggerOptions

References: assert.Empty, assert.NotNil.

TestRuleAtLeastEnableOneAuthConfig_Validate

References: fmt.Errorf.

TestRuleUniqueDataSourceNames_Validate

TestRuleUpstreamAuth_Validate

TestRuleValidateEnforceTimeout_Validate

References: http.MethodGet.

TestRuleValidateIPList_Validate

References: fmt.Errorf.

TestSchema

References: gojsonschema.NewBytesLoader, gojsonschema.NewGoLoader, gojsonschema.Validate.

TestSchemaGraphqlConfig

References: gojsonschema.NewBytesLoader, gojsonschema.NewGoLoader, gojsonschema.Validate.

TestSetDisabledFlags

References: assert.Equal, assert.EqualValues, event.Event, event.QuotaExceeded, event.WebHookHandler.

TestStringRegexMap

References: assert.False, assert.True.

TestValidationResult_ErrorStrings

References: assert.Equal.

TestValidationResult_FirstError

References: assert.Equal, errors.New.

TestValidationResult_HasErrors

References: assert.False, assert.True, errors.New.