Documentation ¶
Index ¶
- Constants
- func ReloadLogger()
- func SetHttpClient(c *http.Client)
- type AccessDefinition
- type AccessSpec
- type Endpoint
- type EndpointConfig
- type HashType
- type OAuthMethod
- type OAuthResponse
- type PortalDeveloper
- type PortalDeveloperOAuthClient
- type Registration
- type SessionState
- type TokenResponse
- type TykAPI
- func (t *TykAPI) CreateAdminSSONonce(data interface{}) (interface{}, Endpoint, error)
- func (t *TykAPI) CreateDeveloper(UserCred string, dev PortalDeveloper) error
- func (t *TykAPI) CreateSSONonce(userAPICred string, data interface{}) (interface{}, Endpoint, error)
- func (t *TykAPI) Decode(raw []byte, retVal interface{}) error
- func (t *TykAPI) DispatchAndDecode(target Endpoint, method string, APIName TykAPIName, retVal interface{}, ...) (error, int, bool)
- func (t *TykAPI) DispatchDashboard(target Endpoint, method string, usercode string, body io.Reader) ([]byte, int, error)
- func (t *TykAPI) DispatchDashboardSuper(target Endpoint, method string, body io.Reader) ([]byte, int, error)
- func (t *TykAPI) DispatchGateway(target Endpoint, method string, body io.Reader, ctype string) ([]byte, int, error)
- func (t *TykAPI) GetDeveloper(UserCred string, DeveloperEmail string) (PortalDeveloper, error)
- func (t *TykAPI) GetDeveloperBySSOKey(UserCred string, SsoKey string) (PortalDeveloper, error, bool)
- func (t *TykAPI) InvalidateToken(UserCred string, BaseAPI string, token string) (error, bool)
- func (t *TykAPI) RequestOAuthToken(...) (*OAuthResponse, error)
- func (t *TykAPI) RequestStandardToken(orgID, policyID, BaseAPIID, UserCred string, expires int64, ...) (*TokenResponse, error)
- func (t *TykAPI) UpdateDeveloper(UserCred string, dev PortalDeveloper) error
- type TykAPIName
Constants ¶
const ( // Main endpoints used in this wrapper PORTAL_DEVS Endpoint = "/api/portal/developers/email" PORTAL_DEVS_SSO Endpoint = "/api/portal/developers/ssokey" PORTAL_DEV Endpoint = "/api/portal/developers" SSO_ADMIN Endpoint = "/admin/sso" SSO_REGULAR Endpoint = "/api/sso" OAUTH_AUTHORIZE Endpoint = "tyk/oauth/authorize-client/" TOKENS Endpoint = "/api/apis/{APIID}/keys" STANDARD_TOKENS Endpoint = "/api/keys" // Main APis used in this wrapper GATEWAY TykAPIName = "gateway" DASH TykAPIName = "dash" DASH_SUPER TykAPIName = "dash_super" HASH_PlainText HashType = "" HASH_BCrypt HashType = "bcrypt" )
Variables ¶
This section is empty.
Functions ¶
func ReloadLogger ¶ added in v1.1.0
func ReloadLogger()
ReloadLogger in case that user set an external logger
func SetHttpClient ¶ added in v1.1.0
Types ¶
type AccessDefinition ¶
type AccessDefinition struct { APIName string `json:"api_name"` APIID string `json:"api_id"` Versions []string `json:"versions"` AllowedURLs []AccessSpec `bson:"allowed_urls" json:"allowed_urls"` // mapped string MUST be a valid regex }
AccessDefinition defines which versions of an API a key has access to
type AccessSpec ¶
AccessSpecs define what URLS a user has access to an what methods are enabled
type EndpointConfig ¶
EndpointConfig is a Configuration for an API Endpoint of one of the Tyk APIs
type OAuthResponse ¶
type PortalDeveloper ¶
type PortalDeveloper struct { Id model.ObjectID `bson:"_id,omitempty" json:"id"` Email string `bson:"email" json:"email"` Password string `bson:"password" json:"-"` DateCreated time.Time `bson:"date_created" json:"date_created"` InActive bool `bson:"inactive" json:"inactive"` OrgId string `bson:"org_id" json:"org_id"` Keys map[string][]string `bson:"keys" json:"keys"` Subscriptions map[string]string `bson:"subscriptions" json:"subscriptions"` Fields map[string]string `bson:"fields" json:"fields"` Nonce string `bson:"nonce" json:"nonce"` SSOKey string `bson:"sso_key" json:"sso_key"` OauthClients map[string][]PortalDeveloperOAuthClient `bson:"oauth_clients,omitempty" json:"oauth_clients,omitempty"` PasswordMaxDays int `bson:"password_max_days" json:"password_max_days"` PasswordUpdated time.Time `bson:"password_updated" json:"password_updated"` PWHistory []string `bson:"PWHistory" json:"PWHistory"` LastLoginDate time.Time `bson:"last_login_date" json:"last_login_date"` }
PortalDeveloper represents a portal developer
type PortalDeveloperOAuthClient ¶ added in v1.2.4
type PortalDeveloperOAuthClient struct { ClientID string `bson:"client_id" json:"client_id"` ClientName string `bson:"client_name" json:"client_name"` ClientSecret string `bson:"secret" json:"secret"` ClientRedirectURI string `bson:"redirect_uri" json:"redirect_uri"` AppDescription string `bson:"app_description" json:"app_description"` UseCase string `bson:"use_case" json:"use_case"` DateCreated time.Time `bson:"date_created" json:"date_created"` DCRRegistration Registration `bson:"dcr_registration" json:"dcr_registration"` }
type Registration ¶ added in v1.2.4
type SessionState ¶
type SessionState struct { LastCheck int64 `json:"last_check"` Allowance float64 `json:"allowance"` Rate float64 `json:"rate"` Per float64 `json:"per"` Expires int64 `json:"expires"` QuotaMax int64 `json:"quota_max"` QuotaRenews int64 `json:"quota_renews"` QuotaRemaining int64 `json:"quota_remaining"` QuotaRenewalRate int64 `json:"quota_renewal_rate"` AccessRights map[string]AccessDefinition `json:"access_rights"` OrgID string `json:"org_id"` OauthClientID string `json:"oauth_client_id"` OauthKeys map[string]string `json:"oauth_keys"` BasicAuthData struct { Password string `json:"password"` Hash HashType `json:"hash_type"` } `json:"basic_auth_data"` JWTData struct { Secret string `json:"secret"` } `json:"jwt_data"` HMACEnabled bool `json:"hmac_enabled"` HmacSecret string `json:"hmac_string"` IsInactive bool `json:"is_inactive"` ApplyPolicyID string `json:"apply_policy_id"` DataExpires int64 `json:"data_expires"` Monitor struct { TriggerLimits []float64 `json:"trigger_limits"` } `json:"monitor"` MetaData interface{} `json:"meta_data"` Tags []string `json:"tags"` }
SessionState objects represent a current API session, mainly used for rate limiting.
type TokenResponse ¶
type TokenResponse struct {
KeyID string `json:"key_id"`
}
type TykAPI ¶
type TykAPI struct { GatewayConfig EndpointConfig DashboardConfig EndpointConfig CustomDispatcher func(target Endpoint, method string, usercode string, body io.Reader) ([]byte, int, error) `json:"-"` CustomSuperDispatcher func(target Endpoint, method string, body io.Reader) ([]byte, int, error) `json:"-"` }
TykAPI is the main object (and configuration) of the Tyk API wrapper
func (*TykAPI) CreateAdminSSONonce ¶
Legacy admin API
func (*TykAPI) CreateDeveloper ¶
func (t *TykAPI) CreateDeveloper(UserCred string, dev PortalDeveloper) error
CreateDeveloper will create a developer using the advanced API
func (*TykAPI) CreateSSONonce ¶
func (t *TykAPI) CreateSSONonce(userAPICred string, data interface{}) (interface{}, Endpoint, error)
CreateSSONonce will generate a single-signon nonce for the relevant part of the Tyk service (dashbaord or portal), nonces are single-use and expire after 60 seconds to prevent hijacking, they are only available during successful requests by redirecting the user. It is recommended that SSL is used throughout
func (*TykAPI) DispatchAndDecode ¶
func (t *TykAPI) DispatchAndDecode(target Endpoint, method string, APIName TykAPIName, retVal interface{}, creds string, body io.Reader, ctype string) (error, int, bool)
DispatchAndDecode will select the API to target, dispatch the request, then decode ther esponse to return to the caller
func (*TykAPI) DispatchDashboard ¶
func (t *TykAPI) DispatchDashboard(target Endpoint, method string, usercode string, body io.Reader) ([]byte, int, error)
DispatchDashboard dispatches a request to the dashboard API and handles the response
func (*TykAPI) DispatchDashboardSuper ¶
func (t *TykAPI) DispatchDashboardSuper(target Endpoint, method string, body io.Reader) ([]byte, int, error)
DispatchDashboardSuper will dispatch a request to the dashbaord super-user API (admin)
func (*TykAPI) DispatchGateway ¶
func (t *TykAPI) DispatchGateway(target Endpoint, method string, body io.Reader, ctype string) ([]byte, int, error)
DispatchGateway will dispatch a request to the gateway API
func (*TykAPI) GetDeveloper ¶
func (t *TykAPI) GetDeveloper(UserCred string, DeveloperEmail string) (PortalDeveloper, error)
GetDeveloper will retrieve a developer from the Advanced API using their Email address
func (*TykAPI) GetDeveloperBySSOKey ¶
func (t *TykAPI) GetDeveloperBySSOKey(UserCred string, SsoKey string) (PortalDeveloper, error, bool)
GetDeveloperBySSOKey will retrieve a deverloper from the Advanced API using their SSO Key address
func (*TykAPI) InvalidateToken ¶
func (*TykAPI) RequestOAuthToken ¶
func (t *TykAPI) RequestOAuthToken(APIlistenPath, redirect_uri, responseType, clientId, secret, orgID, policyID, BaseAPIID string, userInfo interface{}) (*OAuthResponse, error)
func (*TykAPI) RequestStandardToken ¶
func (t *TykAPI) RequestStandardToken(orgID, policyID, BaseAPIID, UserCred string, expires int64, userInfo interface{}) (*TokenResponse, error)
func (*TykAPI) UpdateDeveloper ¶
func (t *TykAPI) UpdateDeveloper(UserCred string, dev PortalDeveloper) error
UpdateDeveloper will update a developer object using the advanced API
type TykAPIName ¶
type TykAPIName string // A type for Tyk API names (e.g. dashboard, gateway)