configsource

package
v0.0.0-...-28092d6 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2024 License: Apache-2.0 Imports: 35 Imported by: 3

Documentation

Index

Constants

View Source
const (
	AuthgearYAML        = "authgear.yaml"
	AuthgearSecretYAML  = "authgear.secrets.yaml"
	AuthgearFeatureYAML = "authgear.features.yaml"
)
View Source
const ContextKeyFeatureConfig = contextKeyFeatureConfigType(AuthgearFeatureYAML)
View Source
const LocalFSPlanName = "local-fs"
View Source
const PGChannelConfigSourceChange = "config_source_change"
View Source
const PGChannelDomainChange = "domain_change"

Variables

View Source
var ContextKeyAppHostSuffixes = contextKeyAppHostSuffixes("APP_HOST_SUFFIXES")
View Source
var ContextKeyClock = clockContextKeyType{}
View Source
var ContextKeyDomainService = domainServiceContextKeyType{}
View Source
var ControllerDependencySet = wire.NewSet(
	NewController,
)
View Source
var ErrAppNotFound = errors.New("app not found")
View Source
var ErrDuplicatedAppID = errors.New("duplicated app ID")
View Source
var ErrEffectiveSecretConfig = apierrors.NewForbidden("cannot view effective secret config")

Functions

func LoadConfig

func LoadConfig(res *resource.Manager) (*config.Config, error)

func MakeAppFSFromDatabaseSource

func MakeAppFSFromDatabaseSource(s *DatabaseSource) (resource.Fs, error)

Types

type AppIDResolver

type AppIDResolver interface {
	ResolveAppID(r *http.Request) (appID string, err error)
}

type AuthgearFeatureYAMLDescriptor

type AuthgearFeatureYAMLDescriptor struct{}

func (AuthgearFeatureYAMLDescriptor) FindResources

func (AuthgearFeatureYAMLDescriptor) MatchResource

func (d AuthgearFeatureYAMLDescriptor) MatchResource(path string) (*resource.Match, bool)

func (AuthgearFeatureYAMLDescriptor) UpdateResource

func (AuthgearFeatureYAMLDescriptor) ViewResources

func (d AuthgearFeatureYAMLDescriptor) ViewResources(resources []resource.ResourceFile, rawView resource.View) (interface{}, error)

type AuthgearSecretYAMLDescriptor

type AuthgearSecretYAMLDescriptor struct{}

func (AuthgearSecretYAMLDescriptor) FindResources

func (AuthgearSecretYAMLDescriptor) MatchResource

func (d AuthgearSecretYAMLDescriptor) MatchResource(path string) (*resource.Match, bool)

func (AuthgearSecretYAMLDescriptor) UpdateResource

func (AuthgearSecretYAMLDescriptor) ViewResources

func (d AuthgearSecretYAMLDescriptor) ViewResources(resources []resource.ResourceFile, rawView resource.View) (interface{}, error)

type AuthgearYAMLDescriptor

type AuthgearYAMLDescriptor struct{}

func (AuthgearYAMLDescriptor) FindResources

func (d AuthgearYAMLDescriptor) FindResources(fs resource.Fs) ([]resource.Location, error)

func (AuthgearYAMLDescriptor) MatchResource

func (d AuthgearYAMLDescriptor) MatchResource(path string) (*resource.Match, bool)

func (AuthgearYAMLDescriptor) UpdateResource

func (AuthgearYAMLDescriptor) ViewResources

func (d AuthgearYAMLDescriptor) ViewResources(resources []resource.ResourceFile, rawView resource.View) (interface{}, error)

type Config

type Config struct {
	// Type sets the type of configuration source
	Type Type `envconfig:"TYPE" default:"local_fs"`

	// Watch indicates whether the configuration source would watch for changes and reload automatically
	Watch bool `envconfig:"WATCH" default:"true"`
	// Directory sets the path to app configuration directory file for local FS sources
	Directory string `envconfig:"DIRECTORY" default:"."`
}

type ConfigSource

type ConfigSource struct {
	AppIDResolver   AppIDResolver
	ContextResolver ContextResolver
}

func (*ConfigSource) ProvideContext

func (s *ConfigSource) ProvideContext(r *http.Request) (*config.AppContext, error)

type ContextResolver

type ContextResolver interface {
	ResolveContext(appID string) (*config.AppContext, error)
}

type Controller

type Controller struct {
	Handle          Handle
	AppIDResolver   AppIDResolver
	ContextResolver ContextResolver
}

func NewController

func NewController(
	cfg *Config,
	lf *LocalFS,
	d *Database,
) *Controller

func (*Controller) Close

func (c *Controller) Close() error

func (*Controller) GetConfigSource

func (c *Controller) GetConfigSource() *ConfigSource

func (*Controller) Open

func (c *Controller) Open() error

func (*Controller) ReloadApp

func (c *Controller) ReloadApp(appID string)

func (*Controller) ResolveContext

func (c *Controller) ResolveContext(appID string) (*config.AppContext, error)

