Documentation
¶
Overview ¶
Package extension adapts Keysmith as a Forge extension.
Index ¶
- Constants
- type Config
- type DashboardConfig
- type ExtOption
- func WithBasePath(path string) ExtOption
- func WithConfig(c Config) ExtOption
- func WithDashboardTenant(tenantID, appID string) ExtOption
- func WithDisableMigrate() ExtOption
- func WithDisableRoutes() ExtOption
- func WithEngineOptions(opts ...keysmith.Option) ExtOption
- func WithGroveDatabase(name string) ExtOption
- func WithHookExtension(x plugin.Plugin) ExtOption
- func WithLogger(l log.Logger) ExtOption
- func WithRequireConfig(require bool) ExtOption
- type Extension
- func (e *Extension) API() *api.API
- func (e *Extension) Engine() *keysmith.Engine
- func (e *Extension) Handler() http.Handler
- func (e *Extension) Health(ctx context.Context) error
- func (e *Extension) Register(fapp forge.App) error
- func (e *Extension) RegisterContractContributor(disp *dispatcher.Dispatcher, reg dashcontract.Registry, ...) error
- func (e *Extension) Start(ctx context.Context) error
- func (e *Extension) Stop(ctx context.Context) error
Constants ¶
const ExtensionDescription = "Composable API key management engine for key lifecycle, validation, and usage analytics"
ExtensionDescription is the human-readable description.
const ExtensionName = "keysmith"
ExtensionName is the name registered with Forge.
const ExtensionVersion = "0.1.0"
ExtensionVersion is the semantic version.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
// DisableRoutes prevents HTTP route registration.
DisableRoutes bool `json:"disable_routes" mapstructure:"disable_routes" yaml:"disable_routes"`
// DisableMigrate prevents auto-migration on start.
DisableMigrate bool `json:"disable_migrate" mapstructure:"disable_migrate" yaml:"disable_migrate"`
// BasePath is the URL prefix for keysmith routes (default: "/keysmith").
BasePath string `json:"base_path" mapstructure:"base_path" yaml:"base_path"`
// GroveDatabase is the name of a grove.DB registered in the DI container.
// When set, the extension resolves this named database and auto-constructs
// the appropriate store based on the driver type (pg/sqlite/mongo).
// When empty and WithGroveDatabase was called, the default (unnamed) DB is used.
GroveDatabase string `json:"grove_database" mapstructure:"grove_database" yaml:"grove_database"`
// Dashboard scopes the React dashboard's contract handlers.
Dashboard DashboardConfig `json:"dashboard" mapstructure:"dashboard" yaml:"dashboard"`
// RequireConfig requires config to be present in YAML files.
// If true and no config is found, Register returns an error.
RequireConfig bool `json:"-" yaml:"-"`
}
Config holds the Keysmith extension configuration. Fields can be set programmatically via Option functions or loaded from YAML configuration files (under "extensions.keysmith" or "keysmith" keys).
func DefaultConfig ¶
func DefaultConfig() Config
DefaultConfig returns a Config with sensible defaults.
type DashboardConfig ¶
type DashboardConfig struct {
// TenantID is the tenant a dashboard request is scoped to when it carries
// no tenant claim and no session org (the forge Scope an auth extension
// such as authsome sets). Leave it empty and those requests refuse, so
// the dashboard never guesses.
TenantID string `json:"tenant_id" mapstructure:"tenant_id" yaml:"tenant_id"`
// AppID labels rows the dashboard creates when the principal carries no
// app claim. It may be empty. Keysmith never filters reads by app.
AppID string `json:"app_id" mapstructure:"app_id" yaml:"app_id"`
}
DashboardConfig scopes the dashboard contract handlers to a tenant.
type ExtOption ¶
type ExtOption func(*Extension)
ExtOption is a functional option for the Forge extension.
func WithBasePath ¶
WithBasePath sets the URL prefix for keysmith routes.
func WithDashboardTenant ¶
WithDashboardTenant sets the tenant (and optional app) the dashboard's contract handlers use when a request carries no tenant claim and no session org. A YAML dashboard.tenant_id or dashboard.app_id wins over these values.
func WithDisableMigrate ¶
func WithDisableMigrate() ExtOption
WithDisableMigrate prevents auto-migration on start.
func WithDisableRoutes ¶
func WithDisableRoutes() ExtOption
WithDisableRoutes prevents HTTP route registration.
func WithEngineOptions ¶
WithEngineOptions passes options to the underlying keysmith engine.
func WithGroveDatabase ¶
WithGroveDatabase sets the name of the grove.DB to resolve from the DI container. The extension will auto-construct the appropriate store backend (postgres/sqlite/mongo) based on the grove driver type. Pass an empty string to use the default (unnamed) grove.DB.
func WithHookExtension ¶
WithHookExtension registers a lifecycle plugin with the engine.
func WithRequireConfig ¶
WithRequireConfig requires config to be present in YAML files. If true and no config is found, Register returns an error.
type Extension ¶
type Extension struct {
*forge.BaseExtension
// contains filtered or unexported fields
}
Extension adapts Keysmith as a Forge extension.
func (*Extension) Engine ¶
Engine returns the underlying keysmith engine (nil until Register is called).
func (*Extension) Health ¶
Health implements forge.Extension.
func (*Extension) Register ¶
Register implements forge.Extension.
func (*Extension) RegisterContractContributor ¶
func (e *Extension) RegisterContractContributor( disp *dispatcher.Dispatcher, reg dashcontract.Registry, wreg dashcontract.WardenRegistry, ) error
RegisterContractContributor implements dashboard.ContractContributorAware. It registers the keysmith contract contributor, which is what the React shell reads.