config

package
v0.0.0-...-1703ca6 Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2025 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AuthTypeOAuth2 = AuthType("OAuth2")
	AuthTypeAPIKey = AuthType("api-key")
)
View Source
const (
	DefaultInitiateToRedirectTtl = 30 * time.Second
	DefaultOAuthRoundTripTtl     = 1 * time.Hour
)

Variables

This section is empty.

Functions

func AllServiceIdStrings

func AllServiceIdStrings() []string

func AllValidServiceIds

func AllValidServiceIds(ids []string) bool

func IsValidServiceId

func IsValidServiceId(id ServiceId) bool

func KindToString

func KindToString(k yaml.Kind) string

Types

type AdminUser

type AdminUser struct {
	Username string `json:"username" yaml:"username"`
	Key      Key    `json:"key" yaml:"key"`
}

func UnmarshallYamlAdminUser

func UnmarshallYamlAdminUser(data []byte) (*AdminUser, error)

func UnmarshallYamlAdminUserString

func UnmarshallYamlAdminUserString(data string) (*AdminUser, error)

func (*AdminUser) UnmarshalYAML

func (au *AdminUser) UnmarshalYAML(value *yaml.Node) error

type AdminUsers

type AdminUsers interface {
	All() []*AdminUser
	GetByUsername(username string) (*AdminUser, bool)
}

func UnmarshallYamlAdminUsers

func UnmarshallYamlAdminUsers(data []byte) (AdminUsers, error)

func UnmarshallYamlAdminUsersString

func UnmarshallYamlAdminUsersString(data string) (AdminUsers, error)

type AdminUsersExternalSource

type AdminUsersExternalSource struct {
	KeysPath string `json:"keys_path" yaml:"keys_path"`
}

func UnmarshallYamlAdminUsersExternalSource

func UnmarshallYamlAdminUsersExternalSource(data []byte) (*AdminUsersExternalSource, error)

func UnmarshallYamlAdminUsersExternalSourceString

func UnmarshallYamlAdminUsersExternalSourceString(data string) (*AdminUsersExternalSource, error)

func (*AdminUsersExternalSource) All

func (s *AdminUsersExternalSource) All() []*AdminUser

func (*AdminUsersExternalSource) GetByUsername

func (s *AdminUsersExternalSource) GetByUsername(username string) (*AdminUser, bool)

type AdminUsersList

type AdminUsersList []*AdminUser

func UnmarshallYamlAdminUsersList

func UnmarshallYamlAdminUsersList(data []byte) (AdminUsersList, error)

func UnmarshallYamlAdminUsersListString

func UnmarshallYamlAdminUsersListString(data string) (AdminUsersList, error)

func (AdminUsersList) All

func (aul AdminUsersList) All() []*AdminUser

func (AdminUsersList) GetByUsername

func (aul AdminUsersList) GetByUsername(username string) (*AdminUser, bool)

type Auth

type Auth interface {
	GetType() AuthType
}

func UnmarshallYamlAuth

func UnmarshallYamlAuth(data []byte) (Auth, error)

func UnmarshallYamlAuthString

func UnmarshallYamlAuthString(data string) (Auth, error)

type AuthApiKey

type AuthApiKey struct {
	Type AuthType `json:"type" yaml:"type"`
}

func (*AuthApiKey) GetType

func (a *AuthApiKey) GetType() AuthType

type AuthOAuth2

type AuthOAuth2 struct {
	Type                  AuthType    `json:"type" yaml:"type"`
	ClientId              StringValue `json:"client_id" yaml:"client_id"`
	ClientSecret          StringValue `json:"client_secret" yaml:"client_secret"`
	Scopes                []Scope     `json:"scopes" yaml:"scopes"`
	AuthorizationEndpoint string      `json:"authorization_endpoint" yaml:"authorization_endpoint"`
	TokenEndpoint         string      `json:"token_endpoint" yaml:"token_endpoint"`
}

func (*AuthOAuth2) GetType

