domain

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidHTTPMethod = errors.New("not a valid HTTPMethod")
View Source
var ErrInvalidRateLimitDescriptionBy = errors.New("not a valid RateLimitDescriptionBy")

Functions

This section is empty.

Types

type Config

type Config struct {
	PublicListenAddress   string           `json:"public_listen_address"`
	AdminListenAddress    string           `json:"admin_listen_address"`
	Auth0Domain           string           `json:"auth0_domain"`
	Auth0Audience         string           `json:"auth0_audience"`
	Auth0ClientID         string           `json:"auth0_client_id"`
	Auth0ClientSecret     string           `json:"auth0_client_secret"`
	RedisAddress          string           `json:"redis_address"`
	RedisPassword         string           `json:"redis_password"`
	DescriptionSyncPeriod time.Duration    `json:"description_sync_period"`
	Services              []*ConfigService `json:"services"`
}

Config ...

func (*Config) SetDefaults

func (c *Config) SetDefaults()

SetDefaults ...

func (*Config) Validate

func (c *Config) Validate() error

Validate ...

type ConfigService

type ConfigService struct {
	Name             string        `json:"name"`
	Address          string        `json:"address"`
	M2MAudience      string        `json:"m2m_audience"`
	OperationTimeout time.Duration `json:"timeout"`
}

ConfigService ...

func (*ConfigService) SetDefaults

func (cs *ConfigService) SetDefaults()

SetDefaults ...

func (*ConfigService) Validate

func (cs *ConfigService) Validate() error

Validate ...

type HTTPMethod

type HTTPMethod uint8

HTTPMethod ... ENUM(unspecified, get, put, post, delete, patch)

const (
	// HTTPMethodUnspecified is a HTTPMethod of type Unspecified.
	HTTPMethodUnspecified HTTPMethod = iota
	// HTTPMethodGet is a HTTPMethod of type Get.
	HTTPMethodGet
	// HTTPMethodPut is a HTTPMethod of type Put.
	HTTPMethodPut
	// HTTPMethodPost is a HTTPMethod of type Post.
	HTTPMethodPost
	// HTTPMethodDelete is a HTTPMethod of type Delete.
	HTTPMethodDelete
	// HTTPMethodPatch is a HTTPMethod of type Patch.
	HTTPMethodPatch
)

func ParseHTTPMethod

func ParseHTTPMethod(name string) (HTTPMethod, error)

ParseHTTPMethod attempts to convert a string to a HTTPMethod.

func (HTTPMethod) IsValid

func (x HTTPMethod) IsValid() bool

IsValid provides a quick way to determine if the typed value is part of the allowed enumerated values

func (HTTPMethod) String

func (x HTTPMethod) String() string

String implements the Stringer interface.

type ProcessRequest

type ProcessRequest struct {
	Service    string
	HTTPMethod HTTPMethod
	APIMethod  string
	Path       string
	Query      string
	Body       []byte
	Headers    http.Header
	RemoteAddr string
}

ProcessRequest ...

func (ProcessRequest) Validate

func (r ProcessRequest) Validate() error

Validate ...

type ProviderDescription

type ProviderDescription struct {
	AuditEnabled          bool
	RateLimiter           *RateLimiterDescription
	RequireAuthentication bool
	RequiredPermissions   []string
	DescriptionByMethod   map[string]*ProviderDescriptionMethod
}

ProviderDescription ...

func (*ProviderDescription) NeedAudit

func (p *ProviderDescription) NeedAudit(method string) bool

NeedAudit ...

func (*ProviderDescription) NeedAuthentication

func (p *ProviderDescription) NeedAuthentication(method string) bool

NeedAuthentication ...

func (*ProviderDescription) Permissions

func (p *ProviderDescription) Permissions(method string) []string

Permissions ...

func (*ProviderDescription) SelectRateLimiter

func (p *ProviderDescription) SelectRateLimiter(method string) (description *RateLimiterDescription, isServiceLimiter bool)

SelectRateLimiter ...

type ProviderDescriptionMethod

type ProviderDescriptionMethod struct {
	Method                 string
	AuditEnabled           bool
	RateLimiter            *RateLimiterDescription
	RequiredAuthentication bool
	RequiredPermissions    []string
	AllowedHTTPMethods     mapset.Set[HTTPMethod]
}

ProviderDescriptionMethod ...

type ProviderProcessRequest

type ProviderProcessRequest struct {
	APIMethod          string
	HTTPMethod         HTTPMethod
	Path               string
	Query              string
	Body               []byte
	Headers            http.Header
	SubjectInformation *SubjectInformation
}

ProviderProcessRequest ...

func (*ProviderProcessRequest) Preprocess

func (p *ProviderProcessRequest) Preprocess()

Preprocess ...

type ProviderProcessResponse

type ProviderProcessResponse struct {
	Body       []byte
	StatusCode uint32
	Headers    http.Header
}

ProviderProcessResponse ...

func (*ProviderProcessResponse) SetDefaults

func (p *ProviderProcessResponse) SetDefaults()

SetDefaults ...

type RateLimitDescriptionBy

type RateLimitDescriptionBy uint8

RateLimitDescriptionBy ... ENUM(ip, subject_id)

const (
	// RateLimitDescriptionByIp is a RateLimitDescriptionBy of type Ip.
	RateLimitDescriptionByIp RateLimitDescriptionBy = iota
	// RateLimitDescriptionBySubjectId is a RateLimitDescriptionBy of type Subject_id.
	RateLimitDescriptionBySubjectId
)

func ParseRateLimitDescriptionBy

func ParseRateLimitDescriptionBy(name string) (RateLimitDescriptionBy, error)

ParseRateLimitDescriptionBy attempts to convert a string to a RateLimitDescriptionBy.

func (RateLimitDescriptionBy) IsValid

func (x RateLimitDescriptionBy) IsValid() bool

IsValid provides a quick way to determine if the typed value is part of the allowed enumerated values

func (RateLimitDescriptionBy) String

func (x RateLimitDescriptionBy) String() string

String implements the Stringer interface.

type RateLimiterDescription

type RateLimiterDescription struct {
	By     RateLimitDescriptionBy
	Rate   uint64
	Burst  uint64
	Period time.Duration
}

RateLimiterDescription ...

type SubjectInformation

type SubjectInformation struct {
	ID          string
	Permissions mapset.Set[string]
}

SubjectInformation ...

func (*SubjectInformation) Validate

func (u *SubjectInformation) Validate() error

Validate ...

Jump to

Keyboard shortcuts

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