ResolveContext allows direct resolution from appID. It is useful when you get appID somewhere else, rather than from a HTTP request.

type Database

type Database struct {
	Logger                DatabaseLogger
	BaseResources         *resource.Manager
	TrustProxy            config.TrustProxy
	Config                *Config
	Clock                 clock.Clock
	StoreFactory          StoreFactory
	DatabaseHandleFactory DatabaseHandleFactory
	DatabaseCredentials   *config.GlobalDatabaseCredentialsEnvironmentConfig
	DatabaseConfig        *config.DatabaseEnvironmentConfig

	ResolveAppIDType ResolveAppIDType
	// contains filtered or unexported fields
}

func (*Database) Close

func (d *Database) Close() error

func (*Database) CreateDatabaseSource

func (d *Database) CreateDatabaseSource(appID string, resources map[string][]byte, planName string) error

func (*Database) Open

func (d *Database) Open() error

func (*Database) ReloadApp

func (d *Database) ReloadApp(appID string)

func (*Database) ResolveAppID

func (d *Database) ResolveAppID(r *http.Request) (string, error)

func (*Database) ResolveContext

func (d *Database) ResolveContext(appID string) (*config.AppContext, error)

func (*Database) UpdateDatabaseSource

func (d *Database) UpdateDatabaseSource(appID string, updates []*resource.ResourceFile) error

type DatabaseHandleFactory

type DatabaseHandleFactory func() *globaldb.Handle

type DatabaseLogger

type DatabaseLogger struct{ *log.Logger }

func NewDatabaseLogger

func NewDatabaseLogger(lf *log.Factory) DatabaseLogger

type DatabaseSource

type DatabaseSource struct {
	ID        string
	AppID     string
	Data      map[string][]byte
	PlanName  string
	CreatedAt time.Time
	UpdatedAt time.Time
}

type DomainService

type DomainService interface {
	ListDomains(appID string) ([]*apimodel.Domain, error)
}

type Handle

type Handle interface {
	Open() error
	Close() error
	ReloadApp(appID string)
}

type LocalFS

type LocalFS struct {
	Logger        LocalFSLogger
	BaseResources *resource.Manager
	Config        *Config

	Fs afero.Fs `wire:"-"`
	// contains filtered or unexported fields
}

func (*LocalFS) AllAppIDs

func (s *LocalFS) AllAppIDs() ([]string, error)

func (*LocalFS) Close

func (s *LocalFS) Close() error

func (*LocalFS) Open

func (s *LocalFS) Open() error

func (*LocalFS) ReloadApp

func (s *LocalFS) ReloadApp(appID string)

func (*LocalFS) ResolveAppID

func (s *LocalFS) ResolveAppID(r *http.Request) (appID string, err error)

func (*LocalFS) ResolveContext

func (s *LocalFS) ResolveContext(_appID string) (*config.AppContext, error)

type LocalFSLogger

type LocalFSLogger struct{ *log.Logger }

func NewLocalFSLogger

func NewLocalFSLogger(lf *log.Factory) LocalFSLogger

type ResolveAppIDType

type ResolveAppIDType string
const (
	ResolveAppIDTypeDomain ResolveAppIDType = "domain"
	ResolveAppIDTypePath   ResolveAppIDType = "path"
)

func NewResolveAppIDTypeDomain

func NewResolveAppIDTypeDomain() ResolveAppIDType

func NewResolveAppIDTypePath

func NewResolveAppIDTypePath() ResolveAppIDType

type Store

type Store struct {
	SQLBuilder  *globaldb.SQLBuilder
	SQLExecutor *globaldb.SQLExecutor
}

func (*Store) CreateDatabaseSource

func (s *Store) CreateDatabaseSource(dbs *DatabaseSource) error

func (*Store) GetAppIDByDomain

func (s *Store) GetAppIDByDomain(domain string) (string, error)

func (*Store) GetDatabaseSourceByAppID

func (s *Store) GetDatabaseSourceByAppID(appID string) (*DatabaseSource, error)

func (*Store) GetDomainsByAppID

func (s *Store) GetDomainsByAppID(appID string) (domains []string, err error)

func (*Store) ListAll

func (s *Store) ListAll() ([]*DatabaseSource, error)

ListAll is introduced by the need of authgear internal elasticsearch reindex --all.

func (*Store) ListByPlan

func (s *Store) ListByPlan(planName string) ([]*DatabaseSource, error)

func (*Store) UpdateDatabaseSource

func (s *Store) UpdateDatabaseSource(dbs *DatabaseSource) error

type StoreFactory

type StoreFactory func(handle *globaldb.Handle) *Store

func NewStoreFactory

func NewStoreFactory(
	ctx context.Context,
	sqlbuilder *globaldb.SQLBuilder,
) StoreFactory

type Type

type Type string
const (
	TypeLocalFS  Type = "local_fs"
	TypeDatabase Type = "database"
)

Jump to

Keyboard shortcuts

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