func (a *AuthOAuth2) GetType() AuthType

func (*AuthOAuth2) UnmarshalYAML

func (i *AuthOAuth2) UnmarshalYAML(value *yaml.Node) error

type AuthType

type AuthType string

type C

type C interface {
	// GetRoot gets the root of the configuration; the data loaded from a configuration file
	GetRoot() *Root

	// IsDebugMode tells the system if debug flags have been passed when running this service
	IsDebugMode() bool

	// MustGetService gets the service information for the specified service name
	MustGetService(serviceName ServiceId) Service

	GetFallbackConnectorLogo() string
}

func FromRoot

func FromRoot(root *Root) C

func LoadConfig

func LoadConfig(path string) (C, error)

type Connector

type Connector struct {
	Id          string `json:"id" yaml:"id"`
	Version     uint64 `json:"version" yaml:"version"`
	DisplayName string `json:"display_name" yaml:"display_name"`
	Description string `json:"description" yaml:"description"`
	Auth        Auth   `json:"auth" yaml:"auth"`
}

func (*Connector) UnmarshalYAML

func (c *Connector) UnmarshalYAML(value *yaml.Node) error

type Database

type Database interface {
	GetProvider() DatabaseProvider
}

func UnmarshallYamlDatabase

func UnmarshallYamlDatabase(data []byte) (Database, error)

func UnmarshallYamlDatabaseString

func UnmarshallYamlDatabaseString(data string) (Database, error)

type DatabaseProvider

type DatabaseProvider string
const (
	DatabaseProviderSqlite DatabaseProvider = "sqlite"
)

type DatabaseSqlite

type DatabaseSqlite struct {
	Provider DatabaseProvider `json:"provider" yaml:"provider"`
	Path     string           `json:"path" yaml:"path"`
}

func (*DatabaseSqlite) GetProvider

func (d *DatabaseSqlite) GetProvider() DatabaseProvider

type ErrorPages

type ErrorPages struct {
	Unauthorized string `json:"unauthorized" yaml:"unauthorized"`
	Fallback     string `json:"fallback" yaml:"fallback"`
}

func (*ErrorPages) GetUnauthorized

func (e *ErrorPages) GetUnauthorized() string

type HumanDuration

type HumanDuration struct {
	time.Duration
}

func (HumanDuration) MarshalJSON

func (d HumanDuration) MarshalJSON() ([]byte, error)

MarshalJSON provides custom serialization of the duration to a human-readable string (e.g., "2m").

func (HumanDuration) MarshalYAML

func (d HumanDuration) MarshalYAML() (interface{}, error)

MarshalYAML provides custom serialization of the duration to a human-readable string (e.g., "2m").

func (*HumanDuration) UnmarshalJSON

func (d *HumanDuration) UnmarshalJSON(data []byte) error

UnmarshalJSON parses a human-readable duration string back into `time.Duration`.

func (*HumanDuration) UnmarshalYAML

func (d *HumanDuration) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML parses a human-readable duration string back into `time.Duration`.

type Image

type Image interface {
	GetUrl() string
}

func UnmarshallYamlImage

func UnmarshallYamlImage(data []byte) (Image, error)

func UnmarshallYamlImageString

func UnmarshallYamlImageString(data string) (Image, error)

type ImageBase64

type ImageBase64 struct {
	MimeType string `json:"mime_type" yaml:"mime_type"`
	Base64   string `json:"base64" yaml:"base64"`
}

func (*ImageBase64) GetUrl

func (i *ImageBase64) GetUrl() string

type ImagePublicUrl

type ImagePublicUrl struct {
	PublicUrl string `json:"public_url" yaml:"public_url"`
}

func (*ImagePublicUrl) GetUrl

func (i *ImagePublicUrl) GetUrl() string

type Key

type Key interface {
	// CanSign checks if the key can sign requests (either private key is present or shared key)
	CanSign() bool
	// CanVerifySignature checks if the key can be used to verify the signature of something (public key is present or shared key)
	CanVerifySignature() bool
}

