kong

package
v1.0.7 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2024 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BasicAuthPlugin = "basic-auth"
	KeyAuthPlugin   = "key-auth"
	OAuthPlugin     = "oauth2"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ACLConfig

type ACLConfig struct {
	AllowedGroups    []string `json:"allow,omitempty" yaml:"allow,omitempty"`
	DeniedGroups     []string `json:"deny,omitempty" yaml:"deny,omitempty"`
	HideGroupsHeader bool     `json:"hide_groups_header" yaml:"hide_groups_header"`
}

type BasicAuthPluginConfig added in v1.0.2

type BasicAuthPluginConfig struct {
	Anonymous       string `json:"anonymous,omitempty"`
	HideCredentials bool   `json:"hide_credentials,omitempty"`
}

func NewBasicAuthPluginConfigFromMap added in v1.0.2

func NewBasicAuthPluginConfigFromMap(mapData map[string]interface{}) (*BasicAuthPluginConfig, error)

type DoRequest

type DoRequest interface {
	Do(req *http.Request) (*http.Response, error)
}

type DocumentObject

type DocumentObject struct {
	CreatedAt int    `json:"created_at,omitempty"`
	ID        string `json:"id,omitempty"`
	Path      string `json:"path,omitempty"`
	Service   struct {
		ID string `json:"id,omitempty"`
	} `json:"service,omitempty"`
}

type DocumentObjects

type DocumentObjects struct {
	Data []DocumentObject `json:"data,omitempty"`
	Next string           `json:"next,omitempty"`
}

type KeyAuthPluginConfig added in v1.0.2

type KeyAuthPluginConfig struct {
	KeyInQuery      bool     `json:"key_in_query,omitempty"`
	KeyInHeader     bool     `json:"key_in_header,omitempty"`
	KeyNames        []string `json:"key_names,omitempty"`
	Anonymous       string   `json:"anonymous,omitempty"`
	RunOnPreflight  bool     `json:"run_on_preflight,omitempty"`
	HideCredentials bool     `json:"hide_credentials,omitempty"`
	KeyInBody       bool     `json:"key_in_body,omitempty"`
}

func NewKeyAuthPluginConfigFromMap added in v1.0.2

func NewKeyAuthPluginConfigFromMap(mapData map[string]interface{}) (*KeyAuthPluginConfig, error)

type KongAPIClient

type KongAPIClient interface {
	// Provisioning
	CreateConsumer(ctx context.Context, id, name string) (*klib.Consumer, error)
	AddConsumerACL(ctx context.Context, id string) error
	DeleteConsumer(ctx context.Context, id string) error
	// Credential
	DeleteOauth2(ctx context.Context, consumerID, clientID string) error
	DeleteHttpBasic(ctx context.Context, consumerID, username string) error
	DeleteAuthKey(ctx context.Context, consumerID, authKey string) error
	CreateHttpBasic(ctx context.Context, consumerID string, basicAuth *klib.BasicAuth) (*klib.BasicAuth, error)
	CreateOauth2(ctx context.Context, consumerID string, oauth2 *klib.Oauth2Credential) (*klib.Oauth2Credential, error)
	CreateAuthKey(ctx context.Context, consumerID string, keyAuth *klib.KeyAuth) (*klib.KeyAuth, error)
	// Access Request
	AddRouteACL(ctx context.Context, routeID, allowedID string) error
	RemoveRouteACL(ctx context.Context, routeID, revokedID string) error
	AddQuota(ctx context.Context, routeID, allowedID, quotaInterval string, quotaLimit int) error

	ListServices(ctx context.Context) ([]*klib.Service, error)
	ListRoutesForService(ctx context.Context, serviceId string) ([]*klib.Route, error)
	GetSpecForService(ctx context.Context, service *klib.Service) ([]byte, error)
	GetKongPlugins() *Plugins
}

type KongClient

type KongClient struct {
	*klib.Client
	// contains filtered or unexported fields
}

func NewKongClient

func NewKongClient(kongConfig *config.KongGatewayConfig) (*KongClient, error)

func (KongClient) AddConsumerACL

func (k KongClient) AddConsumerACL(ctx context.Context, id string) error

func (KongClient) AddQuota

func (k KongClient) AddQuota(ctx context.Context, routeID, managedAppID, quotaInterval string, quotaLimit int) error

func (KongClient) AddRouteACL

