authorizer

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2021 License: MIT Imports: 13 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BackendAuth

type BackendAuth struct {
	Type  string
	Value string
}

BackendAuth contains client authorization credentials for apisonator

type BackendConfig

type BackendConfig struct {
	// EnableCaching of authorization responses to 3scale
	EnableCaching bool
	// CacheFlushInterval is the period at which the cache should be flushed and
	// reported to 3scale
	CacheFlushInterval time.Duration
	Logger             core.Logger
	Policy             backend.FailurePolicy
}

type BackendParams

type BackendParams struct {
	AppID   string
	AppKey  string
	UserID  string
	UserKey string
}

BackendParams contains the ebd user auth for the various supported authentication patterns

type BackendRequest

type BackendRequest struct {
	Auth         BackendAuth
	Service      string
	Transactions []BackendTransaction
}

BackendRequest contains the data required to make an Auth/AuthRep request to apisonator

func (BackendRequest) ToAPIRequest

func (request BackendRequest) ToAPIRequest() (*threescale.Request, error)

ToAPIRequest transforms the BackendRequest into a request that is acceptable for the 3scale Client interface

type BackendResponse

type BackendResponse struct {
	Authorized bool
	ErrorCode  string
	// RejectedReason should* be set in cases where Authorized is false
	RejectedReason string
	RawResponse    interface{}
}

BackendResponse contains the result of an Auth/AuthRep request

type BackendTransaction

type BackendTransaction struct {
	Metrics map[string]int
	Params  BackendParams
}

BackendTransaction contains the metrics and end user auth required to make an Auth/AuthRep request to apisonator

type Cache

type Cache int
const (
	System Cache = iota
	Backend
)

type CacheHitHook

type CacheHitHook func(cache Cache)

CacheHitHook is called when a hit is successful on system or backend cache

type ClientBuilder

type ClientBuilder struct {
	// contains filtered or unexported fields
}

ClientBuilder builds the 3scale clients, injecting the underlying HTTP client

func NewClientBuilder

func NewClientBuilder(httpClient *http.Client) *ClientBuilder

NewClientBuilder returns a pointer to ClientBuilder

func (ClientBuilder) BuildBackendClient

func (cb ClientBuilder) BuildBackendClient(backendURL string) (threescale.Client, error)

BuildBackendClient builds a 3scale apisonator http client The provided 'backendURL' must be prepended with a valid scheme

func (ClientBuilder) BuildSystemClient

func (cb ClientBuilder) BuildSystemClient(systemURL, accessToken string) (SystemClient, error)

BuildSystemClient builds a 3scale porta client from the provided URL(raw string) The provided 'systemURL' must be prepended with a valid scheme

type Manager

type Manager struct {
	// contains filtered or unexported fields
}

Manager manages connections and interactions between the adapter and 3scale (system and backend) Supports managing interactions between multiple hosts and can optionally leverage available caching implementations Capable of Authorizing a request to 3scale and providing the required functionality to pull from the sources to do so

func NewManager

func NewManager(
	client *http.Client,
	systemCache *SystemCache,
	backendConfig BackendConfig,
	reporter *MetricsReporter,
) *Manager

NewManager returns an instance of Manager Starts refreshing background process for underlying system cache if provided

func (Manager) AuthRep

func (m Manager) AuthRep(backendURL string, request BackendRequest) (*BackendResponse, error)

AuthRep does a Authorize and Report request into 3scale apisonator

func (Manager) GetSystemConfiguration

func (m Manager) GetSystemConfiguration(systemURL string, request SystemRequest) (client.ProxyConfig, error)

GetSystemConfiguration returns the configuration from 3scale system which can be used to fulfill and Auth request

func (Manager) OauthAuthRep added in v0.0.2

func (m Manager) OauthAuthRep(backendURL string, request BackendRequest) (*BackendResponse, error)

DEPRECATED: do not use in new code

func (Manager) Shutdown

func (m Manager) Shutdown()

Shutdown stops running background process

type MetricsReporter

type MetricsReporter struct {
	ReportMetrics bool
	ResponseCB    ResponseHook
	CacheHitCB    CacheHitHook
}

MetricsReporter holds config for reporting metrics

type MetricsRoundTripper

type MetricsRoundTripper struct {
	// contains filtered or unexported fields
}

func (*MetricsRoundTripper) RoundTrip

func (mt *MetricsRoundTripper) RoundTrip(req *http.Request) (*http.Response, error)

type ResponseHook

type ResponseHook func(report TelemetryReport)

ResponseHook is a callback function which allows running a function after each HTTP response from 3scale

type SystemCache

type SystemCache struct {
	cache.ConfigurationCache
	SystemCacheConfig
	// contains filtered or unexported fields
}

SystemCache wraps the caching implementation and its configuration for 3scale system

func NewSystemCache

func NewSystemCache(config SystemCacheConfig, stopRefreshing chan struct{}) *SystemCache

NewSystemCache returns a system cache configured with an in-memory caching implementation and sets some sensible defaults if zero values have been provided for the config

type SystemCacheConfig

type SystemCacheConfig struct {
	MaxSize               int
	NumRetryFailedRefresh int
	RefreshInterval       time.Duration
	TTL                   time.Duration
}

SystemCacheConfig holds the configuration for the cache

type SystemClient

type SystemClient interface {
	GetLatestProxyConfig(serviceID, environment string) (system.ProxyConfigElement, error)
}

SystemClient provides a minimalist interface for the adapters requirements from 3scale system

type SystemRequest

type SystemRequest struct {
	AccessToken string
	ServiceID   string
	Environment string
}

SystemRequest provides the required input to request the latest configuration from 3scale system

type TelemetryReport

type TelemetryReport struct {
	Host      string
	Method    string
	Endpoint  string
	Code      int
	TimeTaken time.Duration
}

TelemetryReport reports HTTP info from the request/response cycle to 3scale

Jump to

Keyboard shortcuts

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