Documentation ¶
Index ¶
- Constants
- Variables
- func LoadConfig(res *resource.Manager) (*config.Config, error)
- func MakeAppFSFromDatabaseSource(s *DatabaseSource) (resource.Fs, error)
- type AppIDResolver
- type AuthgearFeatureYAMLDescriptor
- func (d AuthgearFeatureYAMLDescriptor) FindResources(fs resource.Fs) ([]resource.Location, error)
- func (d AuthgearFeatureYAMLDescriptor) MatchResource(path string) (*resource.Match, bool)
- func (d AuthgearFeatureYAMLDescriptor) UpdateResource(_ context.Context, _ []resource.ResourceFile, resrc *resource.ResourceFile, ...) (*resource.ResourceFile, error)
- func (d AuthgearFeatureYAMLDescriptor) ViewResources(resources []resource.ResourceFile, rawView resource.View) (interface{}, error)
- type AuthgearSecretYAMLDescriptor
- func (d AuthgearSecretYAMLDescriptor) FindResources(fs resource.Fs) ([]resource.Location, error)
- func (d AuthgearSecretYAMLDescriptor) MatchResource(path string) (*resource.Match, bool)
- func (d AuthgearSecretYAMLDescriptor) UpdateResource(ctx context.Context, _ []resource.ResourceFile, resrc *resource.ResourceFile, ...) (*resource.ResourceFile, error)
- func (d AuthgearSecretYAMLDescriptor) ViewResources(resources []resource.ResourceFile, rawView resource.View) (interface{}, error)
- type AuthgearYAMLDescriptor
- func (d AuthgearYAMLDescriptor) FindResources(fs resource.Fs) ([]resource.Location, error)
- func (d AuthgearYAMLDescriptor) MatchResource(path string) (*resource.Match, bool)
- func (d AuthgearYAMLDescriptor) UpdateResource(ctx context.Context, _ []resource.ResourceFile, resrc *resource.ResourceFile, ...) (*resource.ResourceFile, error)
- func (d AuthgearYAMLDescriptor) ViewResources(resources []resource.ResourceFile, rawView resource.View) (interface{}, error)
- type Config
- type ConfigSource
- type ContextResolver
- type Controller
- type Database
- func (d *Database) Close() error
- func (d *Database) CreateDatabaseSource(appID string, resources map[string][]byte, planName string) error
- func (d *Database) Open() error
- func (d *Database) ReloadApp(appID string)
- func (d *Database) ResolveAppID(r *http.Request) (string, error)
- func (d *Database) ResolveContext(appID string) (*config.AppContext, error)
- func (d *Database) UpdateDatabaseSource(appID string, updates []*resource.ResourceFile) error
- type DatabaseLogger
- type DatabaseSource
- type Handle
- type LocalFS
- func (s *LocalFS) AllAppIDs() ([]string, error)
- func (s *LocalFS) Close() error
- func (s *LocalFS) Open() error
- func (s *LocalFS) ReloadApp(appID string)
- func (s *LocalFS) ResolveAppID(r *http.Request) (appID string, err error)
- func (s *LocalFS) ResolveContext(_appID string) (*config.AppContext, error)
- type LocalFSLogger
- type ResolveAppIDType
- type Store
- func (s *Store) CreateDatabaseSource(dbs *DatabaseSource) error
- func (s *Store) GetAppIDByDomain(domain string) (string, error)
- func (s *Store) GetDatabaseSourceByAppID(appID string) (*DatabaseSource, error)
- func (s *Store) ListAll() ([]*DatabaseSource, error)
- func (s *Store) ListByPlan(planName string) ([]*DatabaseSource, error)
- func (s *Store) UpdateDatabaseSource(dbs *DatabaseSource) error
- type Type
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 AppConfig = resource.RegisterResource(AuthgearYAMLDescriptor{})
View Source
var ContextKeyClock = clockContextKeyType{}
View Source
var ControllerDependencySet = wire.NewSet( NewController, )
View Source
var DependencySet = wire.NewSet( NewLocalFSLogger, wire.Struct(new(LocalFS), "*"), NewDatabaseLogger, wire.Struct(new(Database), "*"), wire.Struct(new(Store), "*"), )
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")
View Source
var FeatureConfig = resource.RegisterResource(AuthgearFeatureYAMLDescriptor{})
View Source
var SecretConfig = resource.RegisterResource(AuthgearSecretYAMLDescriptor{})
View Source
var Types = []Type{ TypeLocalFS, TypeDatabase, }
Functions ¶
func MakeAppFSFromDatabaseSource ¶
func MakeAppFSFromDatabaseSource(s *DatabaseSource) (resource.Fs, error)
Types ¶
type AppIDResolver ¶
type AuthgearFeatureYAMLDescriptor ¶
type AuthgearFeatureYAMLDescriptor struct{}
func (AuthgearFeatureYAMLDescriptor) FindResources ¶
func (AuthgearFeatureYAMLDescriptor) MatchResource ¶
func (d AuthgearFeatureYAMLDescriptor) MatchResource(path string) (*resource.Match, bool)
func (AuthgearFeatureYAMLDescriptor) UpdateResource ¶
func (d AuthgearFeatureYAMLDescriptor) UpdateResource(_ context.Context, _ []resource.ResourceFile, resrc *resource.ResourceFile, data []byte) (*resource.ResourceFile, error)
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 (d AuthgearSecretYAMLDescriptor) UpdateResource(ctx context.Context, _ []resource.ResourceFile, resrc *resource.ResourceFile, data []byte) (*resource.ResourceFile, error)
func (AuthgearSecretYAMLDescriptor) ViewResources ¶
func (d AuthgearSecretYAMLDescriptor) ViewResources(resources []resource.ResourceFile, rawView resource.View) (interface{}, error)
type AuthgearYAMLDescriptor ¶
type AuthgearYAMLDescriptor struct{}
func (AuthgearYAMLDescriptor) FindResources ¶
func (AuthgearYAMLDescriptor) MatchResource ¶
func (d AuthgearYAMLDescriptor) MatchResource(path string) (*resource.Match, bool)
func (AuthgearYAMLDescriptor) UpdateResource ¶
func (d AuthgearYAMLDescriptor) UpdateResource(ctx context.Context, _ []resource.ResourceFile, resrc *resource.ResourceFile, data []byte) (*resource.ResourceFile, error)
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 Store *Store Database *globaldb.Handle DatabaseCredentials *config.GlobalDatabaseCredentialsEnvironmentConfig DatabaseConfig *config.DatabaseEnvironmentConfig ResolveAppIDType ResolveAppIDType // contains filtered or unexported fields }
func (*Database) CreateDatabaseSource ¶
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 DatabaseLogger ¶
func NewDatabaseLogger ¶
func NewDatabaseLogger(lf *log.Factory) DatabaseLogger
type DatabaseSource ¶
type LocalFS ¶
type LocalFS struct { Logger LocalFSLogger BaseResources *resource.Manager Config *Config Fs afero.Fs `wire:"-"` // contains filtered or unexported fields }
func (*LocalFS) ResolveAppID ¶
func (*LocalFS) ResolveContext ¶
func (s *LocalFS) ResolveContext(_appID string) (*config.AppContext, error)
type LocalFSLogger ¶
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) GetDatabaseSourceByAppID ¶
func (s *Store) GetDatabaseSourceByAppID(appID string) (*DatabaseSource, 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
Click to show internal directories.
Click to hide internal directories.