func (k KongClient) AddRouteACL(ctx context.Context, routeID, allowedID string) error

func (KongClient) CreateAuthKey

func (k KongClient) CreateAuthKey(ctx context.Context, consumerID string, keyAuth *klib.KeyAuth) (*klib.KeyAuth, error)

func (KongClient) CreateConsumer

func (k KongClient) CreateConsumer(ctx context.Context, id, name string) (*klib.Consumer, error)

func (KongClient) CreateHttpBasic

func (k KongClient) CreateHttpBasic(ctx context.Context, consumerID string, basicAuth *klib.BasicAuth) (*klib.BasicAuth, error)

func (KongClient) CreateOauth2

func (k KongClient) CreateOauth2(ctx context.Context, consumerID string, oauth2 *klib.Oauth2Credential) (*klib.Oauth2Credential, error)

func (KongClient) DeleteAuthKey

func (k KongClient) DeleteAuthKey(ctx context.Context, consumerID, authKey string) error

func (KongClient) DeleteConsumer

func (k KongClient) DeleteConsumer(ctx context.Context, id string) error

func (KongClient) DeleteHttpBasic

func (k KongClient) DeleteHttpBasic(ctx context.Context, consumerID, username string) error

func (KongClient) DeleteOauth2

func (k KongClient) DeleteOauth2(ctx context.Context, consumerID, clientID string) error

func (KongClient) GetKongPlugins

func (k KongClient) GetKongPlugins() *Plugins

func (KongClient) GetSpecForService

func (k KongClient) GetSpecForService(ctx context.Context, service *klib.Service) ([]byte, error)

func (KongClient) ListRoutesForService

func (k KongClient) ListRoutesForService(ctx context.Context, serviceId string) ([]*klib.Route, error)

func (KongClient) ListServices

func (k KongClient) ListServices(ctx context.Context) ([]*klib.Service, error)

func (KongClient) RemoveRouteACL

func (k KongClient) RemoveRouteACL(ctx context.Context, routeID, revokedID string) error

type KongServiceSpec

type KongServiceSpec struct {
	Contents  string `json:"contents"`
	CreatedAt int    `json:"created_at"`
	ID        string `json:"id"`
	Path      string `json:"path"`
	Checksum  string `json:"checksum"`
}

type OAuthPluginConfig added in v1.0.2

type OAuthPluginConfig struct {
	HideCredentials               bool     `json:"hide_credentials,omitempty"`
	PersistentRefreshToken        bool     `json:"persistent_refresh_token,omitempty"`
	ProvisionKey                  string   `json:"provision_key,omitempty"`
	RefreshTokenTTL               int64    `json:"refresh_token_ttl,omitempty"`
	TokenExpiration               int64    `json:"token_expiration,omitempty"`
	AcceptHTTPIfAlreadyTerminated bool     `json:"accept_http_if_already_terminated,omitempty"`
	AuthHeaderName                string   `json:"auth_header_name,omitempty"`
	MandatoryScope                bool     `json:"mandatory_scope,omitempty"`
	Scopes                        []string `json:"scopes,omitempty"`
	PKCE                          string   `json:"pkce,omitempty"`
	ReuseRefreshToken             bool     `json:"reuse_refresh_token,omitempty"`
	EnablePasswordGrant           bool     `json:"enable_password_grant,omitempty"`
	EnableClientCredentials       bool     `json:"enable_client_credentials,omitempty"`
	GlobalCredentials             bool     `json:"global_credentials,omitempty"`
	Anonymous                     string   `json:"anonymous,omitempty"`
	EnableImplicitGrant           bool     `json:"enable_implicit_grant,omitempty"`
	EnableAuthorizationCode       bool     `json:"enable_authorization_code,omitempty"`
}

func NewOAuthPluginConfigFromMap added in v1.0.2

func NewOAuthPluginConfigFromMap(mapData map[string]interface{}) (*OAuthPluginConfig, error)

type PluginLister

type PluginLister interface {
	ListAll(ctx context.Context) ([]*klib.Plugin, error)
}

type Plugins

type Plugins struct {
	PluginLister
}

func (*Plugins) GetEffectivePlugins

func (p *Plugins) GetEffectivePlugins(routeID, serviceID string) (map[string]*klib.Plugin, error)

GetEffectivePlugins determines the effective plugin configuration for the route/service combination. Returns a map containing effective Plugin configuration grouped by plugin type.

Jump to

Keyboard shortcuts

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