func UnmarshallYamlKey

func UnmarshallYamlKey(data []byte) (Key, error)

func UnmarshallYamlKeyString

func UnmarshallYamlKeyString(data string) (Key, error)

type KeyData

type KeyData interface {
	// HasData checks if this value has data.
	HasData(ctx context.Context) bool

	// GetData retrieves the bytes of the key
	GetData(ctx context.Context) ([]byte, error)
}

func UnmarshallYamlKeyData

func UnmarshallYamlKeyData(data []byte) (KeyData, error)

func UnmarshallYamlKeyDataString

func UnmarshallYamlKeyDataString(data string) (KeyData, error)

type KeyDataBase64Val

type KeyDataBase64Val struct {
	Base64 string `json:"base64" yaml:"base64"`
}

func (*KeyDataBase64Val) GetData

func (kb *KeyDataBase64Val) GetData(ctx context.Context) ([]byte, error)

func (*KeyDataBase64Val) HasData

func (kb *KeyDataBase64Val) HasData(ctx context.Context) bool

type KeyDataEnvVar

type KeyDataEnvVar struct {
	EnvVar string `json:"env_var" yaml:"env_var"`
}

func (*KeyDataEnvVar) GetData

func (kev *KeyDataEnvVar) GetData(ctx context.Context) ([]byte, error)

func (*KeyDataEnvVar) HasData

func (kev *KeyDataEnvVar) HasData(ctx context.Context) bool

type KeyDataFile

type KeyDataFile struct {
	Path string `json:"path" yaml:"path"`
}

func (*KeyDataFile) GetData

func (kf *KeyDataFile) GetData(ctx context.Context) ([]byte, error)

func (*KeyDataFile) HasData

func (kf *KeyDataFile) HasData(ctx context.Context) bool

type KeyDataRandomBytes

type KeyDataRandomBytes struct {
	NumBytes int `json:"num_bytes" yaml:"num_bytes"`
	// contains filtered or unexported fields
}

func (*KeyDataRandomBytes) GetData

func (kf *KeyDataRandomBytes) GetData(ctx context.Context) ([]byte, error)

func (*KeyDataRandomBytes) HasData

func (kf *KeyDataRandomBytes) HasData(ctx context.Context) bool

type KeyDataRawVal

type KeyDataRawVal struct {
	Raw []byte `json:"-" yaml:"-"`
}

KeyDataRawVal is where the key data is specified directly as bytes. This isn't used for config via file but can be used as way to return data in a config interface that has data already loaded.

func (*KeyDataRawVal) GetData

func (kb *KeyDataRawVal) GetData(ctx context.Context) ([]byte, error)

func (*KeyDataRawVal) HasData

func (kb *KeyDataRawVal) HasData(ctx context.Context) bool

type KeyDataValue

type KeyDataValue struct {
	Value string `json:"value" yaml:"value"`
}

func (*KeyDataValue) GetData

func (kv *KeyDataValue) GetData(ctx context.Context) ([]byte, error)

func (*KeyDataValue) HasData

func (kv *KeyDataValue) HasData(ctx context.Context) bool

type KeyPublicPrivate

type KeyPublicPrivate struct {
	PublicKey  KeyData `json:"public_key" yaml:"public_key"`
	PrivateKey KeyData `json:"private_key" yaml:"private_key"`
}

func (*KeyPublicPrivate) CanSign

func (kpp *KeyPublicPrivate) CanSign() bool

func (*KeyPublicPrivate) CanVerifySignature

func (kpp *KeyPublicPrivate) CanVerifySignature() bool

func (*KeyPublicPrivate) UnmarshalYAML

func (kpp *KeyPublicPrivate) UnmarshalYAML(value *yaml.Node) error

type KeyShared

type KeyShared struct {
	SharedKey KeyData `json:"shared_key" yaml:"shared_key"`
}

