Documentation ¶
Overview ¶
Tyk Gateway API
The code below describes the Tyk Gateway API Version: 2.8.0
Schemes: https, http Host: localhost BasePath: /tyk/ Consumes: - application/json Produces: - application/json Security: - api_key: SecurityDefinitions: api_key: type: apiKey name: X-Tyk-Authorization in: header
swagger:meta
Index ¶
- Constants
- Variables
- func AddNewRelicInstrumentation(app newrelic.Application, r *mux.Router)
- func AuthFailed(m TykMiddleware, r *http.Request, token string)
- func CheckPortWhiteList(w map[string]config.PortWhiteList, listenPort int, protocol string) error
- func CoProcessInit()
- func CoProcessLog(CMessage, CLogLevel *C.char)
- func CreateCoProcessMiddleware(hookName string, hookType coprocess.HookType, mwDriver apidef.MiddlewareDriver, ...) func(http.Handler) http.Handler
- func CreateJWKToken(jGen ...func(*jwt.Token)) string
- func CreateJWKTokenECDSA(jGen ...func(*jwt.Token)) string
- func CreatePolicy(pGen ...func(p *user.Policy)) string
- func CreateSession(sGen ...func(s *user.SessionState)) stringdeprecated
- func CreateStandardPolicy() *user.Policy
- func CreateStandardSession() *user.SessionState
- func DoCoprocessReload()
- func DoReload()
- func DurationToMillisecond(d time.Duration) float64
- func EnablePort(port int, protocol string)
- func EncodeRequestToEvent(r *http.Request) string
- func EnsureTransport(host, protocol string) string
- func EventHandlerByName(handlerConf apidef.EventHandlerTriggerConfig, spec *APISpec) (config.TykEventHandler, error)
- func FireSystemEvent(name apidef.TykEvent, meta interface{})
- func GenerateTestBinaryData() (buf *bytes.Buffer)
- func GetLEState(m *letsencrypt.Manager)
- func GetNodeID() string
- func GetTLSClient(cert *tls.Certificate, caCert []byte) *http.Client
- func InitHostCheckManager(store storage.Handler)
- func InitTestMain(ctx context.Context, m *testing.M, genConf ...func(globalConf *config.Config)) int
- func InstrumentationMW(next http.Handler) http.Handler
- func IsUpgrade(req *http.Request) (bool, string)
- func JSONToFormValues(r *http.Request) error
- func LoadPoliciesFromDashboard(endpoint, secret string, allowExplicit bool) map[string]user.Policy
- func LoadPoliciesFromFile(filePath string) map[string]user.Policy
- func LoadPoliciesFromRPC(orgId string) (map[string]user.Policy, error)
- func LoadPoliciesFromRPCBackup() (map[string]user.Policy, error)
- func MonitorApplicationInstrumentation()
- func NewGRPCDispatcher() (coprocess.Dispatcher, error)
- func NewPythonDispatcher() (dispatcher coprocess.Dispatcher, err error)
- func NotifyCurrentServerStatus()
- func ParseRSAPublicKey(data []byte) (interface{}, error)
- func ProtoMap(inputMap map[string][]string) map[string]string
- func ProtoSessionState(session *user.SessionState) *coprocess.SessionState
- func ProxyHandler(p *ReverseProxy, apiSpec *APISpec) http.Handler
- func PythonInit() error
- func PythonLoadDispatcher() error
- func PythonNewDispatcher(bundleRootPath string) (coprocess.Dispatcher, error)
- func PythonSetEnv(pythonPaths ...string)
- func RegisterBundle(name string, files map[string]string) string
- func RegisterJSFileMiddleware(apiid string, files map[string]string)
- func ResetTestConfig()
- func RevokeAllTokens(storage ExtendedOsinStorageInterface, clientId, clientSecret string) (int, []string, error)
- func RevokeAllTokensHandler(w http.ResponseWriter, r *http.Request)
- func RevokeToken(storage ExtendedOsinStorageInterface, token, tokenTypeHint string)
- func RevokeTokenHandler(w http.ResponseWriter, r *http.Request)
- func SetCheckerHostList()
- func SetNodeID(nodeID string)
- func SetupNewRelic() (app newrelic.Application)
- func Start()
- func StartPeriodicStateBackup(m *letsencrypt.Manager)
- func StoreLEState(m *letsencrypt.Manager)
- func TestReq(t testing.TB, method, urlStr string, body interface{}) *http.Request
- func TestReqBody(t testing.TB, body interface{}) io.Reader
- func TykGetData(CKey *C.char) *C.char
- func TykSessionState(session *coprocess.SessionState) *user.SessionState
- func TykStoreData(CKey, CValue *C.char, CTTL C.int)
- func TykTriggerEvent(CEventName, CPayload *C.char)
- func UpdateAPIVersion(spec *APISpec, name string, verGen func(version *apidef.VersionInfo))
- func WrappedCharsetReader(s string, i io.Reader) (io.Reader, error)
- type APIAllCertificates
- type APICertificateStatusMessage
- type APIDefinitionLoader
- func (a APIDefinitionLoader) FromDashboardService(endpoint, secret string) ([]*APISpec, error)
- func (a APIDefinitionLoader) FromDir(dir string) []*APISpec
- func (a APIDefinitionLoader) FromRPC(orgId string) ([]*APISpec, error)
- func (a APIDefinitionLoader) MakeSpec(def *apidef.APIDefinition, logger *logrus.Entry) *APISpec
- func (a APIDefinitionLoader) ParseDefinition(r io.Reader) *apidef.APIDefinition
- type APIError
- type APISpec
- func BuildAPI(apiGens ...func(spec *APISpec)) (specs []*APISpec)
- func BuildAndLoadAPI(apiGens ...func(spec *APISpec)) (specs []*APISpec)
- func CloneAPI(a *APISpec) *APISpec
- func CreateDefinitionFromString(defStr string) *APISpec
- func LoadAPI(specs ...*APISpec) (out []*APISpec)
- func LoadDefinitionsFromRPCBackup() ([]*APISpec, error)
- func LoadSampleAPI(def string) (spec *APISpec)
- func (a *APISpec) CheckSpecMatchesStatus(r *http.Request, rxPaths []URLSpec, mode URLStatus) (bool, interface{})
- func (s *APISpec) FireEvent(name apidef.TykEvent, meta interface{})
- func (a *APISpec) Init(authStore, sessionStore, healthStore, orgStore storage.Handler)
- func (s *APISpec) Release()
- func (a *APISpec) RequestValid(r *http.Request) (bool, RequestStatus, interface{})
- func (a *APISpec) StopSessionManagerPool()
- func (a *APISpec) StripListenPath(r *http.Request, path string) string
- func (a *APISpec) URLAllowedAndIgnored(r *http.Request, rxPaths []URLSpec, whiteListStatus bool) (RequestStatus, interface{})
- func (s *APISpec) Validate() error
- func (a *APISpec) Version(r *http.Request) (*apidef.VersionInfo, []URLSpec, bool, RequestStatus)
- func (a *APISpec) VersionExpired(versionDef *apidef.VersionInfo) (bool, *time.Time)
- type AccessRightsCheck
- type AnalyticsRecord
- type AuthKey
- type BaseExtractor
- func (e *BaseExtractor) Error(r *http.Request, err error, message string) (returnOverrides ReturnOverrides)
- func (e *BaseExtractor) ExtractAndCheck(r *http.Request) (sessionID string, returnOverrides ReturnOverrides)
- func (e *BaseExtractor) ExtractBody(r *http.Request) (string, error)
- func (e *BaseExtractor) ExtractForm(r *http.Request, paramName string) (formValue string, err error)
- func (e *BaseExtractor) ExtractHeader(r *http.Request) (headerValue string, err error)
- func (e *BaseExtractor) GenerateSessionID(input string, mw BaseMiddleware) (sessionID string)
- type BaseMiddleware
- func (t BaseMiddleware) ApplyPolicies(session *user.SessionState) error
- func (t BaseMiddleware) Base() *BaseMiddleware
- func (t BaseMiddleware) CheckSessionAndIdentityForValidKey(originalKey *string, r *http.Request) (user.SessionState, bool)
- func (t BaseMiddleware) Config() (interface{}, error)
- func (t BaseMiddleware) EnabledForSpec() bool
- func (t BaseMiddleware) FireEvent(name apidef.TykEvent, meta interface{})
- func (t BaseMiddleware) Init()
- func (t BaseMiddleware) Logger() (logger *logrus.Entry)
- func (t BaseMiddleware) OrgSession(key string) (user.SessionState, bool)
- func (t BaseMiddleware) OrgSessionExpiry(orgid string) int64
- func (t *BaseMiddleware) SetName(name string)
- func (t BaseMiddleware) SetOrgExpiry(orgid string, expiry int64)
- func (t *BaseMiddleware) SetRequestLogger(r *http.Request)
- func (t BaseMiddleware) UpdateRequestSession(r *http.Request) bool
- type BasicAuthKeyIsValid
- type BatchReplyUnit
- type BatchRequestHandler
- func (b *BatchRequestHandler) ConstructRequests(batchRequest BatchRequestStructure, unsafe bool) ([]*http.Request, error)
- func (b *BatchRequestHandler) DecodeBatchRequest(r *http.Request) (BatchRequestStructure, error)
- func (b *BatchRequestHandler) HandleBatchRequest(w http.ResponseWriter, r *http.Request)
- func (b *BatchRequestHandler) MakeRequests(batchRequest BatchRequestStructure, requestSet []*http.Request) []BatchReplyUnit
- func (b *BatchRequestHandler) ManualBatchRequest(requestObject []byte) ([]byte, error)
- type BatchRequestStructure
- type Bundle
- type BundleGetter
- type BundleSaver
- type CertificateCheckMW
- type ChainObject
- type CoProcessEventHandler
- type CoProcessEventWrapper
- type CoProcessMiddleware
- type CoProcessor
- type ConfigPayload
- type DBAccessDefinition
- type DBPolicy
- type DashboardServiceSender
- type DefaultHealthChecker
- type DefaultKeyGenerator
- type DefaultSessionManager
- func (b *DefaultSessionManager) Init(store storage.Handler)
- func (b *DefaultSessionManager) KeyExpired(newSession *user.SessionState) bool
- func (b *DefaultSessionManager) RemoveSession(keyName string, hashed bool) bool
- func (b *DefaultSessionManager) ResetQuota(keyName string, session *user.SessionState, isHashed bool)
- func (b *DefaultSessionManager) SessionDetail(keyName string, hashed bool) (user.SessionState, bool)
- func (b *DefaultSessionManager) Sessions(filter string) []string
- func (b *DefaultSessionManager) Stop()
- func (b *DefaultSessionManager) Store() storage.Handler
- func (b *DefaultSessionManager) UpdateSession(keyName string, session *user.SessionState, resetTTLTo int64, hashed bool) error
- type DummyProxyHandler
- type DynamicMiddleware
- type EndPointCacheMeta
- type ErrorHandler
- type EventCurcuitBreakerMeta
- type EventHostStatusMeta
- type EventKeyFailureMeta
- type EventMetaDefault
- type EventTokenMeta
- type EventTriggerExceededMeta
- type EventVersionFailureMeta
- type ExtendedCircuitBreakerMeta
- type ExtendedOsinClientInterface
- type ExtendedOsinStorageInterface
- type GRPCDispatcher
- type GeoData
- type GetConfigPayload
- type GoPluginMiddleware
- type GranularAccessMiddleware
- type HMACFieldValues
- type HTTPBundleGetter
- type HTTPDashboardHandler
- func (h *HTTPDashboardHandler) DeRegister() error
- func (h *HTTPDashboardHandler) Init() error
- func (h *HTTPDashboardHandler) NotifyDashboardOfEvent(event interface{}) error
- func (h *HTTPDashboardHandler) Register() error
- func (h *HTTPDashboardHandler) StartBeating() error
- func (h *HTTPDashboardHandler) StopBeating()
- type HTTPSignatureValidationMiddleware
- func (k *HTTPSignatureValidationMiddleware) EnabledForSpec() bool
- func (hm *HTTPSignatureValidationMiddleware) Init()
- func (hm *HTTPSignatureValidationMiddleware) Name() string
- func (hm *HTTPSignatureValidationMiddleware) ProcessRequest(w http.ResponseWriter, r *http.Request, _ interface{}) (error, int)
- type HeaderInjector
- type HeaderInjectorOptions
- type HeaderTransform
- type HeaderTransformOptions
- type HealthCheckValues
- type HealthChecker
- type HealthPrefix
- type HostCheckerManager
- func (hc *HostCheckerManager) AmIPolling() bool
- func (hc *HostCheckerManager) CheckActivePollerLoop()
- func (hc *HostCheckerManager) DoServiceDiscoveryListUpdateForID(apiID string)
- func (hc *HostCheckerManager) GenerateCheckerId()
- func (hc *HostCheckerManager) HostDown(urlStr string) bool
- func (hc *HostCheckerManager) Init(store storage.Handler)
- func (hc *HostCheckerManager) ListFromService(apiID string) ([]HostData, error)
- func (hc *HostCheckerManager) OnHostBackUp(report HostHealthReport)
- func (hc *HostCheckerManager) OnHostDown(report HostHealthReport)
- func (hc *HostCheckerManager) OnHostReport(report HostHealthReport)
- func (hc *HostCheckerManager) PrepareTrackingHost(checkObject apidef.HostCheckObject, apiID string) (HostData, error)
- func (hc *HostCheckerManager) RecordUptimeAnalytics(report HostHealthReport) error
- func (hc *HostCheckerManager) Start()
- func (hc *HostCheckerManager) StartPoller()
- func (hc *HostCheckerManager) StopPoller()
- func (hc *HostCheckerManager) UpdateTrackingList(hd []HostData)
- func (hc *HostCheckerManager) UpdateTrackingListByAPIID(hd []HostData, apiId string)
- func (hc *HostCheckerManager) UptimePurgeLoop()
- type HostData
- type HostHealthReport
- type HostUptimeChecker
- func (h *HostUptimeChecker) CheckHost(toCheck HostData)
- func (h *HostUptimeChecker) HostCheckLoop()
- func (h *HostUptimeChecker) HostReporter()
- func (h *HostUptimeChecker) Init(workers, triggerLimit, timeout int, hostList map[string]HostData, ...)
- func (h *HostUptimeChecker) ResetList(hostList map[string]HostData)
- func (h *HostUptimeChecker) Start()
- func (h *HostUptimeChecker) Stop()
- type IPBlackListMiddleware
- type IPWhiteListMiddleware
- type IdExtractor
- type InterfaceNotification
- type JSVM
- type JSVMContextGlobal
- type JSVMEventHandler
- type JWK
- type JWKs
- type JWTMiddleware
- type KeyExpired
- type LDAPStorageHandler
- func (l LDAPStorageHandler) AddToSet(keyName, value string)
- func (l LDAPStorageHandler) AddToSortedSet(keyName, value string, score float64)
- func (l LDAPStorageHandler) AppendToSet(keyName, value string)
- func (r *LDAPStorageHandler) AppendToSetPipelined(key string, values []string)
- func (l *LDAPStorageHandler) Connect() bool
- func (l *LDAPStorageHandler) Decrement(keyName string)
- func (r *LDAPStorageHandler) DeleteAllKeys() bool
- func (l *LDAPStorageHandler) DeleteKey(cn string) bool
- func (l *LDAPStorageHandler) DeleteKeys(keys []string) bool
- func (l *LDAPStorageHandler) DeleteRawKey(cn string) bool
- func (l LDAPStorageHandler) DeleteScanMatch(pattern string) bool
- func (l LDAPStorageHandler) Exists(keyName string) (bool, error)
- func (l LDAPStorageHandler) GetAndDeleteSet(keyName string) []interface{}
- func (l *LDAPStorageHandler) GetExp(cn string) (int64, error)
- func (l *LDAPStorageHandler) GetKey(filter string) (string, error)
- func (l LDAPStorageHandler) GetKeyPrefix() string
- func (l *LDAPStorageHandler) GetKeys(filter string) []string
- func (l *LDAPStorageHandler) GetKeysAndValues() map[string]string
- func (l *LDAPStorageHandler) GetKeysAndValuesWithFilter(filter string) map[string]string
- func (l *LDAPStorageHandler) GetListRange(keyName string, from, to int64) ([]string, error)
- func (r *LDAPStorageHandler) GetMultiKey(keyNames []string) ([]string, error)
- func (l *LDAPStorageHandler) GetRawKey(filter string) (string, error)
- func (l *LDAPStorageHandler) GetRollingWindow(keyName string, per int64, pipeline bool) (int, []interface{})
- func (l LDAPStorageHandler) GetSet(keyName string) (map[string]string, error)
- func (l LDAPStorageHandler) GetSortedSetRange(keyName, scoreFrom, scoreTo string) ([]string, []float64, error)
- func (l *LDAPStorageHandler) IncrememntWithExpire(keyName string, timeout int64) int64
- func (l *LDAPStorageHandler) LoadConfFromMeta(meta map[string]interface{})
- func (l LDAPStorageHandler) RemoveFromList(keyName, value string) error
- func (l LDAPStorageHandler) RemoveFromSet(keyName, value string)
- func (l LDAPStorageHandler) RemoveSortedSetRange(keyName, scoreFrom, scoreTo string) error
- func (l *LDAPStorageHandler) SetExp(cn string, exp int64) error
- func (l *LDAPStorageHandler) SetKey(cn, session string, timeout int64) error
- func (l *LDAPStorageHandler) SetRawKey(cn, session string, timeout int64) error
- func (l *LDAPStorageHandler) SetRollingWindow(keyName string, per int64, val string, pipeline bool) (int, []interface{})
- type LE_ServerInfo
- type Latency
- type LogMessageEventHandler
- type MethodNotAllowedHandler
- type MiddlewareContextVars
- type MiniRequestObject
- type MockBundleGetter
- type Monitor
- type MultiTargetProxy
- type NetworkStats
- type NewClientRequest
- type NewOAuthNotification
- type NodeResponseOK
- type Notification
- type NotificationCommand
- type OAuthClient
- type OAuthClientToken
- type OAuthHandlers
- func (o *OAuthHandlers) HandleAccessRequest(w http.ResponseWriter, r *http.Request)
- func (o *OAuthHandlers) HandleAuthorizePassthrough(w http.ResponseWriter, r *http.Request)
- func (o *OAuthHandlers) HandleGenerateAuthCodeData(w http.ResponseWriter, r *http.Request)
- func (o *OAuthHandlers) HandleRevokeAllTokens(w http.ResponseWriter, r *http.Request)
- func (o *OAuthHandlers) HandleRevokeToken(w http.ResponseWriter, r *http.Request)
- type OAuthManager
- type OAuthNotificationType
- type Oauth2KeyExists
- type OpenIDMW
- type OrganizationMonitor
- func (k *OrganizationMonitor) AllowAccessNext(orgChan chan bool, path string, IP string, r *http.Request, ...)
- func (k *OrganizationMonitor) EnabledForSpec() bool
- func (k *OrganizationMonitor) Name() string
- func (k *OrganizationMonitor) ProcessRequest(w http.ResponseWriter, r *http.Request, conf interface{}) (error, int)
- func (k *OrganizationMonitor) ProcessRequestLive(r *http.Request, orgSession user.SessionState) (error, int)
- func (k *OrganizationMonitor) ProcessRequestOffThread(r *http.Request, orgSession user.SessionState) (error, int)
- func (k *OrganizationMonitor) SetOrgSentinel(orgChan chan bool, orgId string)
- type PolicyUpdateObj
- type ProxyResponse
- type PublicSession
- type Purger
- type PythonDispatcher
- type RPCStorageHandler
- func (r RPCStorageHandler) AddToSet(keyName, value string)
- func (r *RPCStorageHandler) AddToSortedSet(keyName, value string, score float64)
- func (r *RPCStorageHandler) AppendToSet(keyName, value string)
- func (r *RPCStorageHandler) AppendToSetPipelined(key string, values []string)
- func (r *RPCStorageHandler) CheckForKeyspaceChanges(orgId string)
- func (r *RPCStorageHandler) CheckForReload(orgId string)
- func (r *RPCStorageHandler) Connect() bool
- func (r *RPCStorageHandler) Decrement(keyName string)
- func (r *RPCStorageHandler) DeleteAllKeys() bool
- func (r *RPCStorageHandler) DeleteKey(keyName string) bool
- func (r *RPCStorageHandler) DeleteKeys(keys []string) bool
- func (r *RPCStorageHandler) DeleteRawKey(keyName string) bool
- func (r *RPCStorageHandler) DeleteScanMatch(pattern string) bool
- func (r *RPCStorageHandler) Exists(keyName string) (bool, error)
- func (r *RPCStorageHandler) GetAndDeleteSet(keyName string) []interface{}
- func (r *RPCStorageHandler) GetApiDefinitions(orgId string, tags []string) string
- func (r *RPCStorageHandler) GetExp(keyName string) (int64, error)
- func (r *RPCStorageHandler) GetKey(keyName string) (string, error)
- func (r *RPCStorageHandler) GetKeyPrefix() string
- func (r *RPCStorageHandler) GetKeys(filter string) []string
- func (r *RPCStorageHandler) GetKeysAndValues() map[string]string
- func (r *RPCStorageHandler) GetKeysAndValuesWithFilter(filter string) map[string]string
- func (r *RPCStorageHandler) GetListRange(keyName string, from, to int64) ([]string, error)
- func (r *RPCStorageHandler) GetMultiKey(keyNames []string) ([]string, error)
- func (r *RPCStorageHandler) GetPolicies(orgId string) string
- func (r *RPCStorageHandler) GetRawKey(keyName string) (string, error)
- func (r *RPCStorageHandler) GetRollingWindow(keyName string, per int64, pipeline bool) (int, []interface{})
- func (r RPCStorageHandler) GetSet(keyName string) (map[string]string, error)
- func (r *RPCStorageHandler) GetSortedSetRange(keyName, scoreFrom, scoreTo string) ([]string, []float64, error)
- func (r *RPCStorageHandler) IncrememntWithExpire(keyName string, expire int64) int64
- func (r RPCStorageHandler) IsAccessError(err error) bool
- func (r *RPCStorageHandler) ProcessKeySpaceChanges(keys []string)
- func (r *RPCStorageHandler) Publish(channel, message string) error
- func (r *RPCStorageHandler) RemoveFromList(keyName, value string) error
- func (r RPCStorageHandler) RemoveFromSet(keyName, value string)
- func (r *RPCStorageHandler) RemoveSortedSetRange(keyName, scoreFrom, scoreTo string) error
- func (r *RPCStorageHandler) SetExp(keyName string, timeout int64) error
- func (r *RPCStorageHandler) SetKey(keyName, session string, timeout int64) error
- func (r *RPCStorageHandler) SetRawKey(keyName, session string, timeout int64) error
- func (r *RPCStorageHandler) SetRollingWindow(keyName string, per int64, val string, pipeline bool) (int, []interface{})
- func (r *RPCStorageHandler) StartPubSubHandler(channel string, callback func(*redis.Message)) error
- func (r *RPCStorageHandler) StartRPCKeepaliveWatcher()
- func (r *RPCStorageHandler) StartRPCLoopCheck(orgId string)
- type RateCheckMW
- type RateLimitAndQuotaCheck
- type RateLimitForAPI
- type RedisAnalyticsHandler
- type RedisCacheMiddleware
- func (m *RedisCacheMiddleware) CreateCheckSum(req *http.Request, keyName string, regex string, ...) (string, error)
- func (m *RedisCacheMiddleware) EnabledForSpec() bool
- func (m *RedisCacheMiddleware) Init()
- func (m *RedisCacheMiddleware) Name() string
- func (m *RedisCacheMiddleware) ProcessRequest(w http.ResponseWriter, r *http.Request, _ interface{}) (error, int)
- type RedisNotifier
- type RedisOsinStorageInterface
- func (r *RedisOsinStorageInterface) Clone() osin.Storage
- func (r *RedisOsinStorageInterface) Close()
- func (r *RedisOsinStorageInterface) DeleteClient(id string, orgID string, ignorePrefix bool) error
- func (r *RedisOsinStorageInterface) GetClient(id string) (osin.Client, error)
- func (r *RedisOsinStorageInterface) GetClientNoPrefix(id string) (osin.Client, error)
- func (r *RedisOsinStorageInterface) GetClientTokens(id string) ([]OAuthClientToken, error)
- func (r *RedisOsinStorageInterface) GetClients(filter string, orgID string, ignorePrefix bool) ([]ExtendedOsinClientInterface, error)
- func (r *RedisOsinStorageInterface) GetExtendedClient(id string) (ExtendedOsinClientInterface, error)
- func (r *RedisOsinStorageInterface) GetExtendedClientNoPrefix(id string) (ExtendedOsinClientInterface, error)
- func (r *RedisOsinStorageInterface) GetPaginatedClientTokens(id string, page int) ([]OAuthClientToken, int, error)
- func (r *RedisOsinStorageInterface) GetUser(username string) (*user.SessionState, error)
- func (r *RedisOsinStorageInterface) LoadAccess(token string) (*osin.AccessData, error)
- func (r *RedisOsinStorageInterface) LoadAuthorize(code string) (*osin.AuthorizeData, error)
- func (r *RedisOsinStorageInterface) LoadRefresh(token string) (*osin.AccessData, error)
- func (r *RedisOsinStorageInterface) RemoveAccess(token string) error
- func (r *RedisOsinStorageInterface) RemoveAuthorize(code string) error
- func (r *RedisOsinStorageInterface) RemoveRefresh(token string) error
- func (r *RedisOsinStorageInterface) SaveAccess(accessData *osin.AccessData) error
- func (r *RedisOsinStorageInterface) SaveAuthorize(authData *osin.AuthorizeData) error
- func (r *RedisOsinStorageInterface) SetClient(id string, orgID string, client osin.Client, ignorePrefix bool) error
- func (r *RedisOsinStorageInterface) SetUser(username string, session *user.SessionState, timeout int64) error
- type RedisPurger
- type RegexExtractor
- type RegexExtractorConfig
- type ReloadMachinery
- func (r *ReloadMachinery) Disable()
- func (r *ReloadMachinery) Enable()
- func (r *ReloadMachinery) EnsureQueued(t *testing.T)
- func (r *ReloadMachinery) EnsureReloaded(t *testing.T)
- func (r *ReloadMachinery) OnQueued()
- func (r *ReloadMachinery) OnReload()
- func (r *ReloadMachinery) Queued() bool
- func (r *ReloadMachinery) Reloaded() bool
- func (r *ReloadMachinery) Reset()
- func (r *ReloadMachinery) Tick()
- func (r *ReloadMachinery) TickOk(t *testing.T)
- type RequestDefinition
- type RequestObject
- type RequestSigning
- type RequestSizeLimitMiddleware
- type RequestStatus
- type ResponseObject
- type ResponseTransformJQMiddleware
- type ResponseTransformMiddleware
- type ReturnConfigPayload
- type ReturnOverrides
- type ReturningHttpHandler
- type RevProxyTransform
- type ReverseProxy
- func (p *ReverseProxy) CheckCircuitBreakerEnforced(spec *APISpec, req *http.Request) (bool, *ExtendedCircuitBreakerMeta)
- func (p *ReverseProxy) CheckHardTimeoutEnforced(spec *APISpec, req *http.Request) (bool, float64)
- func (p *ReverseProxy) CheckHeaderInRemoveList(hdr string, spec *APISpec, req *http.Request) bool
- func (p *ReverseProxy) CopyResponse(dst io.Writer, src io.Reader)
- func (p *ReverseProxy) HandleResponse(rw http.ResponseWriter, res *http.Response, ses *user.SessionState) error
- func (p *ReverseProxy) ServeHTTP(rw http.ResponseWriter, req *http.Request) ProxyResponse
- func (p *ReverseProxy) ServeHTTPForCache(rw http.ResponseWriter, req *http.Request) ProxyResponse
- func (p *ReverseProxy) WrappedServeHTTP(rw http.ResponseWriter, req *http.Request, withCache bool) ProxyResponse
- type RoundRobin
- type ServiceDiscovery
- func (s *ServiceDiscovery) Hostname(item *gabs.Container) string
- func (s *ServiceDiscovery) Init(spec *apidef.ServiceDiscoveryConfiguration)
- func (s *ServiceDiscovery) NestedObject(item *gabs.Container) string
- func (s *ServiceDiscovery) Object(item *gabs.Container) string
- func (s *ServiceDiscovery) ParseObject(contents string, jsonParsed *gabs.Container) error
- func (s *ServiceDiscovery) ProcessRawData(rawData string) (*apidef.HostList, error)
- func (s *ServiceDiscovery) SubObject(obj *gabs.Container) string
- func (s *ServiceDiscovery) SubObjectFromList(objList *gabs.Container) []string
- func (s *ServiceDiscovery) Target(serviceURL string) (*apidef.HostList, error)
- type SessionHandler
- type SessionLimiter
- type StatsDSink
- func (s *StatsDSink) Drain()
- func (s *StatsDSink) EmitComplete(job string, status health.CompletionStatus, nanos int64, kvs map[string]string)
- func (s *StatsDSink) EmitEvent(job, event string, kvs map[string]string)
- func (s *StatsDSink) EmitEventErr(job, event string, inputErr error, kvs map[string]string)
- func (s *StatsDSink) EmitGauge(job, event string, value float64, kvs map[string]string)
- func (s *StatsDSink) EmitTiming(job, event string, nanos int64, kvs map[string]string)
- func (s *StatsDSink) Stop()
- type StatsDSinkOptions
- type StatsDSinkSanitizationFunc
- type StripAuth
- type SuccessHandler
- type TemplateExecutor
- type Test
- func (s *Test) Close()
- func (s *Test) CreateSession(sGen ...func(s *user.SessionState)) (*user.SessionState, string)
- func (s *Test) Do(tc test.TestCase) (*http.Response, error)
- func (s *Test) Run(t testing.TB, testCases ...test.TestCase) (*http.Response, error)
- func (s *Test) RunExt(t testing.TB, testCases ...test.TestCase)
- func (s *Test) Start()
- type TestConfig
- type TestHttpResponse
- type TraceMiddleware
- type TrackEndpointMiddleware
- type TransformHeaders
- type TransformJQMiddleware
- type TransformJQSpec
- type TransformMethod
- type TransformMiddleware
- type TransformSpec
- type TykJSHttpRequest
- type TykJSHttpResponse
- type TykMiddleware
- type TykOsinServer
- type TykResponseHandler
- type URLRewriteMiddleware
- func (m *URLRewriteMiddleware) CheckHostRewrite(oldPath, newTarget string, r *http.Request)
- func (m *URLRewriteMiddleware) EnabledForSpec() bool
- func (m *URLRewriteMiddleware) InitTriggerRx()
- func (m *URLRewriteMiddleware) Name() string
- func (m *URLRewriteMiddleware) ProcessRequest(w http.ResponseWriter, r *http.Request, _ interface{}) (error, int)
- type URLSpec
- type URLStatus
- type UptimeReportData
- type VMResponseObject
- type VMReturnObject
- type ValidateJSON
- type ValueExtractor
- type ValueExtractorConfig
- type VersionCheck
- type VirtualEndpoint
- func (d *VirtualEndpoint) EnabledForSpec() bool
- func (d *VirtualEndpoint) HandleResponse(rw http.ResponseWriter, res *http.Response, ses *user.SessionState)
- func (d *VirtualEndpoint) Init()
- func (d *VirtualEndpoint) Name() string
- func (d *VirtualEndpoint) ProcessRequest(w http.ResponseWriter, r *http.Request, _ interface{}) (error, int)
- func (d *VirtualEndpoint) ServeHTTPForCache(w http.ResponseWriter, r *http.Request, vmeta *apidef.VirtualMeta) *http.Response
- type WebHookHandler
- func (w *WebHookHandler) BuildRequest(reqBody string) (*http.Request, error)
- func (w *WebHookHandler) Checksum(reqBody string) (string, error)
- func (w *WebHookHandler) CreateBody(em config.EventMessage) (string, error)
- func (w *WebHookHandler) HandleEvent(em config.EventMessage)
- func (w *WebHookHandler) Init(handlerConf interface{}) error
- func (w *WebHookHandler) WasHookFired(checksum string) bool
- type WebHookRequestMethod
- type XPathExtractor
- type XPathExtractorConfig
- type ZipBundleSaver
Constants ¶
const ( LDAPStorageEngine apidef.StorageEngineCode = "ldap" RPCStorageEngine apidef.StorageEngineCode = "rpc" )
const ( EventQuotaExceeded apidef.TykEvent = "QuotaExceeded" EventRateLimitExceeded apidef.TykEvent = "RatelimitExceeded" EventAuthFailure apidef.TykEvent = "AuthFailure" EventKeyExpired apidef.TykEvent = "KeyExpired" EventVersionFailure apidef.TykEvent = "VersionFailure" EventOrgQuotaExceeded apidef.TykEvent = "OrgQuotaExceeded" EventOrgRateLimitExceeded apidef.TykEvent = "OrgRateLimitExceeded" EventTriggerExceeded apidef.TykEvent = "TriggerExceeded" EventBreakerTriggered apidef.TykEvent = "BreakerTriggered" EventHOSTDOWN apidef.TykEvent = "HostDown" EventHOSTUP apidef.TykEvent = "HostUp" EventTokenCreated apidef.TykEvent = "TokenCreated" EventTokenUpdated apidef.TykEvent = "TokenUpdated" EventTokenDeleted apidef.TykEvent = "TokenDeleted" )
Register new event types here, the string is the code used to hook at the Api Deifnititon JSON/BSON level
const ( UnHealthyHostMetaDataTargetKey = "target_url" UnHealthyHostMetaDataAPIKey = "api_id" UnHealthyHostMetaDataHostKey = "host_name" PollerCacheKey = "PollerActiveInstanceID" PoolerHostSentinelKeyPrefix = "PollerCheckerInstance:" UptimeAnalytics_KEYNAME = "tyk-uptime-analytics" )
const ( ErrAuthAuthorizationFieldMissing = "auth.auth_field_missing" ErrAuthKeyNotFound = "auth.key_not_found" )
const ( KID = "kid" SUB = "sub" HMACSign = "hmac" RSASign = "rsa" ECDSASign = "ecdsa" )
const ( ErrOAuthAuthorizationFieldMissing = "oauth.auth_field_missing" ErrOAuthAuthorizationFieldMalformed = "oauth.auth_field_malformed" ErrOAuthKeyNotFound = "oauth.key_not_found" ErrOAuthClientDeleted = "oauth.client_deleted" )
const ( QuotaKeyPrefix = "quota-" RateLimitKeyPrefix = "rate-limit-" )
const ( // Accepts any http requests on /, only allows GET on /get, etc. // All return a JSON with request info. TestHttpAny = "http://" + testHttpListen TestHttpGet = TestHttpAny + "/get" MockOrgID = "507f1f77bcf86cd799439011" )
const BackupApiKeyBase = "node-definition-backup:"
const BackupPolicyKeyBase = "node-policy-backup:"
const CoProcessDefaultKeyPrefix = "coprocess-data:"
CoProcessDefaultKeyPrefix is used as a key prefix for this CP.
const EH_CoProcessHandler apidef.TykEventHandlerName = "cp_dynamic_handler"
Constant for event system.
const EH_JSVMHandler apidef.TykEventHandlerName = "eh_dynamic_handler"
const EH_LogHandler apidef.TykEventHandlerName = "eh_log_handler"
The name for event handlers as defined in the API Definition JSON/BSON format
const LEKeyPrefix = "le_ssl:"
const LoopScheme = "tyk"
const OIDPREFIX = "openid"
const RPCKeyPrefix = "rpc:"
const SAFE_METHODS = "SAFE_METHODS"
const used by cache middleware
const VERSION = "v2.9.5"
Variables ¶
var ( // key session memory cache SessionCache = cache.New(10*time.Second, 5*time.Second) // org session memory cache ExpiryCache = cache.New(600*time.Second, 10*time.Minute) // memory cache to store arbitrary items UtilCache = cache.New(time.Hour, 10*time.Minute) )
var ( GlobalEventsJSVM JSVM MainNotifier RedisNotifier DefaultOrgStore DefaultSessionManager DefaultQuotaStore DefaultSessionManager FallbackKeySesionManager = SessionHandler(&DefaultSessionManager{}) MonitoringHandler config.TykEventHandler RPCListener RPCStorageHandler DashService DashboardServiceSender CertificateManager *certs.CertificateManager NewRelicApplication newrelic.Application LE_MANAGER letsencrypt.Manager LE_FIRSTRUN bool NodeID string )
var DRLManager = &drl.DRL{}
var (
EnableTestDNSMock = true
)
var GlobalRate = ratecounter.NewRateCounter(1 * time.Second)
var ( HostCheckerClient = &http.Client{ Timeout: 500 * time.Millisecond, } )
var JWKCache *cache.Cache
var LoopHostRE = regexp.MustCompile("tyk://([^/]+)")
var NonAlphaNumRE = regexp.MustCompile("[^A-Za-z0-9]+")
var ReloadTestCase = &ReloadMachinery{}
ReloadTestCase use this when in any test for gateway reloads
var ServiceCache *cache.Cache
var ServiceNonce string
Nonce to use when interacting with the dashboard service
var TykErrors = make(map[string]config.TykError)
Functions ¶
func AddNewRelicInstrumentation ¶
func AddNewRelicInstrumentation(app newrelic.Application, r *mux.Router)
AddNewRelicInstrumentation adds NewRelic instrumentation to the router
func AuthFailed ¶
func AuthFailed(m TykMiddleware, r *http.Request, token string)
func CheckPortWhiteList ¶
func CoProcessInit ¶
func CoProcessInit()
CoProcessInit creates a new CoProcessDispatcher, it will be called when Tyk starts.
func CoProcessLog ¶
CoProcessLog is a bridge for using Tyk log from CP.
func CreateCoProcessMiddleware ¶
func CreateCoProcessMiddleware(hookName string, hookType coprocess.HookType, mwDriver apidef.MiddlewareDriver, baseMid BaseMiddleware) func(http.Handler) http.Handler
CreateCoProcessMiddleware initializes a new CP middleware, takes hook type (pre, post, etc.), hook name ("my_hook") and driver ("python").
func CreateJWKToken ¶
func CreateJWKTokenECDSA ¶
func CreatePolicy ¶
func CreateSession
deprecated
func CreateSession(sGen ...func(s *user.SessionState)) string
Deprecated: Use Test.CreateSession instead.
func CreateStandardPolicy ¶
func CreateStandardSession ¶
func CreateStandardSession() *user.SessionState
func DoCoprocessReload ¶
func DoCoprocessReload()
func DurationToMillisecond ¶
func EnablePort ¶
func EncodeRequestToEvent ¶
EncodeRequestToEvent will write the request out in wire protocol and encode it to base64 and store it in an Event object
func EnsureTransport ¶
func EventHandlerByName ¶
func EventHandlerByName(handlerConf apidef.EventHandlerTriggerConfig, spec *APISpec) (config.TykEventHandler, error)
EventHandlerByName is a convenience function to get event handler instances from an API Definition
func FireSystemEvent ¶
func GenerateTestBinaryData ¶
func GetLEState ¶
func GetLEState(m *letsencrypt.Manager)
func GetTLSClient ¶
func GetTLSClient(cert *tls.Certificate, caCert []byte) *http.Client
func InitHostCheckManager ¶
func InitTestMain ¶
func InstrumentationMW ¶
InstrumentationMW will set basic instrumentation events, variables and timers on API jobs
func JSONToFormValues ¶
JSONToFormValues if r has header Content-Type set to application/json this will decode request body as json to map[string]string and adds the key/value pairs in r.Form.
func LoadPoliciesFromDashboard ¶
LoadPoliciesFromDashboard will connect and download Policies from a Tyk Dashboard instance.
func MonitorApplicationInstrumentation ¶
func MonitorApplicationInstrumentation()
func NewGRPCDispatcher ¶
func NewGRPCDispatcher() (coprocess.Dispatcher, error)
NewGRPCDispatcher wraps all the actions needed for this CP.
func NewPythonDispatcher ¶
func NewPythonDispatcher() (dispatcher coprocess.Dispatcher, err error)
NewPythonDispatcher wraps all the actions needed for this CP.
func NotifyCurrentServerStatus ¶
func NotifyCurrentServerStatus()
func ParseRSAPublicKey ¶
func ProtoSessionState ¶
func ProtoSessionState(session *user.SessionState) *coprocess.SessionState
ProtoSessionState takes a standard SessionState and outputs a SessionState object compatible with Protocol Buffers.
func ProxyHandler ¶
func ProxyHandler(p *ReverseProxy, apiSpec *APISpec) http.Handler
ProxyHandler Proxies requests through to their final destination, if they make it through the middleware chain.
func PythonLoadDispatcher ¶
func PythonLoadDispatcher() error
PythonLoadDispatcher creates reference to the dispatcher class.
func PythonNewDispatcher ¶
func PythonNewDispatcher(bundleRootPath string) (coprocess.Dispatcher, error)
PythonNewDispatcher creates an instance of TykDispatcher.
func PythonSetEnv ¶
func PythonSetEnv(pythonPaths ...string)
PythonSetEnv sets PYTHONPATH, it's called before initializing the interpreter.
func ResetTestConfig ¶
func ResetTestConfig()
func RevokeAllTokens ¶
func RevokeAllTokens(storage ExtendedOsinStorageInterface, clientId, clientSecret string) (int, []string, error)
func RevokeAllTokensHandler ¶
func RevokeAllTokensHandler(w http.ResponseWriter, r *http.Request)
func RevokeToken ¶
func RevokeToken(storage ExtendedOsinStorageInterface, token, tokenTypeHint string)
func RevokeTokenHandler ¶
func RevokeTokenHandler(w http.ResponseWriter, r *http.Request)
func SetCheckerHostList ¶
func SetCheckerHostList()
func SetupNewRelic ¶
func SetupNewRelic() (app newrelic.Application)
SetupNewRelic creates new newrelic.Application instance
func StartPeriodicStateBackup ¶
func StartPeriodicStateBackup(m *letsencrypt.Manager)
func StoreLEState ¶
func StoreLEState(m *letsencrypt.Manager)
func TykGetData ¶
TykGetData is a CoProcess API function for fetching data.
func TykSessionState ¶
func TykSessionState(session *coprocess.SessionState) *user.SessionState
TykSessionState takes a coprocess.SessionState (as returned by the Protocol Buffer binding), and outputs a standard Tyk SessionState.
func TykStoreData ¶
TykStoreData is a CoProcess API function for storing data.
func TykTriggerEvent ¶
TykTriggerEvent is a CoProcess API function for triggering Tyk system events.
func UpdateAPIVersion ¶
func UpdateAPIVersion(spec *APISpec, name string, verGen func(version *apidef.VersionInfo))
Types ¶
type APIAllCertificates ¶
type APIAllCertificates struct {
CertIDs []string `json:"certs"`
}
type APIDefinitionLoader ¶
type APIDefinitionLoader struct{}
APIDefinitionLoader will load an Api definition from a storage system.
func (APIDefinitionLoader) FromDashboardService ¶
func (a APIDefinitionLoader) FromDashboardService(endpoint, secret string) ([]*APISpec, error)
FromDashboardService will connect and download ApiDefintions from a Tyk Dashboard instance.
func (APIDefinitionLoader) FromDir ¶
func (a APIDefinitionLoader) FromDir(dir string) []*APISpec
FromDir will load APIDefinitions from a directory on the filesystem. Definitions need to be the JSON representation of APIDefinition object
func (APIDefinitionLoader) FromRPC ¶
func (a APIDefinitionLoader) FromRPC(orgId string) ([]*APISpec, error)
FromCloud will connect and download ApiDefintions from a Mongo DB instance.
func (APIDefinitionLoader) MakeSpec ¶
func (a APIDefinitionLoader) MakeSpec(def *apidef.APIDefinition, logger *logrus.Entry) *APISpec
MakeSpec will generate a flattened URLSpec from and APIDefinitions' VersionInfo data. paths are keyed to the Api version name, which is determined during routing to speed up lookups
func (APIDefinitionLoader) ParseDefinition ¶
func (a APIDefinitionLoader) ParseDefinition(r io.Reader) *apidef.APIDefinition
type APIError ¶
APIError is generic error object returned if there is something wrong with the request
type APISpec ¶
type APISpec struct { *apidef.APIDefinition sync.RWMutex RxPaths map[string][]URLSpec WhiteListEnabled map[string]bool AuthManager SessionHandler SessionManager SessionHandler OAuthManager *OAuthManager OrgSessionManager SessionHandler EventPaths map[apidef.TykEvent][]config.TykEventHandler Health HealthChecker JSVM JSVM ResponseChain []TykResponseHandler RoundRobin RoundRobin URLRewriteEnabled bool CircuitBreakerEnabled bool EnforcedTimeoutEnabled bool LastGoodHostList *apidef.HostList HasRun bool ServiceRefreshInProgress bool HTTPTransport http.RoundTripper HTTPTransportCreated time.Time WSTransport http.RoundTripper WSTransportCreated time.Time GlobalConfig config.Config OrgHasNoSession bool // contains filtered or unexported fields }
APISpec represents a path specification for an API, to avoid enumerating multiple nested lists, a single flattened URL list is checked for matching paths and then it's status evaluated if found.
func BuildAndLoadAPI ¶
func LoadSampleAPI ¶
func (*APISpec) CheckSpecMatchesStatus ¶
func (a *APISpec) CheckSpecMatchesStatus(r *http.Request, rxPaths []URLSpec, mode URLStatus) (bool, interface{})
CheckSpecMatchesStatus checks if a url spec has a specific status
func (*APISpec) Release ¶
func (s *APISpec) Release()
Release re;leases all resources associated with API spec
func (*APISpec) RequestValid ¶
func (a *APISpec) RequestValid(r *http.Request) (bool, RequestStatus, interface{})
RequestValid will check if an incoming request has valid version data and return a RequestStatus that describes the status of the request
func (*APISpec) StopSessionManagerPool ¶
func (a *APISpec) StopSessionManagerPool()
func (*APISpec) StripListenPath ¶
func (*APISpec) URLAllowedAndIgnored ¶
func (a *APISpec) URLAllowedAndIgnored(r *http.Request, rxPaths []URLSpec, whiteListStatus bool) (RequestStatus, interface{})
URLAllowedAndIgnored checks if a url is allowed and ignored.
func (*APISpec) Validate ¶
Validate returns nil if s is a valid spec and an error stating why the spec is not valid.
func (*APISpec) Version ¶
func (a *APISpec) Version(r *http.Request) (*apidef.VersionInfo, []URLSpec, bool, RequestStatus)
Version attempts to extract the version data from a request, depending on where it is stored in the request (currently only "header" is supported)
func (*APISpec) VersionExpired ¶
VersionExpired checks if an API version (during a proxied request) is expired. If it isn't and the configured time was valid, it also returns the expiration time.
type AccessRightsCheck ¶
type AccessRightsCheck struct {
BaseMiddleware
}
AccessRightsCheck is a middleware that will check if the key bing used to access the API has permission to access the specific version. If no permission data is in the user.SessionState, then it is assumed that the user can go through.
func (*AccessRightsCheck) Name ¶
func (a *AccessRightsCheck) Name() string
func (*AccessRightsCheck) ProcessRequest ¶
func (a *AccessRightsCheck) ProcessRequest(w http.ResponseWriter, r *http.Request, _ interface{}) (error, int)
ProcessRequest will run any checks on the request on the way through the system, return an error to have the chain fail
type AnalyticsRecord ¶
type AnalyticsRecord struct { Method string Host string Path string // HTTP path, can be overriden by "track path" plugin RawPath string // Original HTTP path ContentLength int64 UserAgent string Day int Month time.Month Year int Hour int ResponseCode int APIKey string TimeStamp time.Time APIVersion string APIName string APIID string OrgID string OauthID string RequestTime int64 Latency Latency RawRequest string // Base64 encoded request data (if detailed recording turned on) RawResponse string // ^ same but for response IPAddress string Geo GeoData Network NetworkStats Tags []string Alias string TrackPath bool ExpireAt time.Time `bson:"expireAt" json:"expireAt"` }
AnalyticsRecord encodes the details of a request
func (*AnalyticsRecord) GetGeo ¶
func (a *AnalyticsRecord) GetGeo(ipStr string)
func (*AnalyticsRecord) NormalisePath ¶
func (a *AnalyticsRecord) NormalisePath(globalConfig *config.Config)
func (*AnalyticsRecord) SetExpiry ¶
func (a *AnalyticsRecord) SetExpiry(expiresInSeconds int64)
type AuthKey ¶
type AuthKey struct {
BaseMiddleware
}
KeyExists will check if the key being used to access the API is in the request data, and then if the key is in the storage engine
func (*AuthKey) ProcessRequest ¶
type BaseExtractor ¶
type BaseExtractor struct { Config *apidef.MiddlewareIdExtractor BaseMid BaseMiddleware Spec *APISpec }
BaseExtractor is the base structure for an ID extractor, it implements the IdExtractor interface. Other extractors may override some of its methods.
func (*BaseExtractor) Error ¶
func (e *BaseExtractor) Error(r *http.Request, err error, message string) (returnOverrides ReturnOverrides)
Error is a helper for logging the extractor errors. It always returns HTTP 400 (so we don't expose any details).
func (*BaseExtractor) ExtractAndCheck ¶
func (e *BaseExtractor) ExtractAndCheck(r *http.Request) (sessionID string, returnOverrides ReturnOverrides)
ExtractAndCheck is called from the CP middleware, if ID extractor is enabled for the current API.
func (*BaseExtractor) ExtractBody ¶
func (e *BaseExtractor) ExtractBody(r *http.Request) (string, error)
ExtractBody is used when BodySource is specified.
func (*BaseExtractor) ExtractForm ¶
func (e *BaseExtractor) ExtractForm(r *http.Request, paramName string) (formValue string, err error)
ExtractForm is used when a FormSource is specified.
func (*BaseExtractor) ExtractHeader ¶
func (e *BaseExtractor) ExtractHeader(r *http.Request) (headerValue string, err error)
ExtractHeader is used when a HeaderSource is specified.
func (*BaseExtractor) GenerateSessionID ¶
func (e *BaseExtractor) GenerateSessionID(input string, mw BaseMiddleware) (sessionID string)
GenerateSessionID is a helper for generating session IDs, it takes an input (usually the extractor output) and a middleware pointer.
type BaseMiddleware ¶
type BaseMiddleware struct { Spec *APISpec Proxy ReturningHttpHandler // contains filtered or unexported fields }
BaseMiddleware wraps up the ApiSpec and Proxy objects to be included in a middleware handler, this can probably be handled better.
func (BaseMiddleware) ApplyPolicies ¶
func (t BaseMiddleware) ApplyPolicies(session *user.SessionState) error
ApplyPolicies will check if any policies are loaded. If any are, it will overwrite the session state to use the policy values.
func (BaseMiddleware) Base ¶
func (t BaseMiddleware) Base() *BaseMiddleware
func (BaseMiddleware) CheckSessionAndIdentityForValidKey ¶
func (t BaseMiddleware) CheckSessionAndIdentityForValidKey(originalKey *string, r *http.Request) (user.SessionState, bool)
CheckSessionAndIdentityForValidKey will check first the Session store for a valid key, if not found, it will try the Auth Handler, if not found it will fail
func (BaseMiddleware) Config ¶
func (t BaseMiddleware) Config() (interface{}, error)
func (BaseMiddleware) EnabledForSpec ¶
func (t BaseMiddleware) EnabledForSpec() bool
func (BaseMiddleware) FireEvent ¶
func (t BaseMiddleware) FireEvent(name apidef.TykEvent, meta interface{})
FireEvent is added to the BaseMiddleware object so it is available across the entire stack
func (BaseMiddleware) Init ¶
func (t BaseMiddleware) Init()
func (BaseMiddleware) Logger ¶
func (t BaseMiddleware) Logger() (logger *logrus.Entry)
func (BaseMiddleware) OrgSession ¶
func (t BaseMiddleware) OrgSession(key string) (user.SessionState, bool)
func (BaseMiddleware) OrgSessionExpiry ¶
func (t BaseMiddleware) OrgSessionExpiry(orgid string) int64
func (*BaseMiddleware) SetName ¶
func (t *BaseMiddleware) SetName(name string)
func (BaseMiddleware) SetOrgExpiry ¶
func (t BaseMiddleware) SetOrgExpiry(orgid string, expiry int64)
func (*BaseMiddleware) SetRequestLogger ¶
func (t *BaseMiddleware) SetRequestLogger(r *http.Request)
func (BaseMiddleware) UpdateRequestSession ¶
func (t BaseMiddleware) UpdateRequestSession(r *http.Request) bool
type BasicAuthKeyIsValid ¶
type BasicAuthKeyIsValid struct { BaseMiddleware // contains filtered or unexported fields }
BasicAuthKeyIsValid uses a username instead of
func (*BasicAuthKeyIsValid) EnabledForSpec ¶
func (k *BasicAuthKeyIsValid) EnabledForSpec() bool
EnabledForSpec checks if UseBasicAuth is set in the API definition.
func (*BasicAuthKeyIsValid) Name ¶
func (k *BasicAuthKeyIsValid) Name() string
func (*BasicAuthKeyIsValid) ProcessRequest ¶
func (k *BasicAuthKeyIsValid) ProcessRequest(w http.ResponseWriter, r *http.Request, _ interface{}) (error, int)
ProcessRequest will run any checks on the request on the way through the system, return an error to have the chain fail
type BatchReplyUnit ¶
type BatchReplyUnit struct { RelativeURL string `json:"relative_url"` Code int `json:"code"` Headers http.Header `json:"headers"` Body string `json:"body"` }
BatchReplyUnit encodes a request suitable for replying to a batch request
type BatchRequestHandler ¶
type BatchRequestHandler struct {
API *APISpec
}
BatchRequestHandler handles batch requests on /tyk/batch for any API Definition that has the feature enabled
func (*BatchRequestHandler) ConstructRequests ¶
func (b *BatchRequestHandler) ConstructRequests(batchRequest BatchRequestStructure, unsafe bool) ([]*http.Request, error)
func (*BatchRequestHandler) DecodeBatchRequest ¶
func (b *BatchRequestHandler) DecodeBatchRequest(r *http.Request) (BatchRequestStructure, error)
func (*BatchRequestHandler) HandleBatchRequest ¶
func (b *BatchRequestHandler) HandleBatchRequest(w http.ResponseWriter, r *http.Request)
HandleBatchRequest is the actual http handler for a batch request on an API definition
func (*BatchRequestHandler) MakeRequests ¶
func (b *BatchRequestHandler) MakeRequests(batchRequest BatchRequestStructure, requestSet []*http.Request) []BatchReplyUnit
func (*BatchRequestHandler) ManualBatchRequest ¶
func (b *BatchRequestHandler) ManualBatchRequest(requestObject []byte) ([]byte, error)
HandleBatchRequest is the actual http handler for a batch request on an API definition
type BatchRequestStructure ¶
type BatchRequestStructure struct { Requests []RequestDefinition `json:"requests"` SuppressParallelExecution bool `json:"suppress_parallel_execution"` }
BatchRequestStructure defines a batch request order
type Bundle ¶
type Bundle struct { Name string Data []byte Path string Spec *APISpec Manifest apidef.BundleManifest }
Bundle is the basic bundle data structure, it holds the bundle name and the data.
type BundleGetter ¶
BundleGetter is used for downloading bundle data, see HttpBundleGetter for reference.
type BundleSaver ¶
BundleSaver is an interface used by bundle saver structures.
type CertificateCheckMW ¶
type CertificateCheckMW struct {
BaseMiddleware
}
CertificateCheckMW is used if domain was not detected or multiple APIs bind on the same domain. In this case authentification check happens not on TLS side but on HTTP level using this middleware
func (*CertificateCheckMW) EnabledForSpec ¶
func (m *CertificateCheckMW) EnabledForSpec() bool
func (*CertificateCheckMW) Name ¶
func (m *CertificateCheckMW) Name() string
func (*CertificateCheckMW) ProcessRequest ¶
func (m *CertificateCheckMW) ProcessRequest(w http.ResponseWriter, r *http.Request, _ interface{}) (error, int)
type ChainObject ¶
type CoProcessEventHandler ¶
type CoProcessEventHandler struct { Spec *APISpec SpecJSON json.RawMessage // contains filtered or unexported fields }
func (*CoProcessEventHandler) HandleEvent ¶
func (l *CoProcessEventHandler) HandleEvent(em config.EventMessage)
func (*CoProcessEventHandler) Init ¶
func (l *CoProcessEventHandler) Init(handlerConf interface{}) error
type CoProcessEventWrapper ¶
type CoProcessEventWrapper struct { Event config.EventMessage `json:"message"` Handler string `json:"handler_name"` SpecJSON *json.RawMessage `json:"spec"` }
type CoProcessMiddleware ¶
type CoProcessMiddleware struct { BaseMiddleware HookType coprocess.HookType HookName string MiddlewareDriver apidef.MiddlewareDriver RawBodyOnly bool // contains filtered or unexported fields }
CoProcessMiddleware is the basic CP middleware struct.
func (*CoProcessMiddleware) EnabledForSpec ¶
func (m *CoProcessMiddleware) EnabledForSpec() bool
EnabledForSpec checks if this middleware should be enabled for a given API.
func (*CoProcessMiddleware) Name ¶
func (m *CoProcessMiddleware) Name() string
func (*CoProcessMiddleware) ProcessRequest ¶
func (m *CoProcessMiddleware) ProcessRequest(w http.ResponseWriter, r *http.Request, _ interface{}) (error, int)
ProcessRequest will run any checks on the request on the way through the system, return an error to have the chain fail
type CoProcessor ¶
type CoProcessor struct { HookType coprocess.HookType Middleware *CoProcessMiddleware }
CoProcessor represents a CoProcess during the request.
func (*CoProcessor) ObjectFromRequest ¶
ObjectFromRequest constructs a CoProcessObject from a given http.Request.
func (*CoProcessor) ObjectPostProcess ¶
func (c *CoProcessor) ObjectPostProcess(object *coprocess.Object, r *http.Request, origURL string, origMethod string) (err error)
ObjectPostProcess does CoProcessObject post-processing (adding/removing headers or params, etc.).
type ConfigPayload ¶
type DBAccessDefinition ¶
type DBAccessDefinition struct { APIName string `json:"apiname"` APIID string `json:"apiid"` Versions []string `json:"versions"` AllowedURLs []user.AccessSpec `bson:"allowed_urls" json:"allowed_urls"` // mapped string MUST be a valid regex Limit *user.APILimit `json:"limit"` }
func (*DBAccessDefinition) ToRegularAD ¶
func (d *DBAccessDefinition) ToRegularAD() user.AccessDefinition
type DBPolicy ¶
type DBPolicy struct { user.Policy AccessRights map[string]DBAccessDefinition `bson:"access_rights" json:"access_rights"` }
func (*DBPolicy) ToRegularPolicy ¶
type DashboardServiceSender ¶
type DefaultHealthChecker ¶
type DefaultHealthChecker struct { APIID string // contains filtered or unexported fields }
func (*DefaultHealthChecker) ApiHealthValues ¶
func (h *DefaultHealthChecker) ApiHealthValues() (HealthCheckValues, error)
func (*DefaultHealthChecker) CreateKeyName ¶
func (h *DefaultHealthChecker) CreateKeyName(subKey HealthPrefix) string
func (*DefaultHealthChecker) Init ¶
func (h *DefaultHealthChecker) Init(storeType storage.Handler)
func (*DefaultHealthChecker) StoreCounterVal ¶
func (h *DefaultHealthChecker) StoreCounterVal(counterType HealthPrefix, value string)
type DefaultKeyGenerator ¶
type DefaultKeyGenerator struct{}
func (DefaultKeyGenerator) GenerateAuthKey ¶
func (DefaultKeyGenerator) GenerateAuthKey(orgID string) string
GenerateAuthKey is a utility function for generating new auth keys. Returns the storage key name and the actual key
func (DefaultKeyGenerator) GenerateHMACSecret ¶
func (DefaultKeyGenerator) GenerateHMACSecret() string
GenerateHMACSecret is a utility function for generating new auth keys. Returns the storage key name and the actual key
type DefaultSessionManager ¶
type DefaultSessionManager struct {
// contains filtered or unexported fields
}
func (*DefaultSessionManager) Init ¶
func (b *DefaultSessionManager) Init(store storage.Handler)
func (*DefaultSessionManager) KeyExpired ¶
func (b *DefaultSessionManager) KeyExpired(newSession *user.SessionState) bool
KeyExpired checks if a key has expired, if the value of user.SessionState.Expires is 0, it will be ignored
func (*DefaultSessionManager) RemoveSession ¶
func (b *DefaultSessionManager) RemoveSession(keyName string, hashed bool) bool
RemoveSession removes session from storage
func (*DefaultSessionManager) ResetQuota ¶
func (b *DefaultSessionManager) ResetQuota(keyName string, session *user.SessionState, isHashed bool)
func (*DefaultSessionManager) SessionDetail ¶
func (b *DefaultSessionManager) SessionDetail(keyName string, hashed bool) (user.SessionState, bool)
SessionDetail returns the session detail using the storage engine (either in memory or Redis)
func (*DefaultSessionManager) Sessions ¶
func (b *DefaultSessionManager) Sessions(filter string) []string
Sessions returns all sessions in the key store that match a filter key (a prefix)
func (*DefaultSessionManager) Stop ¶
func (b *DefaultSessionManager) Stop()
func (*DefaultSessionManager) Store ¶
func (b *DefaultSessionManager) Store() storage.Handler
func (*DefaultSessionManager) UpdateSession ¶
func (b *DefaultSessionManager) UpdateSession(keyName string, session *user.SessionState, resetTTLTo int64, hashed bool) error
UpdateSession updates the session state in the storage engine
type DummyProxyHandler ¶
type DummyProxyHandler struct {
SH SuccessHandler
}
func (*DummyProxyHandler) ServeHTTP ¶
func (d *DummyProxyHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
type DynamicMiddleware ¶
type DynamicMiddleware struct { BaseMiddleware MiddlewareClassName string Pre bool UseSession bool Auth bool }
DynamicMiddleware is a generic middleware that will execute JS code before continuing
func (*DynamicMiddleware) Name ¶
func (d *DynamicMiddleware) Name() string
func (*DynamicMiddleware) ProcessRequest ¶
func (d *DynamicMiddleware) ProcessRequest(w http.ResponseWriter, r *http.Request, _ interface{}) (error, int)
ProcessRequest will run any checks on the request on the way through the system, return an error to have the chain fail
type EndPointCacheMeta ¶
type ErrorHandler ¶
type ErrorHandler struct {
BaseMiddleware
}
ErrorHandler is invoked whenever there is an issue with a proxied request, most middleware will invoke the ErrorHandler if something is wrong with the request and halt the request processing through the chain
func (*ErrorHandler) HandleError ¶
func (e *ErrorHandler) HandleError(w http.ResponseWriter, r *http.Request, errMsg string, errCode int, writeResponse bool)
HandleError is the actual error handler and will store the error details in analytics if analytics processing is enabled.
type EventCurcuitBreakerMeta ¶
type EventCurcuitBreakerMeta struct { EventMetaDefault Path string APIID string CircuitEvent circuit.BreakerEvent }
EventCurcuitBreakerMeta is the event status for a circuit breaker tripping
type EventHostStatusMeta ¶
type EventHostStatusMeta struct { EventMetaDefault HostInfo HostHealthReport }
type EventKeyFailureMeta ¶
type EventKeyFailureMeta struct { EventMetaDefault Path string Origin string Key string }
EventKeyFailureMeta is the metadata structure for any failure related to a key, such as quota or auth failures.
type EventMetaDefault ¶
EventMetaDefault is a standard embedded struct to be used with custom event metadata types, gives an interface for easily extending event metadata objects
type EventTokenMeta ¶
type EventTokenMeta struct { EventMetaDefault Org string Key string }
type EventTriggerExceededMeta ¶
type EventTriggerExceededMeta struct { EventMetaDefault OrgID string `json:"org_id"` Key string `json:"key"` TriggerLimit int64 `json:"trigger_limit"` UsagePercentage int64 `json:"usage_percentage"` }
type EventVersionFailureMeta ¶
type EventVersionFailureMeta struct { EventMetaDefault Path string Origin string Key string Reason string }
EventVersionFailureMeta is the metadata structure for an auth failure (EventKeyExpired)
type ExtendedCircuitBreakerMeta ¶
type ExtendedCircuitBreakerMeta struct { apidef.CircuitBreakerMeta CB *circuit.Breaker `json:"-"` }
type ExtendedOsinStorageInterface ¶
type ExtendedOsinStorageInterface interface { osin.Storage // Create OAuth clients SetClient(id string, orgID string, client osin.Client, ignorePrefix bool) error // Custom getter to handle prefixing issues in Redis GetClientNoPrefix(id string) (osin.Client, error) GetClientTokens(id string) ([]OAuthClientToken, error) GetPaginatedClientTokens(id string, page int) ([]OAuthClientToken, int, error) GetExtendedClient(id string) (ExtendedOsinClientInterface, error) // Custom getter to handle prefixing issues in Redis GetExtendedClientNoPrefix(id string) (ExtendedOsinClientInterface, error) GetClients(filter string, orgID string, ignorePrefix bool) ([]ExtendedOsinClientInterface, error) DeleteClient(id string, orgID string, ignorePrefix bool) error // GetUser retrieves a Basic Access user token type from the key store GetUser(string) (*user.SessionState, error) // SetUser updates a Basic Access user token type in the key store SetUser(string, *user.SessionState, int64) error }
func GetStorageForApi ¶
func GetStorageForApi(apiID string) (ExtendedOsinStorageInterface, int, error)
type GRPCDispatcher ¶
type GRPCDispatcher struct {
coprocess.Dispatcher
}
GRPCDispatcher implements a coprocess.Dispatcher
func (*GRPCDispatcher) DispatchEvent ¶
func (d *GRPCDispatcher) DispatchEvent(eventJSON []byte)
DispatchEvent dispatches a Tyk event.
func (*GRPCDispatcher) HandleMiddlewareCache ¶
func (d *GRPCDispatcher) HandleMiddlewareCache(b *apidef.BundleManifest, basePath string)
HandleMiddlewareCache isn't used by gRPC.
func (*GRPCDispatcher) Reload ¶
func (d *GRPCDispatcher) Reload()
Reload triggers a reload affecting CP middlewares and event handlers.
type GeoData ¶
type GeoData struct { Country struct { ISOCode string `maxminddb:"iso_code"` } `maxminddb:"country"` City struct { Names map[string]string `maxminddb:"names"` } `maxminddb:"city"` Location struct { Latitude float64 `maxminddb:"latitude"` Longitude float64 `maxminddb:"longitude"` TimeZone string `maxminddb:"time_zone"` } `maxminddb:"location"` }
type GetConfigPayload ¶
type GoPluginMiddleware ¶
type GoPluginMiddleware struct { BaseMiddleware Path string // path to .so file SymbolName string // function symbol to look up // contains filtered or unexported fields }
GoPluginMiddleware is a generic middleware that will execute Go-plugin code before continuing
func (*GoPluginMiddleware) EnabledForSpec ¶
func (m *GoPluginMiddleware) EnabledForSpec() bool
func (*GoPluginMiddleware) Name ¶
func (m *GoPluginMiddleware) Name() string
func (*GoPluginMiddleware) ProcessRequest ¶
func (m *GoPluginMiddleware) ProcessRequest(w http.ResponseWriter, r *http.Request, conf interface{}) (err error, respCode int)
type GranularAccessMiddleware ¶
type GranularAccessMiddleware struct {
BaseMiddleware
}
GranularAccessMiddleware will check if a URL is specifically enabled for the key
func (*GranularAccessMiddleware) Name ¶
func (m *GranularAccessMiddleware) Name() string
func (*GranularAccessMiddleware) ProcessRequest ¶
func (m *GranularAccessMiddleware) ProcessRequest(w http.ResponseWriter, r *http.Request, _ interface{}) (error, int)
ProcessRequest will run any checks on the request on the way through the system, return an error to have the chain fail
type HMACFieldValues ¶
type HTTPBundleGetter ¶
HTTPBundleGetter is a simple HTTP BundleGetter.
func (*HTTPBundleGetter) Get ¶
func (g *HTTPBundleGetter) Get() ([]byte, error)
Get performs an HTTP GET request.
type HTTPDashboardHandler ¶
type HTTPDashboardHandler struct { RegistrationEndpoint string DeRegistrationEndpoint string HeartBeatEndpoint string KeyQuotaTriggerEndpoint string Secret string // contains filtered or unexported fields }
func (*HTTPDashboardHandler) DeRegister ¶
func (h *HTTPDashboardHandler) DeRegister() error
func (*HTTPDashboardHandler) Init ¶
func (h *HTTPDashboardHandler) Init() error
func (*HTTPDashboardHandler) NotifyDashboardOfEvent ¶
func (h *HTTPDashboardHandler) NotifyDashboardOfEvent(event interface{}) error
NotifyDashboardOfEvent acts as a form of event which informs the dashboard of a key which has reached a certain usage quota
func (*HTTPDashboardHandler) Register ¶
func (h *HTTPDashboardHandler) Register() error
func (*HTTPDashboardHandler) StartBeating ¶
func (h *HTTPDashboardHandler) StartBeating() error
func (*HTTPDashboardHandler) StopBeating ¶
func (h *HTTPDashboardHandler) StopBeating()
type HTTPSignatureValidationMiddleware ¶
type HTTPSignatureValidationMiddleware struct { BaseMiddleware // contains filtered or unexported fields }
HTTPSignatureValidationMiddleware will check if the request has a signature, and if the request is allowed through
func (*HTTPSignatureValidationMiddleware) EnabledForSpec ¶
func (k *HTTPSignatureValidationMiddleware) EnabledForSpec() bool
func (*HTTPSignatureValidationMiddleware) Init ¶
func (hm *HTTPSignatureValidationMiddleware) Init()
func (*HTTPSignatureValidationMiddleware) Name ¶
func (hm *HTTPSignatureValidationMiddleware) Name() string
func (*HTTPSignatureValidationMiddleware) ProcessRequest ¶
func (hm *HTTPSignatureValidationMiddleware) ProcessRequest(w http.ResponseWriter, r *http.Request, _ interface{}) (error, int)
type HeaderInjector ¶
type HeaderInjector struct { Spec *APISpec // contains filtered or unexported fields }
func (*HeaderInjector) HandleResponse ¶
func (h *HeaderInjector) HandleResponse(rw http.ResponseWriter, res *http.Response, req *http.Request, ses *user.SessionState) error
func (*HeaderInjector) Init ¶
func (h *HeaderInjector) Init(c interface{}, spec *APISpec) error
func (HeaderInjector) Name ¶
func (HeaderInjector) Name() string
type HeaderInjectorOptions ¶
type HeaderTransform ¶
type HeaderTransform struct { Spec *APISpec // contains filtered or unexported fields }
func (*HeaderTransform) HandleResponse ¶
func (h *HeaderTransform) HandleResponse(rw http.ResponseWriter, res *http.Response, req *http.Request, ses *user.SessionState) error
func (*HeaderTransform) Init ¶
func (h *HeaderTransform) Init(c interface{}, spec *APISpec) error
func (HeaderTransform) Name ¶
func (HeaderTransform) Name() string
type HeaderTransformOptions ¶
type HeaderTransformOptions struct {
RevProxyTransform RevProxyTransform `mapstructure:"rev_proxy_header_cleanup" bson:"rev_proxy_header_cleanup" json:"rev_proxy_header_cleanup"`
}
type HealthCheckValues ¶
type HealthCheckValues struct { ThrottledRequestsPS float64 `bson:"throttle_reqests_per_second,omitempty" json:"throttle_reqests_per_second"` QuotaViolationsPS float64 `bson:"quota_violations_per_second,omitempty" json:"quota_violations_per_second"` KeyFailuresPS float64 `bson:"key_failures_per_second,omitempty" json:"key_failures_per_second"` AvgUpstreamLatency float64 `bson:"average_upstream_latency,omitempty" json:"average_upstream_latency"` AvgRequestsPS float64 `bson:"average_requests_per_second,omitempty" json:"average_requests_per_second"` }
type HealthChecker ¶
type HealthChecker interface { Init(storage.Handler) ApiHealthValues() (HealthCheckValues, error) StoreCounterVal(HealthPrefix, string) }
type HealthPrefix ¶
type HealthPrefix string
const ( Throttle HealthPrefix = "Throttle" QuotaViolation HealthPrefix = "QuotaViolation" KeyFailure HealthPrefix = "KeyFailure" RequestLog HealthPrefix = "Request" BlockedRequestLog HealthPrefix = "BlockedRequest" )
type HostCheckerManager ¶
type HostCheckerManager struct { Id string // contains filtered or unexported fields }
var GlobalHostChecker HostCheckerManager
func (*HostCheckerManager) AmIPolling ¶
func (hc *HostCheckerManager) AmIPolling() bool
func (*HostCheckerManager) CheckActivePollerLoop ¶
func (hc *HostCheckerManager) CheckActivePollerLoop()
func (*HostCheckerManager) DoServiceDiscoveryListUpdateForID ¶
func (hc *HostCheckerManager) DoServiceDiscoveryListUpdateForID(apiID string)
func (*HostCheckerManager) GenerateCheckerId ¶
func (hc *HostCheckerManager) GenerateCheckerId()
func (*HostCheckerManager) HostDown ¶
func (hc *HostCheckerManager) HostDown(urlStr string) bool
func (*HostCheckerManager) Init ¶
func (hc *HostCheckerManager) Init(store storage.Handler)
func (*HostCheckerManager) ListFromService ¶
func (hc *HostCheckerManager) ListFromService(apiID string) ([]HostData, error)
func (*HostCheckerManager) OnHostBackUp ¶
func (hc *HostCheckerManager) OnHostBackUp(report HostHealthReport)
func (*HostCheckerManager) OnHostDown ¶
func (hc *HostCheckerManager) OnHostDown(report HostHealthReport)
func (*HostCheckerManager) OnHostReport ¶
func (hc *HostCheckerManager) OnHostReport(report HostHealthReport)
func (*HostCheckerManager) PrepareTrackingHost ¶
func (hc *HostCheckerManager) PrepareTrackingHost(checkObject apidef.HostCheckObject, apiID string) (HostData, error)
func (*HostCheckerManager) RecordUptimeAnalytics ¶
func (hc *HostCheckerManager) RecordUptimeAnalytics(report HostHealthReport) error
RecordHit will store an AnalyticsRecord in Redis
func (*HostCheckerManager) Start ¶
func (hc *HostCheckerManager) Start()
func (*HostCheckerManager) StartPoller ¶
func (hc *HostCheckerManager) StartPoller()
func (*HostCheckerManager) StopPoller ¶
func (hc *HostCheckerManager) StopPoller()
func (*HostCheckerManager) UpdateTrackingList ¶
func (hc *HostCheckerManager) UpdateTrackingList(hd []HostData)
func (*HostCheckerManager) UpdateTrackingListByAPIID ¶
func (hc *HostCheckerManager) UpdateTrackingListByAPIID(hd []HostData, apiId string)
func (*HostCheckerManager) UptimePurgeLoop ¶
func (hc *HostCheckerManager) UptimePurgeLoop()
type HostHealthReport ¶
type HostUptimeChecker ¶
type HostUptimeChecker struct { HostList map[string]HostData // contains filtered or unexported fields }
func (*HostUptimeChecker) CheckHost ¶
func (h *HostUptimeChecker) CheckHost(toCheck HostData)
func (*HostUptimeChecker) HostCheckLoop ¶
func (h *HostUptimeChecker) HostCheckLoop()
func (*HostUptimeChecker) HostReporter ¶
func (h *HostUptimeChecker) HostReporter()
func (*HostUptimeChecker) Init ¶
func (h *HostUptimeChecker) Init(workers, triggerLimit, timeout int, hostList map[string]HostData, failureCallback, upCallback, pingCallback func(HostHealthReport))
func (*HostUptimeChecker) ResetList ¶
func (h *HostUptimeChecker) ResetList(hostList map[string]HostData)
func (*HostUptimeChecker) Start ¶
func (h *HostUptimeChecker) Start()
func (*HostUptimeChecker) Stop ¶
func (h *HostUptimeChecker) Stop()
type IPBlackListMiddleware ¶
type IPBlackListMiddleware struct {
BaseMiddleware
}
IPBlackListMiddleware lets you define a list of IPs to block from upstream
func (*IPBlackListMiddleware) EnabledForSpec ¶
func (i *IPBlackListMiddleware) EnabledForSpec() bool
func (*IPBlackListMiddleware) Name ¶
func (i *IPBlackListMiddleware) Name() string
func (*IPBlackListMiddleware) ProcessRequest ¶
func (i *IPBlackListMiddleware) ProcessRequest(w http.ResponseWriter, r *http.Request, _ interface{}) (error, int)
ProcessRequest will run any checks on the request on the way through the system, return an error to have the chain fail
type IPWhiteListMiddleware ¶
type IPWhiteListMiddleware struct {
BaseMiddleware
}
IPWhiteListMiddleware lets you define a list of IPs to allow upstream
func (*IPWhiteListMiddleware) EnabledForSpec ¶
func (i *IPWhiteListMiddleware) EnabledForSpec() bool
func (*IPWhiteListMiddleware) Name ¶
func (i *IPWhiteListMiddleware) Name() string
func (*IPWhiteListMiddleware) ProcessRequest ¶
func (i *IPWhiteListMiddleware) ProcessRequest(w http.ResponseWriter, r *http.Request, _ interface{}) (error, int)
ProcessRequest will run any checks on the request on the way through the system, return an error to have the chain fail
type IdExtractor ¶
type IdExtractor interface { ExtractAndCheck(*http.Request) (string, ReturnOverrides) GenerateSessionID(string, BaseMiddleware) string }
IdExtractor is the base interface for an ID extractor.
type InterfaceNotification ¶
type JSVM ¶
type JSVM struct { Spec *APISpec VM *otto.Otto Timeout time.Duration Log *logrus.Entry // logger used by the JS code RawLog *logrus.Logger // logger used by `rawlog` func to avoid formatting }
func (*JSVM) LoadJSPaths ¶
LoadJSPaths will load JS classes and functionality in to the VM by file
func (*JSVM) LoadTykJSApi ¶
func (j *JSVM) LoadTykJSApi()
type JSVMContextGlobal ¶
type JSVMEventHandler ¶
type JSVMEventHandler struct { Spec *APISpec SpecJSON string // contains filtered or unexported fields }
JSVMEventHandler is a scriptable event handler
func (*JSVMEventHandler) HandleEvent ¶
func (l *JSVMEventHandler) HandleEvent(em config.EventMessage)
HandleEvent will be fired when the event handler instance is found in an APISpec EventPaths object during a request chain
func (*JSVMEventHandler) Init ¶
func (l *JSVMEventHandler) Init(handlerConf interface{}) error
New enables the intitialisation of event handler instances when they are created on ApiSpec creation
type JWTMiddleware ¶
type JWTMiddleware struct {
BaseMiddleware
}
func (*JWTMiddleware) EnabledForSpec ¶
func (k *JWTMiddleware) EnabledForSpec() bool
func (*JWTMiddleware) Name ¶
func (k *JWTMiddleware) Name() string
func (*JWTMiddleware) ProcessRequest ¶
func (k *JWTMiddleware) ProcessRequest(w http.ResponseWriter, r *http.Request, _ interface{}) (error, int)
type KeyExpired ¶
type KeyExpired struct {
BaseMiddleware
}
KeyExpired middleware will check if the requesting key is expired or not. It makes use of the authManager to do so.
func (*KeyExpired) Name ¶
func (k *KeyExpired) Name() string
func (*KeyExpired) ProcessRequest ¶
func (k *KeyExpired) ProcessRequest(w http.ResponseWriter, r *http.Request, _ interface{}) (error, int)
ProcessRequest will run any checks on the request on the way through the system, return an error to have the chain fail
type LDAPStorageHandler ¶
type LDAPStorageHandler struct { LDAPServer string LDAPPort uint16 BaseDN string Attributes []string SessionAttributeName string SearchString string // contains filtered or unexported fields }
LDAPStorageHandler implements storage.Handler, this is a read-only implementation to access keys from an LDAP service
func (LDAPStorageHandler) AddToSet ¶
func (l LDAPStorageHandler) AddToSet(keyName, value string)
func (LDAPStorageHandler) AddToSortedSet ¶
func (l LDAPStorageHandler) AddToSortedSet(keyName, value string, score float64)
func (LDAPStorageHandler) AppendToSet ¶
func (l LDAPStorageHandler) AppendToSet(keyName, value string)
func (*LDAPStorageHandler) AppendToSetPipelined ¶
func (r *LDAPStorageHandler) AppendToSetPipelined(key string, values []string)
func (*LDAPStorageHandler) Connect ¶
func (l *LDAPStorageHandler) Connect() bool
func (*LDAPStorageHandler) Decrement ¶
func (l *LDAPStorageHandler) Decrement(keyName string)
func (*LDAPStorageHandler) DeleteAllKeys ¶
func (r *LDAPStorageHandler) DeleteAllKeys() bool
func (*LDAPStorageHandler) DeleteKey ¶
func (l *LDAPStorageHandler) DeleteKey(cn string) bool
func (*LDAPStorageHandler) DeleteKeys ¶
func (l *LDAPStorageHandler) DeleteKeys(keys []string) bool
func (*LDAPStorageHandler) DeleteRawKey ¶
func (l *LDAPStorageHandler) DeleteRawKey(cn string) bool
func (LDAPStorageHandler) DeleteScanMatch ¶
func (l LDAPStorageHandler) DeleteScanMatch(pattern string) bool
func (LDAPStorageHandler) GetAndDeleteSet ¶
func (l LDAPStorageHandler) GetAndDeleteSet(keyName string) []interface{}
func (*LDAPStorageHandler) GetKey ¶
func (l *LDAPStorageHandler) GetKey(filter string) (string, error)
func (LDAPStorageHandler) GetKeyPrefix ¶
func (l LDAPStorageHandler) GetKeyPrefix() string
func (*LDAPStorageHandler) GetKeys ¶
func (l *LDAPStorageHandler) GetKeys(filter string) []string
func (*LDAPStorageHandler) GetKeysAndValues ¶
func (l *LDAPStorageHandler) GetKeysAndValues() map[string]string
func (*LDAPStorageHandler) GetKeysAndValuesWithFilter ¶
func (l *LDAPStorageHandler) GetKeysAndValuesWithFilter(filter string) map[string]string
func (*LDAPStorageHandler) GetListRange ¶
func (l *LDAPStorageHandler) GetListRange(keyName string, from, to int64) ([]string, error)
func (*LDAPStorageHandler) GetMultiKey ¶
func (r *LDAPStorageHandler) GetMultiKey(keyNames []string) ([]string, error)
func (*LDAPStorageHandler) GetRawKey ¶
func (l *LDAPStorageHandler) GetRawKey(filter string) (string, error)
func (*LDAPStorageHandler) GetRollingWindow ¶
func (l *LDAPStorageHandler) GetRollingWindow(keyName string, per int64, pipeline bool) (int, []interface{})
func (LDAPStorageHandler) GetSet ¶
func (l LDAPStorageHandler) GetSet(keyName string) (map[string]string, error)
func (LDAPStorageHandler) GetSortedSetRange ¶
func (l LDAPStorageHandler) GetSortedSetRange(keyName, scoreFrom, scoreTo string) ([]string, []float64, error)
func (*LDAPStorageHandler) IncrememntWithExpire ¶
func (l *LDAPStorageHandler) IncrememntWithExpire(keyName string, timeout int64) int64
func (*LDAPStorageHandler) LoadConfFromMeta ¶
func (l *LDAPStorageHandler) LoadConfFromMeta(meta map[string]interface{})
func (LDAPStorageHandler) RemoveFromList ¶
func (l LDAPStorageHandler) RemoveFromList(keyName, value string) error
func (LDAPStorageHandler) RemoveFromSet ¶
func (l LDAPStorageHandler) RemoveFromSet(keyName, value string)
func (LDAPStorageHandler) RemoveSortedSetRange ¶
func (l LDAPStorageHandler) RemoveSortedSetRange(keyName, scoreFrom, scoreTo string) error
func (*LDAPStorageHandler) SetKey ¶
func (l *LDAPStorageHandler) SetKey(cn, session string, timeout int64) error
func (*LDAPStorageHandler) SetRawKey ¶
func (l *LDAPStorageHandler) SetRawKey(cn, session string, timeout int64) error
func (*LDAPStorageHandler) SetRollingWindow ¶
type LE_ServerInfo ¶
type LogMessageEventHandler ¶
type LogMessageEventHandler struct {
// contains filtered or unexported fields
}
LogMessageEventHandler is a sample Event Handler
func (*LogMessageEventHandler) HandleEvent ¶
func (l *LogMessageEventHandler) HandleEvent(em config.EventMessage)
HandleEvent will be fired when the event handler instance is found in an APISpec EventPaths object during a request chain
func (*LogMessageEventHandler) Init ¶
func (l *LogMessageEventHandler) Init(handlerConf interface{}) error
New enables the intitialisation of event handler instances when they are created on ApiSpec creation
type MethodNotAllowedHandler ¶
type MethodNotAllowedHandler struct{}
func (MethodNotAllowedHandler) ServeHTTP ¶
func (m MethodNotAllowedHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
type MiddlewareContextVars ¶
type MiddlewareContextVars struct {
BaseMiddleware
}
func (*MiddlewareContextVars) EnabledForSpec ¶
func (m *MiddlewareContextVars) EnabledForSpec() bool
func (*MiddlewareContextVars) Name ¶
func (m *MiddlewareContextVars) Name() string
func (*MiddlewareContextVars) ProcessRequest ¶
func (m *MiddlewareContextVars) ProcessRequest(w http.ResponseWriter, r *http.Request, _ interface{}) (error, int)
ProcessRequest will run any checks on the request on the way through the system, return an error to have the chain fail
type MiniRequestObject ¶
type MiniRequestObject struct { Headers map[string][]string SetHeaders map[string]string DeleteHeaders []string Body []byte URL string Params map[string][]string AddParams map[string]string ExtendedParams map[string][]string DeleteParams []string ReturnOverrides ReturnOverrides IgnoreBody bool Method string RequestURI string Scheme string }
MiniRequestObject is marshalled to JSON string and passed into JSON middleware
func (*MiniRequestObject) ReconstructParams ¶
func (mr *MiniRequestObject) ReconstructParams(r *http.Request)
type MockBundleGetter ¶
MockBundleGetter is a BundleGetter for testing.
func (*MockBundleGetter) Get ¶
func (g *MockBundleGetter) Get() ([]byte, error)
Get mocks an HTTP(S) GET request.
type MultiTargetProxy ¶
type MultiTargetProxy struct {
// contains filtered or unexported fields
}
func NewMultiTargetProxy ¶
func NewMultiTargetProxy(spec *APISpec, logger *logrus.Entry) *MultiTargetProxy
func (*MultiTargetProxy) CopyResponse ¶
func (m *MultiTargetProxy) CopyResponse(dst io.Writer, src io.Reader)
func (*MultiTargetProxy) ServeHTTP ¶
func (m *MultiTargetProxy) ServeHTTP(w http.ResponseWriter, r *http.Request) ProxyResponse
func (*MultiTargetProxy) ServeHTTPForCache ¶
func (m *MultiTargetProxy) ServeHTTPForCache(w http.ResponseWriter, r *http.Request) ProxyResponse
type NetworkStats ¶
type NetworkStats struct { OpenConnections int64 ClosedConnection int64 BytesIn int64 BytesOut int64 }
func (*NetworkStats) Flush ¶
func (n *NetworkStats) Flush() NetworkStats
type NewClientRequest ¶
type NewClientRequest struct { ClientID string `json:"client_id"` ClientRedirectURI string `json:"redirect_uri"` APIID string `json:"api_id,omitempty"` PolicyID string `json:"policy_id,omitempty"` ClientSecret string `json:"secret"` MetaData interface{} `json:"meta_data"` Description string `json:"description"` }
NewClientRequest is an outward facing JSON object translated from osin OAuthClients
swagger:model NewClientRequest
type NewOAuthNotification ¶
type NewOAuthNotification struct { AuthCode string `json:"auth_code"` NewOAuthToken string `json:"new_oauth_token"` RefreshToken string `json:"refresh_token"` OldRefreshToken string `json:"old_refresh_token"` NotificationType OAuthNotificationType `json:"notification_type"` }
NewOAuthNotification is a notification sent to a web-hook when an access request or a refresh request comes in.
type NodeResponseOK ¶
type Notification ¶
type Notification struct { Command NotificationCommand `json:"command"` Payload string `json:"payload"` Signature string `json:"signature"` SignatureAlgo crypto.Hash `json:"algorithm"` }
Notification is a type that encodes a message published to a pub sub channel (shared between implementations)
func (*Notification) Sign ¶
func (n *Notification) Sign()
type NotificationCommand ¶
type NotificationCommand string
const ( RedisPubSubChannel = "tyk.cluster.notifications" NoticeApiUpdated NotificationCommand = "ApiUpdated" NoticeApiRemoved NotificationCommand = "ApiRemoved" NoticeApiAdded NotificationCommand = "ApiAdded" NoticeGroupReload NotificationCommand = "GroupReload" NoticePolicyChanged NotificationCommand = "PolicyChanged" NoticeConfigUpdate NotificationCommand = "NoticeConfigUpdated" NoticeDashboardZeroConf NotificationCommand = "NoticeDashboardZeroConf" NoticeDashboardConfigRequest NotificationCommand = "NoticeDashboardConfigRequest" NoticeGatewayConfigResponse NotificationCommand = "NoticeGatewayConfigResponse" NoticeGatewayDRLNotification NotificationCommand = "NoticeGatewayDRLNotification" NoticeGatewayLENotification NotificationCommand = "NoticeGatewayLENotification" KeySpaceUpdateNotification NotificationCommand = "KeySpaceUpdateNotification" )
type OAuthClient ¶
type OAuthClient struct { ClientID string `json:"id"` ClientSecret string `json:"secret"` ClientRedirectURI string `json:"redirecturi"` MetaData interface{} `json:"meta_data,omitempty"` PolicyID string `json:"policyid"` Description string `json:"description"` }
OAuthClient is a representation within an APISpec of a client
func (*OAuthClient) GetDescription ¶
func (oc *OAuthClient) GetDescription() string
func (*OAuthClient) GetId ¶
func (oc *OAuthClient) GetId() string
func (*OAuthClient) GetPolicyID ¶
func (oc *OAuthClient) GetPolicyID() string
func (*OAuthClient) GetRedirectUri ¶
func (oc *OAuthClient) GetRedirectUri() string
func (*OAuthClient) GetSecret ¶
func (oc *OAuthClient) GetSecret() string
func (*OAuthClient) GetUserData ¶
func (oc *OAuthClient) GetUserData() interface{}
type OAuthClientToken ¶
swagger:model
type OAuthHandlers ¶
type OAuthHandlers struct {
Manager OAuthManager
}
OAuthHandlers are the HTTP Handlers that manage the Tyk OAuth flow
func (*OAuthHandlers) HandleAccessRequest ¶
func (o *OAuthHandlers) HandleAccessRequest(w http.ResponseWriter, r *http.Request)
HandleAccessRequest handles the OAuth 2.0 token or refresh access request, and wraps Tyk's own and Osin's OAuth handlers, returns a response to the client and notifies the provider of the access request (in order to track identity against OAuth tokens without revealing tokens before they are requested).
func (*OAuthHandlers) HandleAuthorizePassthrough ¶
func (o *OAuthHandlers) HandleAuthorizePassthrough(w http.ResponseWriter, r *http.Request)
HandleAuthorizePassthrough handles a Client Auth request, first it checks if the client is OK (otherwise it blocks the request), then it forwards on to the resource providers approval URI
func (*OAuthHandlers) HandleGenerateAuthCodeData ¶
func (o *OAuthHandlers) HandleGenerateAuthCodeData(w http.ResponseWriter, r *http.Request)
HandleGenerateAuthCodeData handles a resource provider approving an OAuth request from a client
func (*OAuthHandlers) HandleRevokeAllTokens ¶
func (o *OAuthHandlers) HandleRevokeAllTokens(w http.ResponseWriter, r *http.Request)
func (*OAuthHandlers) HandleRevokeToken ¶
func (o *OAuthHandlers) HandleRevokeToken(w http.ResponseWriter, r *http.Request)
in compliance with https://tools.ietf.org/html/rfc7009#section-2.1 ToDo: set an authentication mechanism
type OAuthManager ¶
type OAuthManager struct { API *APISpec OsinServer *TykOsinServer }
OAuthManager handles and wraps osin OAuth2 functions to handle authorise and access requests
func (*OAuthManager) HandleAccess ¶
func (o *OAuthManager) HandleAccess(r *http.Request) *osin.Response
HandleAccess wraps an access request with osin's primitives
func (*OAuthManager) HandleAuthorisation ¶
func (o *OAuthManager) HandleAuthorisation(r *http.Request, complete bool, session string) *osin.Response
HandleAuthorisation creates the authorisation data for the request
type OAuthNotificationType ¶
type OAuthNotificationType string
OAuthNotificationType const to reduce risk of collisions
type Oauth2KeyExists ¶
type Oauth2KeyExists struct {
BaseMiddleware
}
Oauth2KeyExists will check if the key being used to access the API is in the request data, and then if the key is in the storage engine
func (*Oauth2KeyExists) EnabledForSpec ¶
func (k *Oauth2KeyExists) EnabledForSpec() bool
func (*Oauth2KeyExists) Name ¶
func (k *Oauth2KeyExists) Name() string
func (*Oauth2KeyExists) ProcessRequest ¶
func (k *Oauth2KeyExists) ProcessRequest(w http.ResponseWriter, r *http.Request, _ interface{}) (error, int)
ProcessRequest will run any checks on the request on the way through the system, return an error to have the chain fail
type OpenIDMW ¶
type OpenIDMW struct { BaseMiddleware // contains filtered or unexported fields }
func (*OpenIDMW) EnabledForSpec ¶
func (*OpenIDMW) ProcessRequest ¶
type OrganizationMonitor ¶
type OrganizationMonitor struct { BaseMiddleware // contains filtered or unexported fields }
RateLimitAndQuotaCheck will check the incoming request and key whether it is within it's quota and within it's rate limit, it makes use of the SessionLimiter object to do this
func (*OrganizationMonitor) AllowAccessNext ¶
func (k *OrganizationMonitor) AllowAccessNext( orgChan chan bool, path string, IP string, r *http.Request, session *user.SessionState)
func (*OrganizationMonitor) EnabledForSpec ¶
func (k *OrganizationMonitor) EnabledForSpec() bool
func (*OrganizationMonitor) Name ¶
func (k *OrganizationMonitor) Name() string
func (*OrganizationMonitor) ProcessRequest ¶
func (k *OrganizationMonitor) ProcessRequest(w http.ResponseWriter, r *http.Request, conf interface{}) (error, int)
func (*OrganizationMonitor) ProcessRequestLive ¶
func (k *OrganizationMonitor) ProcessRequestLive(r *http.Request, orgSession user.SessionState) (error, int)
ProcessRequest will run any checks on the request on the way through the system, return an error to have the chain fail
func (*OrganizationMonitor) ProcessRequestOffThread ¶
func (k *OrganizationMonitor) ProcessRequestOffThread(r *http.Request, orgSession user.SessionState) (error, int)
func (*OrganizationMonitor) SetOrgSentinel ¶
func (k *OrganizationMonitor) SetOrgSentinel(orgChan chan bool, orgId string)
type PolicyUpdateObj ¶
type ProxyResponse ¶
type PublicSession ¶
type Purger ¶
Purger is an interface that will define how the in-memory store will be purged of analytics data to prevent it growing too large
type PythonDispatcher ¶
type PythonDispatcher struct {
coprocess.Dispatcher
}
PythonDispatcher implements a coprocess.Dispatcher
func (*PythonDispatcher) DispatchEvent ¶
func (d *PythonDispatcher) DispatchEvent(eventJSON []byte)
DispatchEvent dispatches a Tyk event.
func (*PythonDispatcher) HandleMiddlewareCache ¶
func (d *PythonDispatcher) HandleMiddlewareCache(b *apidef.BundleManifest, basePath string)
HandleMiddlewareCache isn't used by Python.
func (*PythonDispatcher) Reload ¶
func (d *PythonDispatcher) Reload()
Reload triggers a reload affecting CP middlewares and event handlers.
type RPCStorageHandler ¶
RPCStorageHandler is a storage manager that uses the redis database.
func (RPCStorageHandler) AddToSet ¶
func (r RPCStorageHandler) AddToSet(keyName, value string)
func (*RPCStorageHandler) AddToSortedSet ¶
func (r *RPCStorageHandler) AddToSortedSet(keyName, value string, score float64)
func (*RPCStorageHandler) AppendToSet ¶
func (r *RPCStorageHandler) AppendToSet(keyName, value string)
func (*RPCStorageHandler) AppendToSetPipelined ¶
func (r *RPCStorageHandler) AppendToSetPipelined(key string, values []string)
func (*RPCStorageHandler) CheckForKeyspaceChanges ¶
func (r *RPCStorageHandler) CheckForKeyspaceChanges(orgId string)
CheckForKeyspaceChanges will poll for keysace changes
func (*RPCStorageHandler) CheckForReload ¶
func (r *RPCStorageHandler) CheckForReload(orgId string)
CheckForReload will start a long poll
func (*RPCStorageHandler) Connect ¶
func (r *RPCStorageHandler) Connect() bool
Connect will establish a connection to the RPC
func (*RPCStorageHandler) Decrement ¶
func (r *RPCStorageHandler) Decrement(keyName string)
Decrement will decrement a key in redis
func (*RPCStorageHandler) DeleteAllKeys ¶
func (r *RPCStorageHandler) DeleteAllKeys() bool
func (*RPCStorageHandler) DeleteKey ¶
func (r *RPCStorageHandler) DeleteKey(keyName string) bool
DeleteKey will remove a key from the database
func (*RPCStorageHandler) DeleteKeys ¶
func (r *RPCStorageHandler) DeleteKeys(keys []string) bool
DeleteKeys will remove a group of keys in bulk
func (*RPCStorageHandler) DeleteRawKey ¶
func (r *RPCStorageHandler) DeleteRawKey(keyName string) bool
DeleteKey will remove a key from the database without prefixing, assumes user knows what they are doing
func (*RPCStorageHandler) DeleteScanMatch ¶
func (r *RPCStorageHandler) DeleteScanMatch(pattern string) bool
func (*RPCStorageHandler) GetAndDeleteSet ¶
func (r *RPCStorageHandler) GetAndDeleteSet(keyName string) []interface{}
func (*RPCStorageHandler) GetApiDefinitions ¶
func (r *RPCStorageHandler) GetApiDefinitions(orgId string, tags []string) string
GetAPIDefinitions will pull API definitions from the RPC server
func (*RPCStorageHandler) GetExp ¶
func (r *RPCStorageHandler) GetExp(keyName string) (int64, error)
func (*RPCStorageHandler) GetKey ¶
func (r *RPCStorageHandler) GetKey(keyName string) (string, error)
GetKey will retrieve a key from the database
func (*RPCStorageHandler) GetKeyPrefix ¶
func (r *RPCStorageHandler) GetKeyPrefix() string
func (*RPCStorageHandler) GetKeys ¶
func (r *RPCStorageHandler) GetKeys(filter string) []string
GetKeys will return all keys according to the filter (filter is a prefix - e.g. tyk.keys.*)
func (*RPCStorageHandler) GetKeysAndValues ¶
func (r *RPCStorageHandler) GetKeysAndValues() map[string]string
GetKeysAndValues will return all keys and their values - not to be used lightly
func (*RPCStorageHandler) GetKeysAndValuesWithFilter ¶
func (r *RPCStorageHandler) GetKeysAndValuesWithFilter(filter string) map[string]string
GetKeysAndValuesWithFilter will return all keys and their values with a filter
func (*RPCStorageHandler) GetListRange ¶
func (r *RPCStorageHandler) GetListRange(keyName string, from, to int64) ([]string, error)
func (*RPCStorageHandler) GetMultiKey ¶
func (r *RPCStorageHandler) GetMultiKey(keyNames []string) ([]string, error)
func (*RPCStorageHandler) GetPolicies ¶
func (r *RPCStorageHandler) GetPolicies(orgId string) string
GetPolicies will pull Policies from the RPC server
func (*RPCStorageHandler) GetRawKey ¶
func (r *RPCStorageHandler) GetRawKey(keyName string) (string, error)
func (*RPCStorageHandler) GetRollingWindow ¶
func (r *RPCStorageHandler) GetRollingWindow(keyName string, per int64, pipeline bool) (int, []interface{})
func (RPCStorageHandler) GetSet ¶
func (r RPCStorageHandler) GetSet(keyName string) (map[string]string, error)
func (*RPCStorageHandler) GetSortedSetRange ¶
func (r *RPCStorageHandler) GetSortedSetRange(keyName, scoreFrom, scoreTo string) ([]string, []float64, error)
func (*RPCStorageHandler) IncrememntWithExpire ¶
func (r *RPCStorageHandler) IncrememntWithExpire(keyName string, expire int64) int64
IncrementWithExpire will increment a key in redis
func (RPCStorageHandler) IsAccessError ¶
func (r RPCStorageHandler) IsAccessError(err error) bool
func (*RPCStorageHandler) ProcessKeySpaceChanges ¶
func (r *RPCStorageHandler) ProcessKeySpaceChanges(keys []string)
func (*RPCStorageHandler) Publish ¶
func (r *RPCStorageHandler) Publish(channel, message string) error
func (*RPCStorageHandler) RemoveFromList ¶
func (r *RPCStorageHandler) RemoveFromList(keyName, value string) error
func (RPCStorageHandler) RemoveFromSet ¶
func (r RPCStorageHandler) RemoveFromSet(keyName, value string)
func (*RPCStorageHandler) RemoveSortedSetRange ¶
func (r *RPCStorageHandler) RemoveSortedSetRange(keyName, scoreFrom, scoreTo string) error
func (*RPCStorageHandler) SetExp ¶
func (r *RPCStorageHandler) SetExp(keyName string, timeout int64) error
func (*RPCStorageHandler) SetKey ¶
func (r *RPCStorageHandler) SetKey(keyName, session string, timeout int64) error
SetKey will create (or update) a key value in the store
func (*RPCStorageHandler) SetRawKey ¶
func (r *RPCStorageHandler) SetRawKey(keyName, session string, timeout int64) error
func (*RPCStorageHandler) SetRollingWindow ¶
func (r *RPCStorageHandler) SetRollingWindow(keyName string, per int64, val string, pipeline bool) (int, []interface{})
SetScrollingWindow is used in the rate limiter to handle rate limits fairly.
func (*RPCStorageHandler) StartPubSubHandler ¶
func (r *RPCStorageHandler) StartPubSubHandler(channel string, callback func(*redis.Message)) error
StartPubSubHandler will listen for a signal and run the callback with the message
func (*RPCStorageHandler) StartRPCKeepaliveWatcher ¶
func (r *RPCStorageHandler) StartRPCKeepaliveWatcher()
func (*RPCStorageHandler) StartRPCLoopCheck ¶
func (r *RPCStorageHandler) StartRPCLoopCheck(orgId string)
type RateCheckMW ¶
type RateCheckMW struct {
BaseMiddleware
}
func (*RateCheckMW) Name ¶
func (m *RateCheckMW) Name() string
func (*RateCheckMW) ProcessRequest ¶
func (m *RateCheckMW) ProcessRequest(w http.ResponseWriter, r *http.Request, _ interface{}) (error, int)
type RateLimitAndQuotaCheck ¶
type RateLimitAndQuotaCheck struct {
BaseMiddleware
}
RateLimitAndQuotaCheck will check the incomming request and key whether it is within it's quota and within it's rate limit, it makes use of the SessionLimiter object to do this
func (*RateLimitAndQuotaCheck) EnabledForSpec ¶
func (k *RateLimitAndQuotaCheck) EnabledForSpec() bool
func (*RateLimitAndQuotaCheck) Name ¶
func (k *RateLimitAndQuotaCheck) Name() string
func (*RateLimitAndQuotaCheck) ProcessRequest ¶
func (k *RateLimitAndQuotaCheck) ProcessRequest(w http.ResponseWriter, r *http.Request, _ interface{}) (error, int)
ProcessRequest will run any checks on the request on the way through the system, return an error to have the chain fail
type RateLimitForAPI ¶
type RateLimitForAPI struct { BaseMiddleware // contains filtered or unexported fields }
RateLimitAndQuotaCheck will check the incoming request and key whether it is within it's quota and within it's rate limit, it makes use of the SessionLimiter object to do this
func (*RateLimitForAPI) EnabledForSpec ¶
func (k *RateLimitForAPI) EnabledForSpec() bool
func (*RateLimitForAPI) Name ¶
func (k *RateLimitForAPI) Name() string
func (*RateLimitForAPI) ProcessRequest ¶
func (k *RateLimitForAPI) ProcessRequest(w http.ResponseWriter, r *http.Request, _ interface{}) (error, int)
ProcessRequest will run any checks on the request on the way through the system, return an error to have the chain fail
type RedisAnalyticsHandler ¶
type RedisAnalyticsHandler struct { Store storage.Handler Clean Purger GeoIPDB *maxminddb.Reader // contains filtered or unexported fields }
RedisAnalyticsHandler will record analytics data to a redis back end as defined in the Config object
func (*RedisAnalyticsHandler) Init ¶
func (r *RedisAnalyticsHandler) Init(globalConf config.Config)
func (*RedisAnalyticsHandler) RecordHit ¶
func (r *RedisAnalyticsHandler) RecordHit(record *AnalyticsRecord) error
RecordHit will store an AnalyticsRecord in Redis
func (*RedisAnalyticsHandler) Stop ¶
func (r *RedisAnalyticsHandler) Stop()
type RedisCacheMiddleware ¶
type RedisCacheMiddleware struct { BaseMiddleware CacheStore storage.Handler // contains filtered or unexported fields }
RedisCacheMiddleware is a caching middleware that will pull data from Redis instead of the upstream proxy
func (*RedisCacheMiddleware) CreateCheckSum ¶
func (*RedisCacheMiddleware) EnabledForSpec ¶
func (m *RedisCacheMiddleware) EnabledForSpec() bool
func (*RedisCacheMiddleware) Init ¶
func (m *RedisCacheMiddleware) Init()
func (*RedisCacheMiddleware) Name ¶
func (m *RedisCacheMiddleware) Name() string
func (*RedisCacheMiddleware) ProcessRequest ¶
func (m *RedisCacheMiddleware) ProcessRequest(w http.ResponseWriter, r *http.Request, _ interface{}) (error, int)
ProcessRequest will run any checks on the request on the way through the system, return an error to have the chain fail
type RedisNotifier ¶
type RedisNotifier struct {
// contains filtered or unexported fields
}
RedisNotifier will use redis pub/sub channels to send notifications
func (*RedisNotifier) Notify ¶
func (r *RedisNotifier) Notify(notif interface{}) bool
Notify will send a notification to a channel
type RedisOsinStorageInterface ¶
type RedisOsinStorageInterface struct {
// contains filtered or unexported fields
}
TODO: Refactor this to move prefix handling into a checker method, then it can be an unexported setting in the struct. RedisOsinStorageInterface implements osin.Storage interface to use Tyk's own storage mechanism
func (*RedisOsinStorageInterface) Clone ¶
func (r *RedisOsinStorageInterface) Clone() osin.Storage
func (*RedisOsinStorageInterface) Close ¶
func (r *RedisOsinStorageInterface) Close()
func (*RedisOsinStorageInterface) DeleteClient ¶
func (r *RedisOsinStorageInterface) DeleteClient(id string, orgID string, ignorePrefix bool) error
DeleteClient Removes a client from the system
func (*RedisOsinStorageInterface) GetClient ¶
func (r *RedisOsinStorageInterface) GetClient(id string) (osin.Client, error)
GetClient will retrieve client data
func (*RedisOsinStorageInterface) GetClientNoPrefix ¶
func (r *RedisOsinStorageInterface) GetClientNoPrefix(id string) (osin.Client, error)
GetClientNoPrefix will retrieve client data, but not assign a prefix - this is an unfortunate hack, but we don't want to change the signature in Osin for GetClient to support the odd Redis prefixing
func (*RedisOsinStorageInterface) GetClientTokens ¶
func (r *RedisOsinStorageInterface) GetClientTokens(id string) ([]OAuthClientToken, error)
func (*RedisOsinStorageInterface) GetClients ¶
func (r *RedisOsinStorageInterface) GetClients(filter string, orgID string, ignorePrefix bool) ([]ExtendedOsinClientInterface, error)
GetClients will retrieve a list of clients for a prefix
func (*RedisOsinStorageInterface) GetExtendedClient ¶
func (r *RedisOsinStorageInterface) GetExtendedClient(id string) (ExtendedOsinClientInterface, error)
func (*RedisOsinStorageInterface) GetExtendedClientNoPrefix ¶
func (r *RedisOsinStorageInterface) GetExtendedClientNoPrefix(id string) (ExtendedOsinClientInterface, error)
GetExtendedClientNoPrefix custom getter to handle prefixing issues in Redis,
func (*RedisOsinStorageInterface) GetPaginatedClientTokens ¶
func (r *RedisOsinStorageInterface) GetPaginatedClientTokens(id string, page int) ([]OAuthClientToken, int, error)
GetPaginatedClientTokens returns all tokens associated with the given id. It returns the tokens, the total number of pages of the tokens after pagination and an error if any
func (*RedisOsinStorageInterface) GetUser ¶
func (r *RedisOsinStorageInterface) GetUser(username string) (*user.SessionState, error)
LoadRefresh will load access data from Redis
func (*RedisOsinStorageInterface) LoadAccess ¶
func (r *RedisOsinStorageInterface) LoadAccess(token string) (*osin.AccessData, error)
LoadAccess will load access data from redis
func (*RedisOsinStorageInterface) LoadAuthorize ¶
func (r *RedisOsinStorageInterface) LoadAuthorize(code string) (*osin.AuthorizeData, error)
LoadAuthorize loads auth data from redis
func (*RedisOsinStorageInterface) LoadRefresh ¶
func (r *RedisOsinStorageInterface) LoadRefresh(token string) (*osin.AccessData, error)
LoadRefresh will load access data from Redis
func (*RedisOsinStorageInterface) RemoveAccess ¶
func (r *RedisOsinStorageInterface) RemoveAccess(token string) error
RemoveAccess will remove access data from Redis
func (*RedisOsinStorageInterface) RemoveAuthorize ¶
func (r *RedisOsinStorageInterface) RemoveAuthorize(code string) error
RemoveAuthorize removes authorisation keys from redis
func (*RedisOsinStorageInterface) RemoveRefresh ¶
func (r *RedisOsinStorageInterface) RemoveRefresh(token string) error
RemoveRefresh will remove a refresh token from redis
func (*RedisOsinStorageInterface) SaveAccess ¶
func (r *RedisOsinStorageInterface) SaveAccess(accessData *osin.AccessData) error
SaveAccess will save a token and it's access data to redis
func (*RedisOsinStorageInterface) SaveAuthorize ¶
func (r *RedisOsinStorageInterface) SaveAuthorize(authData *osin.AuthorizeData) error
SaveAuthorize saves authorisation data to Redis
func (*RedisOsinStorageInterface) SetClient ¶
func (r *RedisOsinStorageInterface) SetClient(id string, orgID string, client osin.Client, ignorePrefix bool) error
SetClient creates client data
func (*RedisOsinStorageInterface) SetUser ¶
func (r *RedisOsinStorageInterface) SetUser(username string, session *user.SessionState, timeout int64) error
type RedisPurger ¶
func (*RedisPurger) PurgeCache ¶
func (r *RedisPurger) PurgeCache()
func (RedisPurger) PurgeLoop ¶
func (r RedisPurger) PurgeLoop(ticker <-chan time.Time)
type RegexExtractor ¶
type RegexExtractor struct { BaseExtractor // contains filtered or unexported fields }
func (*RegexExtractor) ExtractAndCheck ¶
func (e *RegexExtractor) ExtractAndCheck(r *http.Request) (SessionID string, returnOverrides ReturnOverrides)
type RegexExtractorConfig ¶
type RegexExtractorConfig struct { HeaderName string `mapstructure:"header_name" bson:"header_name" json:"header_name"` RegexExpression string `mapstructure:"regex_expression" bson:"regex_expression" json:"regex_expression"` RegexMatchIndex int `mapstructure:"regex_match_index" bson:"regex_match_index" json:"regex_match_index"` FormParamName string `mapstructure:"param_name" bson:"param_name" json:"param_name"` }
type ReloadMachinery ¶
type ReloadMachinery struct {
// contains filtered or unexported fields
}
ReloadMachinery is a helper struct to use when writing tests that do manual gateway reloads
func (*ReloadMachinery) Disable ¶
func (r *ReloadMachinery) Disable()
Disable turns off tracking of reload cycles and queues
func (*ReloadMachinery) Enable ¶
func (r *ReloadMachinery) Enable()
Enable when callled it will allow r to keep track of reload cycles and queues
func (*ReloadMachinery) EnsureQueued ¶
func (r *ReloadMachinery) EnsureQueued(t *testing.T)
EnsureQueued this will block until any queue happens. It will timeout after 100ms
func (*ReloadMachinery) EnsureReloaded ¶
func (r *ReloadMachinery) EnsureReloaded(t *testing.T)
EnsureReloaded this will block until any reload happens. It will timeout after 100ms
func (*ReloadMachinery) OnQueued ¶
func (r *ReloadMachinery) OnQueued()
OnQueued is called when a reload has been queued. This increments the queue count
func (*ReloadMachinery) OnReload ¶
func (r *ReloadMachinery) OnReload()
OnReload is called when a reload has been completed. This increments the reload cycles count.
func (*ReloadMachinery) Queued ¶
func (r *ReloadMachinery) Queued() bool
Queued returns true if any queue happened
func (*ReloadMachinery) Reloaded ¶
func (r *ReloadMachinery) Reloaded() bool
Reloaded returns true if a read has occured since r was enabled
func (*ReloadMachinery) Reset ¶
func (r *ReloadMachinery) Reset()
Reset sets reloads counts and queues to 0
func (*ReloadMachinery) TickOk ¶
func (r *ReloadMachinery) TickOk(t *testing.T)
TickOk triggers a reload and ensures a queue happend and a reload cycle happens. This will block until all the cases are met.
type RequestDefinition ¶
type RequestDefinition struct { Method string `json:"method"` Headers map[string]string `json:"headers"` Body string `json:"body"` RelativeURL string `json:"relative_url"` }
RequestDefinition defines a batch request
type RequestObject ¶
type RequestObject struct { Headers map[string][]string Body string URL string Params map[string][]string Scheme string }
RequestObject is marshalled to JSON string and passed into JSON middleware
type RequestSigning ¶
type RequestSigning struct {
BaseMiddleware
}
func (*RequestSigning) EnabledForSpec ¶
func (s *RequestSigning) EnabledForSpec() bool
func (*RequestSigning) Name ¶
func (s *RequestSigning) Name() string
func (*RequestSigning) ProcessRequest ¶
func (s *RequestSigning) ProcessRequest(w http.ResponseWriter, r *http.Request, _ interface{}) (error, int)
type RequestSizeLimitMiddleware ¶
type RequestSizeLimitMiddleware struct {
BaseMiddleware
}
TransformMiddleware is a middleware that will apply a template to a request body to transform it's contents ready for an upstream API
func (*RequestSizeLimitMiddleware) EnabledForSpec ¶
func (t *RequestSizeLimitMiddleware) EnabledForSpec() bool
func (*RequestSizeLimitMiddleware) Name ¶
func (t *RequestSizeLimitMiddleware) Name() string
func (*RequestSizeLimitMiddleware) ProcessRequest ¶
func (t *RequestSizeLimitMiddleware) ProcessRequest(w http.ResponseWriter, r *http.Request, _ interface{}) (error, int)
RequestSizeLimit will check a request for maximum request size, this can be a global limit or a matched limit.
type RequestStatus ¶
type RequestStatus string
RequestStatus is a custom type to avoid collisions
const ( VersionNotFound RequestStatus = "Version information not found" VersionDoesNotExist RequestStatus = "This API version does not seem to exist" VersionWhiteListStatusNotFound RequestStatus = "WhiteListStatus for path not found" VersionExpired RequestStatus = "Api Version has expired, please check documentation or contact administrator" EndPointNotAllowed RequestStatus = "Requested endpoint is forbidden" StatusOkAndIgnore RequestStatus = "Everything OK, passing and not filtering" StatusOk RequestStatus = "Everything OK, passing" StatusCached RequestStatus = "Cached path" StatusTransform RequestStatus = "Transformed path" StatusTransformResponse RequestStatus = "Transformed response" StatusTransformJQ RequestStatus = "Transformed path with JQ" StatusTransformJQResponse RequestStatus = "Transformed response with JQ" StatusHeaderInjected RequestStatus = "Header injected" StatusMethodTransformed RequestStatus = "Method Transformed" StatusHeaderInjectedResponse RequestStatus = "Header injected on response" StatusRedirectFlowByReply RequestStatus = "Exceptional action requested, redirecting flow!" StatusHardTimeout RequestStatus = "Hard Timeout enforced on path" StatusCircuitBreaker RequestStatus = "Circuit breaker enforced" StatusURLRewrite RequestStatus = "URL Rewritten" StatusVirtualPath RequestStatus = "Virtual Endpoint" StatusRequestSizeControlled RequestStatus = "Request Size Limited" StatusRequestTracked RequestStatus = "Request Tracked" StatusRequestNotTracked RequestStatus = "Request Not Tracked" StatusValidateJSON RequestStatus = "Validate JSON" StatusInternal RequestStatus = "Internal path" )
Statuses of the request, all are false-y except StatusOk and StatusOkAndIgnore
type ResponseTransformJQMiddleware ¶
type ResponseTransformJQMiddleware struct {
Spec *APISpec
}
func (*ResponseTransformJQMiddleware) HandleResponse ¶
func (h *ResponseTransformJQMiddleware) HandleResponse(rw http.ResponseWriter, res *http.Response, req *http.Request, ses *user.SessionState) error
func (*ResponseTransformJQMiddleware) Init ¶
func (h *ResponseTransformJQMiddleware) Init(c interface{}, spec *APISpec) error
func (ResponseTransformJQMiddleware) Name ¶
func (ResponseTransformJQMiddleware) Name() string
type ResponseTransformMiddleware ¶
type ResponseTransformMiddleware struct {
Spec *APISpec
}
func (*ResponseTransformMiddleware) HandleResponse ¶
func (h *ResponseTransformMiddleware) HandleResponse(rw http.ResponseWriter, res *http.Response, req *http.Request, ses *user.SessionState) error
func (*ResponseTransformMiddleware) Init ¶
func (h *ResponseTransformMiddleware) Init(c interface{}, spec *APISpec) error
func (ResponseTransformMiddleware) Name ¶
func (ResponseTransformMiddleware) Name() string
type ReturnConfigPayload ¶
type ReturnOverrides ¶
type ReturnOverrides struct { ResponseCode int ResponseError string ResponseBody string ResponseHeaders map[string]string OverrideError bool }
Lets the user override and return a response from middleware
type ReturningHttpHandler ¶
type ReturningHttpHandler interface { ServeHTTP(http.ResponseWriter, *http.Request) ProxyResponse ServeHTTPForCache(http.ResponseWriter, *http.Request) ProxyResponse CopyResponse(io.Writer, io.Reader) }
type RevProxyTransform ¶
type ReverseProxy ¶
type ReverseProxy struct { // Director must be a function which modifies // the request into a new request to be sent // using Transport. Its response is then copied // back to the original client unmodified. Director func(*http.Request) // The transport used to perform proxy requests. // If nil, http.DefaultTransport is used. Transport http.RoundTripper // FlushInterval specifies the flush interval // to flush to the client while copying the // response body. // If zero, no periodic flushing is done. FlushInterval time.Duration // TLSClientConfig specifies the TLS configuration to use for 'wss'. // If nil, the default configuration is used. TLSClientConfig *tls.Config TykAPISpec *APISpec ErrorHandler ErrorHandler // contains filtered or unexported fields }
ReverseProxy is an HTTP Handler that takes an incoming request and sends it to another server, proxying the response back to the client.
func TykNewSingleHostReverseProxy ¶
func TykNewSingleHostReverseProxy(target *url.URL, spec *APISpec, logger *logrus.Entry) *ReverseProxy
TykNewSingleHostReverseProxy returns a new ReverseProxy that rewrites URLs to the scheme, host, and base path provided in target. If the target's path is "/base" and the incoming request was for "/dir", the target request will be for /base/dir. This version modifies the stdlib version by also setting the host to the target, this allows us to work with heroku and other such providers
func (*ReverseProxy) CheckCircuitBreakerEnforced ¶
func (p *ReverseProxy) CheckCircuitBreakerEnforced(spec *APISpec, req *http.Request) (bool, *ExtendedCircuitBreakerMeta)
func (*ReverseProxy) CheckHardTimeoutEnforced ¶
func (*ReverseProxy) CheckHeaderInRemoveList ¶
func (*ReverseProxy) CopyResponse ¶
func (p *ReverseProxy) CopyResponse(dst io.Writer, src io.Reader)
func (*ReverseProxy) HandleResponse ¶
func (p *ReverseProxy) HandleResponse(rw http.ResponseWriter, res *http.Response, ses *user.SessionState) error
func (*ReverseProxy) ServeHTTP ¶
func (p *ReverseProxy) ServeHTTP(rw http.ResponseWriter, req *http.Request) ProxyResponse
func (*ReverseProxy) ServeHTTPForCache ¶
func (p *ReverseProxy) ServeHTTPForCache(rw http.ResponseWriter, req *http.Request) ProxyResponse
func (*ReverseProxy) WrappedServeHTTP ¶
func (p *ReverseProxy) WrappedServeHTTP(rw http.ResponseWriter, req *http.Request, withCache bool) ProxyResponse
type RoundRobin ¶
type RoundRobin struct {
// contains filtered or unexported fields
}
func (*RoundRobin) WithLen ¶
func (r *RoundRobin) WithLen(len int) int
type ServiceDiscovery ¶
type ServiceDiscovery struct {
// contains filtered or unexported fields
}
func (*ServiceDiscovery) Hostname ¶
func (s *ServiceDiscovery) Hostname(item *gabs.Container) string
func (*ServiceDiscovery) Init ¶
func (s *ServiceDiscovery) Init(spec *apidef.ServiceDiscoveryConfiguration)
func (*ServiceDiscovery) NestedObject ¶
func (s *ServiceDiscovery) NestedObject(item *gabs.Container) string
func (*ServiceDiscovery) ParseObject ¶
func (s *ServiceDiscovery) ParseObject(contents string, jsonParsed *gabs.Container) error
func (*ServiceDiscovery) ProcessRawData ¶
func (s *ServiceDiscovery) ProcessRawData(rawData string) (*apidef.HostList, error)
func (*ServiceDiscovery) SubObject ¶
func (s *ServiceDiscovery) SubObject(obj *gabs.Container) string
func (*ServiceDiscovery) SubObjectFromList ¶
func (s *ServiceDiscovery) SubObjectFromList(objList *gabs.Container) []string
type SessionHandler ¶
type SessionHandler interface { Init(store storage.Handler) Store() storage.Handler UpdateSession(keyName string, session *user.SessionState, resetTTLTo int64, hashed bool) error RemoveSession(keyName string, hashed bool) bool SessionDetail(keyName string, hashed bool) (user.SessionState, bool) KeyExpired(newSession *user.SessionState) bool Sessions(filter string) []string ResetQuota(string, *user.SessionState, bool) Stop() }
SessionHandler handles all update/create/access session functions and deals exclusively with user.SessionState objects, not identity
type SessionLimiter ¶
type SessionLimiter struct {
// contains filtered or unexported fields
}
SessionLimiter is the rate limiter for the API, use ForwardMessage() to check if a message should pass through or not
func (*SessionLimiter) ForwardMessage ¶
func (l *SessionLimiter) ForwardMessage(r *http.Request, currentSession *user.SessionState, key string, store storage.Handler, enableRL, enableQ bool, globalConf *config.Config, apiID string, dryRun bool) sessionFailReason
ForwardMessage will enforce rate limiting, returning a non-zero sessionFailReason if session limits have been exceeded. Key values to manage rate are Rate and Per, e.g. Rate of 10 messages Per 10 seconds
func (*SessionLimiter) RedisQuotaExceeded ¶
type StatsDSink ¶
type StatsDSink struct {
// contains filtered or unexported fields
}
func NewStatsDSink ¶
func NewStatsDSink(addr string, options *StatsDSinkOptions) (*StatsDSink, error)
func (*StatsDSink) Drain ¶
func (s *StatsDSink) Drain()
func (*StatsDSink) EmitComplete ¶
func (s *StatsDSink) EmitComplete(job string, status health.CompletionStatus, nanos int64, kvs map[string]string)
func (*StatsDSink) EmitEvent ¶
func (s *StatsDSink) EmitEvent(job, event string, kvs map[string]string)
func (*StatsDSink) EmitEventErr ¶
func (s *StatsDSink) EmitEventErr(job, event string, inputErr error, kvs map[string]string)
func (*StatsDSink) EmitGauge ¶
func (s *StatsDSink) EmitGauge(job, event string, value float64, kvs map[string]string)
func (*StatsDSink) EmitTiming ¶
func (s *StatsDSink) EmitTiming(job, event string, nanos int64, kvs map[string]string)
func (*StatsDSink) Stop ¶
func (s *StatsDSink) Stop()
type StatsDSinkOptions ¶
type StatsDSinkOptions struct { // Prefix is something like "metroid" // Events emitted to StatsD would be metroid.myevent.wat // Eg, don't include a trailing dot in the prefix. // It can be "", that's fine. Prefix string // SanitizationFunc sanitizes jobs and events before sending them to statsd SanitizationFunc StatsDSinkSanitizationFunc // SkipNestedEvents will skip {events,timers,gauges} from sending the job.event version // and will only send the event version. SkipNestedEvents bool // SkipTopLevelEvents will skip {events,timers,gauges} from sending the event version // and will only send the job.event version. SkipTopLevelEvents bool }
type StripAuth ¶
type StripAuth struct {
BaseMiddleware
}
func (*StripAuth) EnabledForSpec ¶
func (*StripAuth) ProcessRequest ¶
type SuccessHandler ¶
type SuccessHandler struct {
BaseMiddleware
}
SuccessHandler represents the final ServeHTTP() request for a proxied API request
func (*SuccessHandler) ServeHTTP ¶
func (s *SuccessHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) *http.Response
ServeHTTP will store the request details in the analytics store if necessary and proxy the request to it's final destination, this is invoked by the ProxyHandler or right at the start of a request chain if the URL Spec states the path is Ignored
func (*SuccessHandler) ServeHTTPWithCache ¶
func (s *SuccessHandler) ServeHTTPWithCache(w http.ResponseWriter, r *http.Request) ProxyResponse
ServeHTTPWithCache will store the request details in the analytics store if necessary and proxy the request to it's final destination, this is invoked by the ProxyHandler or right at the start of a request chain if the URL Spec states the path is Ignored Itwill also return a response object for the cache
type TemplateExecutor ¶
TemplateExecutor is an interface used to switch between text/templates and html/template. It only switch to text/template (templatesRaw) when contentType is XML related
type Test ¶
type Test struct { URL string GlobalConfig config.Config // contains filtered or unexported fields }
func StartTest ¶
func StartTest(config ...TestConfig) *Test
func (*Test) CreateSession ¶
func (s *Test) CreateSession(sGen ...func(s *user.SessionState)) (*user.SessionState, string)
type TestConfig ¶
type TestConfig struct { Delay time.Duration HotReload bool CoprocessConfig config.CoProcessConfig // contains filtered or unexported fields }
type TestHttpResponse ¶
type TraceMiddleware ¶
type TraceMiddleware struct {
TykMiddleware
}
func (TraceMiddleware) ProcessRequest ¶
func (tr TraceMiddleware) ProcessRequest(w http.ResponseWriter, r *http.Request, conf interface{}) (error, int)
type TrackEndpointMiddleware ¶
type TrackEndpointMiddleware struct {
BaseMiddleware
}
TrackEndpointMiddleware sets context variables to enable or disable whether Tyk should record analytitcs for a specific path.
func (*TrackEndpointMiddleware) EnabledForSpec ¶
func (t *TrackEndpointMiddleware) EnabledForSpec() bool
func (*TrackEndpointMiddleware) Name ¶
func (t *TrackEndpointMiddleware) Name() string
func (*TrackEndpointMiddleware) ProcessRequest ¶
func (t *TrackEndpointMiddleware) ProcessRequest(w http.ResponseWriter, r *http.Request, _ interface{}) (error, int)
ProcessRequest will run any checks on the request on the way through the system, return an error to have the chain fail
type TransformHeaders ¶
type TransformHeaders struct {
BaseMiddleware
}
TransformMiddleware is a middleware that will apply a template to a request body to transform it's contents ready for an upstream API
func (*TransformHeaders) EnabledForSpec ¶
func (t *TransformHeaders) EnabledForSpec() bool
func (*TransformHeaders) Name ¶
func (t *TransformHeaders) Name() string
func (*TransformHeaders) ProcessRequest ¶
func (t *TransformHeaders) ProcessRequest(w http.ResponseWriter, r *http.Request, _ interface{}) (error, int)
ProcessRequest will run any checks on the request on the way through the system, return an error to have the chain fail
type TransformJQMiddleware ¶
type TransformJQMiddleware struct {
BaseMiddleware
}
func (*TransformJQMiddleware) EnabledForSpec ¶
func (t *TransformJQMiddleware) EnabledForSpec() bool
func (*TransformJQMiddleware) Name ¶
func (t *TransformJQMiddleware) Name() string
func (*TransformJQMiddleware) ProcessRequest ¶
func (t *TransformJQMiddleware) ProcessRequest(w http.ResponseWriter, r *http.Request, _ interface{}) (error, int)
ProcessRequest will run any checks on the request on the way through the system, return an error to have the chain fail
type TransformJQSpec ¶
type TransformJQSpec struct {
apidef.TransformJQMeta
}
type TransformMethod ¶
type TransformMethod struct {
BaseMiddleware
}
TransformMiddleware is a middleware that will apply a template to a request body to transform it's contents ready for an upstream API
func (*TransformMethod) EnabledForSpec ¶
func (t *TransformMethod) EnabledForSpec() bool
func (*TransformMethod) Name ¶
func (t *TransformMethod) Name() string
func (*TransformMethod) ProcessRequest ¶
func (t *TransformMethod) ProcessRequest(w http.ResponseWriter, r *http.Request, _ interface{}) (error, int)
ProcessRequest will run any checks on the request on the way through the system, return an error to have the chain fail
type TransformMiddleware ¶
type TransformMiddleware struct {
BaseMiddleware
}
TransformMiddleware is a middleware that will apply a template to a request body to transform it's contents ready for an upstream API
func (*TransformMiddleware) EnabledForSpec ¶
func (t *TransformMiddleware) EnabledForSpec() bool
func (*TransformMiddleware) Name ¶
func (t *TransformMiddleware) Name() string
func (*TransformMiddleware) ProcessRequest ¶
func (t *TransformMiddleware) ProcessRequest(w http.ResponseWriter, r *http.Request, _ interface{}) (error, int)
ProcessRequest will run any checks on the request on the way through the system, return an error to have the chain fail
type TransformSpec ¶
type TransformSpec struct { apidef.TemplateMeta Template *template.Template }
type TykJSHttpRequest ¶
type TykJSHttpResponse ¶
type TykMiddleware ¶
type TykMiddleware interface { Init() Base() *BaseMiddleware SetName(string) SetRequestLogger(*http.Request) Logger() *logrus.Entry Config() (interface{}, error) ProcessRequest(w http.ResponseWriter, r *http.Request, conf interface{}) (error, int) // Handles request EnabledForSpec() bool Name() string }
type TykOsinServer ¶
type TykOsinServer struct { osin.Server Config *osin.ServerConfig Storage ExtendedOsinStorageInterface AuthorizeTokenGen osin.AuthorizeTokenGen AccessTokenGen osin.AccessTokenGen }
TykOsinServer subclasses osin.Server so we can add the SetClient method without wrecking the lbrary
func TykOsinNewServer ¶
func TykOsinNewServer(config *osin.ServerConfig, storage ExtendedOsinStorageInterface) *TykOsinServer
TykOsinNewServer creates a new server instance, but uses an extended interface so we can SetClient() too.
type TykResponseHandler ¶
type URLRewriteMiddleware ¶
type URLRewriteMiddleware struct {
BaseMiddleware
}
URLRewriteMiddleware Will rewrite an inbund URL to a matching outbound one, it can also handle dynamic variable substitution
func (*URLRewriteMiddleware) CheckHostRewrite ¶
func (m *URLRewriteMiddleware) CheckHostRewrite(oldPath, newTarget string, r *http.Request)
func (*URLRewriteMiddleware) EnabledForSpec ¶
func (m *URLRewriteMiddleware) EnabledForSpec() bool
func (*URLRewriteMiddleware) InitTriggerRx ¶
func (m *URLRewriteMiddleware) InitTriggerRx()
func (*URLRewriteMiddleware) Name ¶
func (m *URLRewriteMiddleware) Name() string
func (*URLRewriteMiddleware) ProcessRequest ¶
func (m *URLRewriteMiddleware) ProcessRequest(w http.ResponseWriter, r *http.Request, _ interface{}) (error, int)
ProcessRequest will run any checks on the request on the way through the system, return an error to have the chain fail
type URLSpec ¶
type URLSpec struct { Spec *regexp.Regexp Status URLStatus MethodActions map[string]apidef.EndpointMethodMeta CacheConfig EndPointCacheMeta TransformAction TransformSpec TransformResponseAction TransformSpec TransformJQAction TransformJQSpec TransformJQResponseAction TransformJQSpec InjectHeaders apidef.HeaderInjectionMeta InjectHeadersResponse apidef.HeaderInjectionMeta HardTimeout apidef.HardTimeoutMeta CircuitBreaker ExtendedCircuitBreakerMeta URLRewrite *apidef.URLRewriteMeta VirtualPathSpec apidef.VirtualMeta RequestSize apidef.RequestSizeMeta MethodTransform apidef.MethodTransformMeta TrackEndpoint apidef.TrackEndpointMeta DoNotTrackEndpoint apidef.TrackEndpointMeta ValidatePathMeta apidef.ValidatePathMeta Internal apidef.InternalMeta IgnoreCase bool }
URLSpec represents a flattened specification for URLs, used to check if a proxy URL path is on any of the white, black or ignored lists. This is generated as part of the configuration init
type URLStatus ¶
type URLStatus int
URLStatus is a custom enum type to avoid collisions
const ( Ignored URLStatus WhiteList BlackList Cached Transformed TransformedJQ HeaderInjected HeaderInjectedResponse TransformedResponse TransformedJQResponse HardTimeout CircuitBreaker URLRewrite VirtualPath RequestSizeLimit MethodTransformed RequestTracked RequestNotTracked ValidateJSONRequest Internal )
Enums representing the various statuses for a VersionInfo Path match during a proxy request
type UptimeReportData ¶
type UptimeReportData struct { URL string RequestTime int64 ResponseCode int TCPError bool ServerError bool Day int Month time.Month Year int Hour int Minute int TimeStamp time.Time ExpireAt time.Time `bson:"expireAt" json:"expireAt"` APIID string OrgID string }
func (*UptimeReportData) SetExpiry ¶
func (u *UptimeReportData) SetExpiry(expiresInSeconds int64)
type VMResponseObject ¶
type VMResponseObject struct { Response ResponseObject SessionMeta map[string]string }
type VMReturnObject ¶
type VMReturnObject struct { Request MiniRequestObject SessionMeta map[string]string Session user.SessionState AuthValue string }
type ValidateJSON ¶
type ValidateJSON struct {
BaseMiddleware
}
func (*ValidateJSON) EnabledForSpec ¶
func (k *ValidateJSON) EnabledForSpec() bool
func (*ValidateJSON) Name ¶
func (k *ValidateJSON) Name() string
func (*ValidateJSON) ProcessRequest ¶
func (k *ValidateJSON) ProcessRequest(w http.ResponseWriter, r *http.Request, _ interface{}) (error, int)
ProcessRequest will run any checks on the request on the way through the system, return an error to have the chain fail
type ValueExtractor ¶
type ValueExtractor struct { BaseExtractor // contains filtered or unexported fields }
func (*ValueExtractor) Extract ¶
func (e *ValueExtractor) Extract(input interface{}) string
func (*ValueExtractor) ExtractAndCheck ¶
func (e *ValueExtractor) ExtractAndCheck(r *http.Request) (sessionID string, returnOverrides ReturnOverrides)
type ValueExtractorConfig ¶
type VersionCheck ¶
type VersionCheck struct { BaseMiddleware // contains filtered or unexported fields }
VersionCheck will check whether the version of the requested API the request is accessing has any restrictions on URL endpoints
func (*VersionCheck) DoMockReply ¶
func (v *VersionCheck) DoMockReply(w http.ResponseWriter, meta interface{})
func (*VersionCheck) Init ¶
func (v *VersionCheck) Init()
func (*VersionCheck) Name ¶
func (v *VersionCheck) Name() string
func (*VersionCheck) ProcessRequest ¶
func (v *VersionCheck) ProcessRequest(w http.ResponseWriter, r *http.Request, _ interface{}) (error, int)
ProcessRequest will run any checks on the request on the way through the system, return an error to have the chain fail
type VirtualEndpoint ¶
type VirtualEndpoint struct { BaseMiddleware // contains filtered or unexported fields }
DynamicMiddleware is a generic middleware that will execute JS code before continuing
func (*VirtualEndpoint) EnabledForSpec ¶
func (d *VirtualEndpoint) EnabledForSpec() bool
func (*VirtualEndpoint) HandleResponse ¶
func (d *VirtualEndpoint) HandleResponse(rw http.ResponseWriter, res *http.Response, ses *user.SessionState)
func (*VirtualEndpoint) Init ¶
func (d *VirtualEndpoint) Init()
func (*VirtualEndpoint) Name ¶
func (d *VirtualEndpoint) Name() string
func (*VirtualEndpoint) ProcessRequest ¶
func (d *VirtualEndpoint) ProcessRequest(w http.ResponseWriter, r *http.Request, _ interface{}) (error, int)
ProcessRequest will run any checks on the request on the way through the system, return an error to have the chain fail
func (*VirtualEndpoint) ServeHTTPForCache ¶
func (d *VirtualEndpoint) ServeHTTPForCache(w http.ResponseWriter, r *http.Request, vmeta *apidef.VirtualMeta) *http.Response
type WebHookHandler ¶
type WebHookHandler struct {
// contains filtered or unexported fields
}
WebHookHandler is an event handler that triggers web hooks
func (*WebHookHandler) BuildRequest ¶
func (w *WebHookHandler) BuildRequest(reqBody string) (*http.Request, error)
func (*WebHookHandler) CreateBody ¶
func (w *WebHookHandler) CreateBody(em config.EventMessage) (string, error)
func (*WebHookHandler) HandleEvent ¶
func (w *WebHookHandler) HandleEvent(em config.EventMessage)
HandleEvent will be fired when the event handler instance is found in an APISpec EventPaths object during a request chain
func (*WebHookHandler) Init ¶
func (w *WebHookHandler) Init(handlerConf interface{}) error
Init enables the init of event handler instances when they are created on ApiSpec creation
func (*WebHookHandler) WasHookFired ¶
func (w *WebHookHandler) WasHookFired(checksum string) bool
hookFired checks if an event has been fired within the EventTimeout setting
type WebHookRequestMethod ¶
type WebHookRequestMethod string
const ( WH_GET WebHookRequestMethod = "GET" WH_PUT WebHookRequestMethod = "PUT" WH_POST WebHookRequestMethod = "POST" WH_DELETE WebHookRequestMethod = "DELETE" WH_PATCH WebHookRequestMethod = "PATCH" // Define the Event Handler name so we can register it EH_WebHook apidef.TykEventHandlerName = "eh_web_hook_handler" )
type XPathExtractor ¶
type XPathExtractor struct { BaseExtractor // contains filtered or unexported fields }
func (*XPathExtractor) ExtractAndCheck ¶
func (e *XPathExtractor) ExtractAndCheck(r *http.Request) (SessionID string, returnOverrides ReturnOverrides)
type XPathExtractorConfig ¶
type XPathExtractorConfig struct { HeaderName string `mapstructure:"header_name" bson:"header_name" json:"header_name"` RegexExpression string `mapstructure:"regex_expression" bson:"regex_expression" json:"regex_expression"` RegexMatchIndex int `mapstructure:"regex_match_index" bson:"regex_match_index" json:"regex_match_index"` FormParamName string `mapstructure:"param_name" bson:"param_name" json:"param_name"` }
Source Files ¶
- analytics.go
- api.go
- api_definition.go
- api_healthcheck.go
- api_loader.go
- auth_manager.go
- batch_requests.go
- cert.go
- coprocess.go
- coprocess_api.go
- coprocess_bundle.go
- coprocess_events.go
- coprocess_grpc.go
- coprocess_helpers.go
- coprocess_id_extractor.go
- coprocess_python.go
- dashboard_register.go
- distributed_rate_limiter.go
- event_handler_webhooks.go
- event_system.go
- handler_error.go
- handler_success.go
- host_checker.go
- host_checker_manager.go
- instrumentation_handlers.go
- instrumentation_statsd_sink.go
- jsvm_event_handler.go
- ldap_auth_handler.go
- le_helpers.go
- log_helpers.go
- middleware.go
- monitor.go
- multi_target_proxy_handler.go
- mw_access_rights.go
- mw_api_rate_limit.go
- mw_auth_key.go
- mw_basic_auth.go
- mw_certificate_check.go
- mw_context_vars.go
- mw_go_plugin.go
- mw_granular_access.go
- mw_http_signature_validation.go
- mw_ip_blacklist.go
- mw_ip_whitelist.go
- mw_js_plugin.go
- mw_jwt.go
- mw_key_expired_check.go
- mw_method_transform.go
- mw_modify_headers.go
- mw_oauth2_key_exists.go
- mw_openid.go
- mw_organisation_activity.go
- mw_rate_check.go
- mw_rate_limiting.go
- mw_redis_cache.go
- mw_request_signing.go
- mw_request_size_limit.go
- mw_strip_auth.go
- mw_track_endpoints.go
- mw_transform.go
- mw_transform_jq_dummy.go
- mw_url_rewrite.go
- mw_validate_json.go
- mw_version_check.go
- mw_virtual_endpoint.go
- newrelic.go
- oauth_manager.go
- policy.go
- proxy_muxer.go
- redis_analytics_purger.go
- redis_logrus_hook.go
- redis_signal_handle_config.go
- redis_signals.go
- res_handler_header_injector.go
- res_handler_header_transform.go
- res_handler_jq_transform_dummy.go
- res_handler_transform.go
- reverse_proxy.go
- rpc_backup_handlers.go
- rpc_storage_handler.go
- server.go
- service_discovery.go
- session_manager.go
- swagger.go
- testutil.go
- tracing.go
- util.go
- version.go