Documentation ¶
Index ¶
- Variables
- type ApigatewayJwtApp
- type ApigatewayJwtClaims
- type ApigatewayJwtUser
- type Definition
- type DefintionContext
- type Manager
- func NewDefaultManager(apiName string, config bkapi.ClientConfig) (*Manager, error)
- func NewManager(apiName string, config bkapi.ClientConfig, definition *Definition, ...) (*Manager, error)
- func NewManagerFrom(apiName string, config bkapi.ClientConfig, path string, data interface{}) (*Manager, error)
- func (m *Manager) ApplyPermissions(namespace string) (map[string]interface{}, error)
- func (m *Manager) CreateResourceVersion(namespace string) (map[string]interface{}, error)
- func (m *Manager) GetDefinition() *Definition
- func (m *Manager) GetLatestResourceVersion() (map[string]interface{}, error)
- func (m *Manager) GetPublicKey() (map[string]interface{}, error)
- func (m *Manager) GetPublicKeyString() (string, error)
- func (m *Manager) GrantPermissions(namespace string) (map[string]interface{}, error)
- func (m *Manager) LoadDefinition(path string, data interface{}) error
- func (m *Manager) Release(namespace string) (map[string]interface{}, error)
- func (m *Manager) SyncBasicInfo(namespace string) (map[string]interface{}, error)
- func (m *Manager) SyncPluginConfig(namespace string) (map[string]interface{}, error)
- func (m *Manager) SyncResourceDocByArchive(namespace string) (map[string]interface{}, error)
- func (m *Manager) SyncResourcesConfig(namespace string) (map[string]interface{}, error)
- func (m *Manager) SyncStageConfig(namespace string) (map[string]interface{}, error)
- type PublicKeyMemoryCache
- type PublicKeyProvider
- type PublicKeySimpleProvider
- type RsaJwtTokenParser
Constants ¶
This section is empty.
Variables ¶
var ( ErrNotFound = errors.New("not found") ErrApigatewayRequest = errors.New("apigateway request error") ErrApiGatewayPublicKeyNotFound = errors.New("public key not found") ErrApiGatewayPublicKeyTypeNotSupported = errors.New("public key type not supported") )
var (
ErrKidInvalid = errors.New("kid is invalid")
)
Functions ¶
This section is empty.
Types ¶
type ApigatewayJwtApp ¶
type ApigatewayJwtApp struct { AppCode string `json:"app_code"` BkAppCode string `json:"bk_app_code"` Verified bool `json:"verified"` }
ApigatewayJwtApp represents the request app.
type ApigatewayJwtClaims ¶
type ApigatewayJwtClaims struct { jwt.StandardClaims ApiName string `json:"-"` App *ApigatewayJwtApp `json:"app,omitempty"` User *ApigatewayJwtUser `json:"user,omitempty"` }
ApigatewayJwtClaims is the jwt token payload, which carries the information of the request.
type ApigatewayJwtUser ¶
type ApigatewayJwtUser struct { Username string `json:"bk_username"` SourceType string `json:"source_type"` Verified bool `json:"verified"` }
ApigatewayJwtUser represents the request user.
type Definition ¶
type Definition struct {
// contains filtered or unexported fields
}
Definition represents a definition of a api gateway.
func NewDefinition ¶
func NewDefinition(definition map[string]interface{}) *Definition
NewDefinition creates a new definition from the given map.
func NewDefinitionFromYaml ¶
func NewDefinitionFromYaml(content []byte) (*Definition, error)
NewDefinitionFromYaml unmarshal the given yaml string to a definition.
type DefintionContext ¶
type DefintionContext struct {
// contains filtered or unexported fields
}
DefintionContext for defintion template engine
func NewDefinitionContext ¶
func NewDefinitionContext(apiName string, config *bkapi.ClientConfig) *DefintionContext
NewDefinitionContext return new defintion context
func (*DefintionContext) Context ¶
func (c *DefintionContext) Context(data interface{}) pongo2.Context
Context return pongo2 context
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager is the manager of apigw, it helps to sync apigw configs and get apigw infomations.
func NewDefaultManager ¶
func NewDefaultManager(apiName string, config bkapi.ClientConfig) (*Manager, error)
NewDefaultManager create a new default manager.
func NewManager ¶
func NewManager( apiName string, config bkapi.ClientConfig, definition *Definition, clientFactory func( configProvider define.ClientConfigProvider, opts ...define.BkApiClientOption, ) (*apigateway.Client, error), ) (*Manager, error)
NewManager create a new manager.
func NewManagerFrom ¶
func NewManagerFrom( apiName string, config bkapi.ClientConfig, path string, data interface{}, ) (*Manager, error)
NewManagerFrom file will create a new manager from the file.
func (*Manager) ApplyPermissions ¶
ApplyPermissions apply the permissions under the namespace to apigw.
func (*Manager) CreateResourceVersion ¶
CreateResourceVersion create a resource version defined in the namespace.
func (*Manager) GetDefinition ¶
func (m *Manager) GetDefinition() *Definition
GetDefinition return the definition.
func (*Manager) GetLatestResourceVersion ¶
GetLatestResourceVersion get the latest resource version from apigw.
func (*Manager) GetPublicKey ¶
GetPublicKey fetch the public key info from apigw.
func (*Manager) GetPublicKeyString ¶
GetPublicKey fetch the public key from apigw.
func (*Manager) GrantPermissions ¶
GrantPermissions grant the permissions under the namespace to apigw.
func (*Manager) LoadDefinition ¶
LoadDefinition will load the definition from the file.
func (*Manager) SyncBasicInfo ¶
SyncBasicInfo sync the basic info from definition under the namespace to apigw.
func (*Manager) SyncPluginConfig ¶
SyncPluginConfig sync the plugin config from definition under the namespace to apigw.
func (*Manager) SyncResourceDocByArchive ¶
SyncResourceDocByArchive sync the resource doc from archive to apigw.
func (*Manager) SyncResourcesConfig ¶
SyncResourcesConfig sync the resources config from definition under the namespace to apigw.
type PublicKeyMemoryCache ¶
type PublicKeyMemoryCache struct {
// contains filtered or unexported fields
}
PublicKeyMemoryCache will cache public key in memory.
func NewDefaultPublicKeyMemoryCache ¶
func NewDefaultPublicKeyMemoryCache(config bkapi.ClientConfig) *PublicKeyMemoryCache
NewDefaultPublicKeyMemoryCache creates a default memory cache for public key.
func NewPublicKeyMemoryCache ¶
func NewPublicKeyMemoryCache( config bkapi.ClientConfig, expiration time.Duration, clientFactory func(apiName string, config bkapi.ClientConfig) (*Manager, error), ) *PublicKeyMemoryCache
NewPublicKeyMemoryCache creates a memory cache for public key.
func (*PublicKeyMemoryCache) ProvidePublicKey ¶
func (c *PublicKeyMemoryCache) ProvidePublicKey(apiName string) (string, error)
ProvidePublicKey gets public key from cache.
type PublicKeyProvider ¶
PublicKeyProvider is the interface for public key provider.
type PublicKeySimpleProvider ¶
type PublicKeySimpleProvider struct {
// contains filtered or unexported fields
}
PublicKeySimpleProvider provides some predefined public keys.
func NewPublicKeySimpleProvider ¶
func NewPublicKeySimpleProvider(publicKeys map[string]string) *PublicKeySimpleProvider
NewPublicKeySimpleProvider creates a simple public key provider.
func (*PublicKeySimpleProvider) ProvidePublicKey ¶
func (p *PublicKeySimpleProvider) ProvidePublicKey(apiName string) (string, error)
ProvidePublicKey returns public key for given api name.
type RsaJwtTokenParser ¶
type RsaJwtTokenParser struct {
// contains filtered or unexported fields
}
RsaJwtTokenParser can parse jwt token by rsa algorithm.
func NewRsaJwtTokenParser ¶
func NewRsaJwtTokenParser(provider PublicKeyProvider) *RsaJwtTokenParser
NewRsaJwtTokenParser creates a new rsa jwt token parser.
func (*RsaJwtTokenParser) Parse ¶
func (p *RsaJwtTokenParser) Parse(tokenString string) (ApigatewayJwtClaims, error)
Parse the jwt token.