func (*KeyShared) CanSign

func (ks *KeyShared) CanSign() bool

func (*KeyShared) CanVerifySignature

func (ks *KeyShared) CanVerifySignature() bool

func (*KeyShared) UnmarshalYAML

func (ks *KeyShared) UnmarshalYAML(value *yaml.Node) error

type OAuth

type OAuth struct {
	// InitiateToRedirectTtl is the time allowed between the oauth initiate API call, and the time when the browser
	// completes the redirect from the auth proxy public service. This value must be less than RoundTripTtl. This value
	// should be as small as possible as the handoff from the API to the redirect involves a one-time-use auth token
	// in the query parameters, which could be used to steal the session.
	InitiateToRedirectTtl HumanDuration `json:"initiate_to_redirect_ttl" yaml:"initiate_to_redirect_ttl"`

	// RoundTripTtl is the time we allow for the user to go through the oauth flow, from the initiate call, all the
	// way back to returning to AuthProxy to exchange the auth token for an access token. The purpose of this timeout
	// is to reduce the time that a redirect link from auth proxy would be valid for the purposes of phishing other
	// peoples credentials using this link as the basis.
	RoundTripTtl HumanDuration `json:"round_trip_ttl" yaml:"round_trip_ttl"`
}

func (*OAuth) GetInitiateToRedirectTtlOrDefault

func (o *OAuth) GetInitiateToRedirectTtlOrDefault() time.Duration

func (*OAuth) GetRoundTripTtlOrDefault

func (o *OAuth) GetRoundTripTtlOrDefault() time.Duration

type Redis

type Redis interface {
	GetProvider() RedisProvider
}

func UnmarshallYamlRedis

func UnmarshallYamlRedis(data []byte) (Redis, error)

func UnmarshallYamlRedisString

func UnmarshallYamlRedisString(data string) (Redis, error)

type RedisMiniredis

type RedisMiniredis struct {
	Provider RedisProvider `json:"provider" yaml:"provider"`
}

func (*RedisMiniredis) GetProvider

func (d *RedisMiniredis) GetProvider() RedisProvider

type RedisProvider

type RedisProvider string
const (
	RedisProviderMiniredis RedisProvider = "miniredis"
	RedisProviderRedis     RedisProvider = "redis"
)

type RedisReal

type RedisReal struct {
	Provider RedisProvider `json:"provider" yaml:"provider"`

	// The network type, either tcp or unix.
	// Default is tcp.
	Network string `json:"network" yaml:"network"`

	// host:port address.
	Address string `json:"address" yaml:"address"`

	// Protocol 2 or 3. Use the version to negotiate RESP version with redis-server.
	// Default is 3.
	Protocol int `json:"protocol" yaml:"protocol"`

	// Use the specified Username to authenticate the current connection
	// with one of the connections defined in the ACL list when connecting
	// to a Redis 6.0 instance, or greater, that is using the Redis ACL system.
	Username StringValue `json:"username" yaml:"username"`

	// Optional password. Must match the password specified in the
	// requirepass server configuration option (if connecting to a Redis 5.0 instance, or lower),
	// or the User Password when connecting to a Redis 6.0 instance, or greater,
	// that is using the Redis ACL system.
	Password StringValue `json:"password" yaml:"password"`

	// Database to be selected after connecting to the server.
	DB int `json:"db" yaml:"db"`
}

func (*RedisReal) GetProvider

func (d *RedisReal) GetProvider() RedisProvider

func (*RedisReal) ToRedisOptions

func (d *RedisReal) ToRedisOptions(ctx context.Context) (*redis.Options, error)

func (*RedisReal) UnmarshalYAML

func (sa *RedisReal) UnmarshalYAML(value *yaml.Node) error

type Root

