Documentation
¶
Index ¶
- func NewExtension(opts ...ConfigOption) forge.Extension
- func ResolveAuth(app forge.App) (*authsome.Auth, error)
- type Config
- type ConfigOption
- func WithBasePath(path string) ConfigOption
- func WithConfig(config Config) ConfigOption
- func WithDatabase(db *bun.DB) ConfigOption
- func WithDatabaseName(name string) ConfigOption
- func WithGeoIPProvider(provider security.GeoIPProvider) ConfigOption
- func WithPlugins(plugins ...plugins.Plugin) ConfigOption
- func WithRBACEnforcement(enabled bool) ConfigOption
- func WithRateLimitConfig(config ratelimit.Config) ConfigOption
- func WithRateLimitStorage(storage ratelimit.Storage) ConfigOption
- func WithRequireConfig(require bool) ConfigOption
- func WithSecret(secret string) ConfigOption
- func WithSecurityConfig(config security.Config) ConfigOption
- func WithTrustedOrigins(origins []string) ConfigOption
- type Extension
- func (e *Extension) Auth() *authsome.Auth
- func (e *Extension) GetBasePath() string
- func (e *Extension) GetDB() *bun.DB
- func (e *Extension) GetPluginRegistry() plugins.PluginRegistry
- func (e *Extension) GetServiceRegistry() *registry.ServiceRegistry
- func (e *Extension) Health(ctx context.Context) error
- func (e *Extension) Register(app forge.App) error
- func (e *Extension) RegisterPlugin(plugin plugins.Plugin) error
- func (e *Extension) Start(ctx context.Context) error
- func (e *Extension) Stop(ctx context.Context) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewExtension ¶
func NewExtension(opts ...ConfigOption) forge.Extension
NewExtension creates a new AuthSome extension with optional configuration
Types ¶
type Config ¶
type Config struct {
// BasePath is the base path where auth routes are mounted
BasePath string `yaml:"basePath" json:"basePath"`
// Database configuration - mutually exclusive options
// Database is a direct database connection (takes precedence)
Database interface{} `yaml:"-" json:"-"`
// DatabaseName is the name of the database to use from DatabaseManager
DatabaseName string `yaml:"databaseName" json:"databaseName"`
// TrustedOrigins for CORS
TrustedOrigins []string `yaml:"trustedOrigins" json:"trustedOrigins"`
// Secret for signing tokens
Secret string `yaml:"secret" json:"secret"`
// RBACEnforce enables handler-level RBAC enforcement
RBACEnforce bool `yaml:"rbacEnforce" json:"rbacEnforce"`
// SecurityConfig for IP/country restrictions
SecurityConfig *security.Config `yaml:"security" json:"security"`
// RateLimitConfig for rate limiting
RateLimitConfig *ratelimit.Config `yaml:"rateLimit" json:"rateLimit"`
// RateLimitStorage is the storage backend for rate limiting
RateLimitStorage ratelimit.Storage `yaml:"-" json:"-"`
// GeoIPProvider for country-based restrictions
GeoIPProvider security.GeoIPProvider `yaml:"-" json:"-"`
// Plugins to register with AuthSome
Plugins []plugins.Plugin `yaml:"-" json:"-"`
// RequireConfig determines if configuration must be loaded from file
RequireConfig bool `yaml:"-" json:"-"`
}
Config holds the configuration for the AuthSome extension
type ConfigOption ¶
type ConfigOption func(*Config)
ConfigOption is a functional option for configuring the extension
func WithBasePath ¶
func WithBasePath(path string) ConfigOption
WithBasePath sets the base path for routes
func WithConfig ¶
func WithConfig(config Config) ConfigOption
WithConfig sets the entire configuration
func WithDatabase ¶
func WithDatabase(db *bun.DB) ConfigOption
WithDatabase sets a direct database connection
func WithDatabaseName ¶
func WithDatabaseName(name string) ConfigOption
WithDatabaseName sets the database name to use from DatabaseManager
func WithGeoIPProvider ¶
func WithGeoIPProvider(provider security.GeoIPProvider) ConfigOption
WithGeoIPProvider sets the GeoIP provider
func WithPlugins ¶
func WithPlugins(plugins ...plugins.Plugin) ConfigOption
WithPlugins sets the plugins to register
func WithRBACEnforcement ¶
func WithRBACEnforcement(enabled bool) ConfigOption
WithRBACEnforcement enables/disables RBAC enforcement
func WithRateLimitConfig ¶
func WithRateLimitConfig(config ratelimit.Config) ConfigOption
WithRateLimitConfig sets rate limit configuration
func WithRateLimitStorage ¶
func WithRateLimitStorage(storage ratelimit.Storage) ConfigOption
WithRateLimitStorage sets the rate limit storage backend
func WithRequireConfig ¶
func WithRequireConfig(require bool) ConfigOption
WithRequireConfig sets whether configuration must be loaded from file
func WithSecret ¶
func WithSecret(secret string) ConfigOption
WithSecret sets the secret for token signing
func WithSecurityConfig ¶
func WithSecurityConfig(config security.Config) ConfigOption
WithSecurityConfig sets security configuration
func WithTrustedOrigins ¶
func WithTrustedOrigins(origins []string) ConfigOption
WithTrustedOrigins sets trusted origins for CORS
type Extension ¶
type Extension struct {
*forge.BaseExtension
// contains filtered or unexported fields
}
Extension implements the Forge extension interface for AuthSome
func ResolveExtension ¶
ResolveExtension resolves the AuthSome extension from a Forge app This allows you to access the extension instance after registration
func (*Extension) Auth ¶
Auth returns the AuthSome instance Use this to access AuthSome programmatically after extension is registered
func (*Extension) GetBasePath ¶
GetBasePath returns the configured base path This is used by plugins to construct URLs
func (*Extension) GetDB ¶
GetDB returns the database instance This is used by plugins that need direct database access
func (*Extension) GetPluginRegistry ¶
func (e *Extension) GetPluginRegistry() plugins.PluginRegistry
GetPluginRegistry returns the plugin registry for plugin detection This is used by the dashboard plugin to detect which plugins are enabled
func (*Extension) GetServiceRegistry ¶
func (e *Extension) GetServiceRegistry() *registry.ServiceRegistry
GetServiceRegistry returns the service registry This is used by plugins that need access to core services
func (*Extension) RegisterPlugin ¶
RegisterPlugin registers a plugin before Start is called