type Root struct {
	AdminApi   ServiceAdminApi `json:"admin_api" yaml:"admin_api"`
	Api        ServiceApi      `json:"api" yaml:"api"`
	Public     ServicePublic   `json:"public" yaml:"public"`
	SystemAuth SystemAuth      `json:"system_auth" yaml:"system_auth"`
	Database   Database        `json:"database" yaml:"database"`
	Redis      Redis           `json:"redis" yaml:"redis"`
	Oauth      OAuth           `json:"oauth" yaml:"oauth"`
	ErrorPages ErrorPages      `json:"error_pages" yaml:"error_pages"`
	Connectors []Connector     `json:"connectors" yaml:"connectors"`
}

func UnmarshallYamlRoot

func UnmarshallYamlRoot(data []byte) (*Root, error)

func UnmarshallYamlRootString

func UnmarshallYamlRootString(data string) (*Root, error)

func (*Root) MustGetService

func (r *Root) MustGetService(serviceId ServiceId) Service

func (*Root) UnmarshalYAML

func (sa *Root) UnmarshalYAML(value *yaml.Node) error

type Scope

type Scope struct {
	Id       string `json:"id" yaml:"id"`
	Required bool   `json:"required" yaml:"required"`
	Reason   string `json:"reason" yaml:"reason"`
}

func UnmarshallYamlScope

func UnmarshallYamlScope(data []byte) (*Scope, error)

func UnmarshallYamlScopeString

func UnmarshallYamlScopeString(data string) (*Scope, error)

func (*Scope) UnmarshalYAML

func (s *Scope) UnmarshalYAML(value *yaml.Node) error

type Service

type Service interface {
	Port() uint64
	IsHttps() bool
	Domain() string
	GetBaseUrl() string
	SupportsSession() bool
	GetId() ServiceId
}

type ServiceAdminApi

type ServiceAdminApi struct {
	PortVal    uint64 `json:"port" yaml:"port"`
	DomainVal  string `json:"domain" yaml:"domain"`
	IsHttpsVal bool   `json:"https" yaml:"https"`
}

func (*ServiceAdminApi) Domain

func (s *ServiceAdminApi) Domain() string

func (*ServiceAdminApi) GetBaseUrl

func (s *ServiceAdminApi) GetBaseUrl() string

func (*ServiceAdminApi) GetId

func (s *ServiceAdminApi) GetId() ServiceId

func (*ServiceAdminApi) IsHttps

func (s *ServiceAdminApi) IsHttps() bool

func (*ServiceAdminApi) Port

func (s *ServiceAdminApi) Port() uint64

func (*ServiceAdminApi) SupportsSession

func (s *ServiceAdminApi) SupportsSession() bool

type ServiceApi

type ServiceApi struct {
	PortVal    uint64 `json:"port" yaml:"port"`
	DomainVal  string `json:"domain" yaml:"domain"`
	IsHttpsVal bool   `json:"https" yaml:"https"`
}

func (*ServiceApi) Domain

func (s *ServiceApi) Domain() string

func (*ServiceApi) GetBaseUrl

func (s *ServiceApi) GetBaseUrl() string

func (*ServiceApi) GetId

func (s *ServiceApi) GetId() ServiceId

func (*ServiceApi) IsHttps

func (s *ServiceApi) IsHttps() bool

func (*ServiceApi) Port

func (s *ServiceApi) Port() uint64

func (*ServiceApi) SupportsSession

func (s *ServiceApi) SupportsSession() bool

type ServiceId

type ServiceId string
const (
	ServiceIdAdminApi ServiceId = "admin-api"
	ServiceIdApi      ServiceId = "api"
	ServiceIdPublic   ServiceId = "public"
)

func AllServiceIds

func AllServiceIds() []ServiceId

type ServicePublic

type ServicePublic struct {
	PortVal    uint64 `json:"port" yaml:"port"`
	DomainVal  string `json:"domain" yaml:"domain"`
	IsHttpsVal bool   `json:"https" yaml:"https"`
}

func (*ServicePublic) Domain

func (s *ServicePublic) Domain() string

func (*ServicePublic) GetBaseUrl

func (s *ServicePublic) GetBaseUrl() string

func (*ServicePublic) GetId

func (s *ServicePublic) GetId() ServiceId

func (*ServicePublic) IsHttps

func (s *ServicePublic) IsHttps() bool

func (*ServicePublic) Port

func (s *ServicePublic) Port() uint64

func (*ServicePublic) SupportsSession

func (s *ServicePublic) SupportsSession() bool

type StringValue

type StringValue interface {
	// HasValue checks if this value has data.
	HasValue(ctx context.Context) bool

	// GetValue retrieves the bytes of the key
	GetValue(ctx context.Context) (string, error)
}

func UnmarshallYamlStringValue

func UnmarshallYamlStringValue(data []byte) (StringValue, error)

func UnmarshallYamlStringValueString

func UnmarshallYamlStringValueString(data string) (StringValue, error)

type StringValueBase64

type StringValueBase64 struct {
	Base64 string `json:"base64" yaml:"base64"`
}

func (*StringValueBase64) GetValue

func (kb *StringValueBase64) GetValue(ctx context.Context) (string, error)

func (*StringValueBase64) HasValue

func (kb *StringValueBase64) HasValue(ctx context.Context) bool

type StringValueDirect

type StringValueDirect struct {
	Value string `json:"value" yaml:"value"`
}

StringValueDirect is where the key data is specified directly as bytes. This isn't used for config via file but can be used as way to return data in a config interface that has data already loaded.

func (*StringValueDirect) GetValue

func (kb *StringValueDirect) GetValue(ctx context.Context) (string, error)

func (*StringValueDirect) HasValue

func (kb *StringValueDirect) HasValue(ctx context.Context) bool

type StringValueEnvVar

type StringValueEnvVar struct {
	EnvVar string `json:"env_var" yaml:"env_var"`
}

func (*StringValueEnvVar) GetValue

func (kev *StringValueEnvVar) GetValue(ctx context.Context) (string, error)

func (*StringValueEnvVar) HasValue

func (kev *StringValueEnvVar) HasValue(ctx context.Context) bool

type StringValueFile

type StringValueFile struct {
	Path string `json:"path" yaml:"path"`
}

func (*StringValueFile) GetValue

func (kf *StringValueFile) GetValue(ctx context.Context) (string, error)

func (*StringValueFile) HasValue

func (kf *StringValueFile) HasValue(ctx context.Context) bool

type SystemAuth

type SystemAuth struct {
	JwtSigningKey       Key           `json:"jwt_signing_key" yaml:"jwt_signing_key"`
	JwtIssuerVal        string        `json:"jwt_issuer" yaml:"jwt_issuer"`
	JwtTokenDurationVal time.Duration `json:"jwt_token_duration" yaml:"jwt_token_duration"`
	CookieDomain        string        `json:"cookie_domain" yaml:"cookie_domain"`
	CookieDurationVal   time.Duration `json:"cookie_duration" yaml:"cookie_duration"`
	DisableXSRF         bool          `json:"disable_xsrf" yaml:"disable_xsrf"`
	AdminUsers          AdminUsers    `json:"admin_users" yaml:"admin_users"`
	GlobalAESKey        KeyData       `json:"global_aes_key" yaml:"global_aes_key"`
}

func UnmarshallYamlSystemAuth

func UnmarshallYamlSystemAuth(data []byte) (*SystemAuth, error)

func UnmarshallYamlSystemAuthString

func UnmarshallYamlSystemAuthString(data string) (*SystemAuth, error)

func (*SystemAuth) CookieDuration

func (sa *SystemAuth) CookieDuration() time.Duration

func (*SystemAuth) JwtIssuer

func (sa *SystemAuth) JwtIssuer() string

func (*SystemAuth) JwtTokenDuration

func (sa *SystemAuth) JwtTokenDuration() time.Duration

func (*SystemAuth) UnmarshalYAML

func (sa *SystemAuth) UnmarshalYAML(value *yaml.Node) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