Documentation
¶
Overview ¶
Package bridge defines local interfaces for optional forgery extension integration. AuthSome defines its own slim interfaces (following the keysmith audit_hook pattern) to avoid hard coupling to external packages. Bridge adapters in separate packages translate between these local types and the actual extension APIs.
Index ¶
- Constants
- Variables
- func LegacyPlaintextReads() uint64
- type AESGCMEncryptor
- type AuditEvent
- type Authorizer
- type AuthorizerFunc
- type AuthzRequest
- type AuthzResult
- type BusChronicle
- type Chronicle
- type ChronicleFunc
- type CreateKeyInput
- type Dispatcher
- type EmailMessage
- type Encryptor
- type EndpointInput
- type EndpointRelay
- type EventRelay
- type EventRelayFunc
- type Herald
- type HeraldNotifyRequest
- type HeraldRenderedContent
- type HeraldSendRequest
- type HeraldTemplate
- type HeraldTemplateManager
- type HeraldTemplateVariable
- type HeraldTemplateVersion
- type KeyManager
- type KeyResult
- type Keyring
- type Ledger
- type Mailer
- type MailerFunc
- type MemoryChronicle
- type MemoryEndpoint
- type MemoryRelay
- func (m *MemoryRelay) CreateEndpoint(_ context.Context, in EndpointInput) (string, error)
- func (m *MemoryRelay) DeleteEndpoint(_ context.Context, endpointID string) error
- func (m *MemoryRelay) Endpoint(endpointID string) (MemoryEndpoint, bool)
- func (m *MemoryRelay) EndpointCount() int
- func (m *MemoryRelay) Events() []*WebhookEvent
- func (*MemoryRelay) RegisterEventTypes(context.Context, []WebhookDefinition) error
- func (m *MemoryRelay) RotateEndpointSecret(_ context.Context, endpointID string) (string, error)
- func (m *MemoryRelay) Send(_ context.Context, event *WebhookEvent) error
- func (m *MemoryRelay) SetEndpointEnabled(_ context.Context, endpointID string, enabled bool) error
- func (m *MemoryRelay) UpdateEndpoint(_ context.Context, endpointID string, in EndpointInput) error
- type MetricsCollector
- type NoopDispatcher
- type NoopEncryptor
- type NoopHerald
- func (h *NoopHerald) CreateTemplate(_ context.Context, _ *HeraldTemplate) error
- func (h *NoopHerald) CreateVersion(_ context.Context, _ *HeraldTemplateVersion) error
- func (h *NoopHerald) DeleteTemplate(_ context.Context, _ string) error
- func (h *NoopHerald) DeleteVersion(_ context.Context, _ string) error
- func (h *NoopHerald) GetTemplate(_ context.Context, _ string) (*HeraldTemplate, error)
- func (h *NoopHerald) ListTemplates(_ context.Context, _ string) ([]*HeraldTemplate, error)
- func (h *NoopHerald) Notify(_ context.Context, req *HeraldNotifyRequest) error
- func (h *NoopHerald) RenderTemplate(_ context.Context, _, _ string, _ map[string]any) (*HeraldRenderedContent, error)
- func (h *NoopHerald) ResetDefaultTemplates(_ context.Context, _ string) error
- func (h *NoopHerald) SeedDefaultTemplates(_ context.Context, _ string) error
- func (h *NoopHerald) Send(_ context.Context, req *HeraldSendRequest) error
- func (h *NoopHerald) TestSend(_ context.Context, _ *HeraldSendRequest) error
- func (h *NoopHerald) UpdateTemplate(_ context.Context, _ *HeraldTemplate) error
- func (h *NoopHerald) UpdateVersion(_ context.Context, _ *HeraldTemplateVersion) error
- type NoopKeyManager
- type NoopLedger
- type NoopMailer
- type NoopRelay
- type NoopSMSSender
- type NoopVault
- type SMSMessage
- type SMSSender
- type StrictEncryptor
- type ValidatedKey
- type Vault
- type VaultFunc
- type WebhookDefinition
- type WebhookEvent
Constants ¶
const ( SeverityInfo = "info" SeverityWarning = "warning" SeverityCritical = "critical" )
Severity constants.
const ( OutcomeSuccess = "success" OutcomeFailure = "failure" )
Outcome constants.
const ( HeraldCategoryAuth = "auth" HeraldCategoryTransactional = "transactional" HeraldCategoryMarketing = "marketing" HeraldCategorySystem = "system" )
Template category constants.
Variables ¶
var ( // ErrUnknownKeyID is returned when a v2 envelope names a key the ring // does not hold: the operator retired a key that still has rows. ErrUnknownKeyID = errors.New("bridge: keyring: envelope names an unknown key id") // ErrPlaintextRefused is returned by a strict encryptor asked to decrypt // a value that carries no envelope at all. ErrPlaintextRefused = errors.New("bridge: strict encryptor refuses a value with no envelope") // ErrBadKeyID is returned when a key id is empty or contains a // separator the envelope reserves. ErrBadKeyID = errors.New("bridge: keyring: key id must be non-empty and free of ':' and ','") )
var ErrDispatchNotAvailable = errors.New("bridge: dispatch not available (standalone mode)")
ErrDispatchNotAvailable is returned when the dispatch bridge is not configured.
var ErrEndpointNotFound = errors.New("bridge: endpoint not found")
ErrEndpointNotFound is returned by MemoryRelay for an unknown endpoint.
var ErrHeraldNotAvailable = errors.New("authsome: herald not available")
ErrHeraldNotAvailable is returned when Herald is not configured.
var ErrInvalidKeyLength = errors.New("bridge: AES-256 key must be exactly 32 bytes")
ErrInvalidKeyLength is returned when a key passed to NewAESGCMEncryptor is not exactly 32 bytes (AES-256).
var ErrKeyManagerNotAvailable = errors.New("bridge: key manager not available (standalone mode)")
ErrKeyManagerNotAvailable is returned when key management is not configured.
var ErrLedgerNotAvailable = errors.New("bridge: ledger not available (standalone mode)")
ErrLedgerNotAvailable is returned when the ledger bridge is not configured.
var ErrMailerNotAvailable = errors.New("authsome: mailer not available")
ErrMailerNotAvailable is returned when no mailer bridge is configured.
var ErrSMSNotAvailable = errors.New("authsome: SMS sender not available")
ErrSMSNotAvailable is returned when no SMS bridge is configured.
var ErrVaultNotAvailable = errors.New("bridge: vault not available (standalone mode)")
ErrVaultNotAvailable is returned when vault bridge is not configured.
Functions ¶
func LegacyPlaintextReads ¶
func LegacyPlaintextReads() uint64
LegacyPlaintextReads reports how many unenveloped values have been passed through by AES-GCM encryptors in this process since it started. Zero over a full cycle of the workload means every row has been rewritten and strict mode can be turned on.
Types ¶
type AESGCMEncryptor ¶
type AESGCMEncryptor struct {
// contains filtered or unexported fields
}
AESGCMEncryptor implements Encryptor using AES-256-GCM with a 12-byte random nonce per encryption. Decrypt is tolerant of legacy plaintext (no v1: prefix) and returns it unchanged so existing rows remain readable during the at-rest encryption rollout.
func (*AESGCMEncryptor) Decrypt ¶
func (e *AESGCMEncryptor) Decrypt(ciphertext []byte) ([]byte, error)
Decrypt accepts either a "v1:"-prefixed envelope (decodes & authenticates) or legacy plaintext (no recognized prefix), which it returns unchanged. This passthrough is intentional: it is the migration path for rows written before at-rest encryption was deployed.
type AuditEvent ¶
type AuditEvent struct {
Action string `json:"action"`
Resource string `json:"resource"`
ResourceID string `json:"resource_id,omitempty"`
ActorID string `json:"actor_id,omitempty"`
Tenant string `json:"tenant,omitempty"`
OrgID string `json:"org_id,omitempty"`
Outcome string `json:"outcome"`
Severity string `json:"severity"`
Category string `json:"category,omitempty"`
Metadata map[string]string `json:"metadata,omitempty"`
Reason string `json:"reason,omitempty"`
// Request correlation. Populated by the hook bus from the request
// context; an event recorded outside a request leaves them empty.
IP string `json:"ip,omitempty"`
UserAgent string `json:"user_agent,omitempty"`
RequestID string `json:"request_id,omitempty"`
SessionID string `json:"session_id,omitempty"`
}
AuditEvent is a local representation of an audit event.
type Authorizer ¶
type Authorizer interface {
Check(ctx context.Context, req *AuthzRequest) (*AuthzResult, error)
}
Authorizer is a local authorization interface. Implementations perform access control checks (e.g., via warden).
type AuthorizerFunc ¶
type AuthorizerFunc func(ctx context.Context, req *AuthzRequest) (*AuthzResult, error)
AuthorizerFunc is an adapter to use a plain function as an Authorizer.
func (AuthorizerFunc) Check ¶
func (f AuthorizerFunc) Check(ctx context.Context, req *AuthzRequest) (*AuthzResult, error)
Check implements Authorizer.
type AuthzRequest ¶
type AuthzRequest struct {
Subject string `json:"subject"`
Action string `json:"action"`
Resource string `json:"resource"`
Tenant string `json:"tenant,omitempty"`
}
AuthzRequest represents an authorization check.
type AuthzResult ¶
AuthzResult represents the outcome of an authorization check.
type BusChronicle ¶
type BusChronicle struct {
// contains filtered or unexported fields
}
BusChronicle is a Chronicle that records through the engine's hook bus instead of writing to the audit sink directly. Plugins and middleware hold a Chronicle for their audit helpers; giving them this one means every record they make is enriched with request correlation and observed by metrics and notifications exactly like an engine event, and reaches the real sink through the engine's single subscriber.
func NewBusChronicle ¶
func NewBusChronicle(bus *hook.Bus) *BusChronicle
NewBusChronicle returns a Chronicle backed by bus. A nil bus yields an inert Chronicle so callers keep their nil-safe shape.
func (*BusChronicle) Record ¶
func (c *BusChronicle) Record(ctx context.Context, event *AuditEvent) error
Record implements Chronicle. The bus logs sink failures; Record itself never fails, matching the best-effort contract every plugin helper has.
type Chronicle ¶
type Chronicle interface {
Record(ctx context.Context, event *AuditEvent) error
}
Chronicle is a local audit interface. Implementations record auth events to an audit trail backend (e.g., chronicle).
type ChronicleFunc ¶
type ChronicleFunc func(ctx context.Context, event *AuditEvent) error
ChronicleFunc is an adapter to use a plain function as a Chronicle.
func (ChronicleFunc) Record ¶
func (f ChronicleFunc) Record(ctx context.Context, event *AuditEvent) error
Record implements Chronicle.
type CreateKeyInput ¶
type CreateKeyInput struct {
Name string `json:"name"`
Owner string `json:"owner"`
Environment string `json:"environment,omitempty"`
Scopes []string `json:"scopes,omitempty"`
Metadata map[string]string `json:"metadata,omitempty"`
}
CreateKeyInput represents the input for key creation.
type Dispatcher ¶
type Dispatcher interface {
// Enqueue submits a background job for immediate processing.
Enqueue(ctx context.Context, jobName string, payload []byte) error
// Schedule submits a background job for processing at a future time.
Schedule(ctx context.Context, jobName string, payload []byte, runAt time.Time) error
}
Dispatcher is a local job/task queue interface. Implementations enqueue background jobs and schedule future work via the dispatch extension.
type EmailMessage ¶
type EmailMessage struct {
To []string `json:"to"`
From string `json:"from,omitempty"`
Subject string `json:"subject"`
HTML string `json:"html,omitempty"`
Text string `json:"text,omitempty"`
}
EmailMessage represents a transactional email.
type Encryptor ¶
type Encryptor interface {
Encrypt(plaintext []byte) ([]byte, error)
Decrypt(ciphertext []byte) ([]byte, error)
}
Encryptor encrypts and decrypts opaque byte payloads. Implementations must be deterministic about the format (envelope) so plaintext rows from before encryption was deployed can be migrated transparently.
Concrete implementations:
- NoopEncryptor: identity. Suitable for tests / explicit-no-encryption dev configs. Operators MUST NOT ship this in production.
- AESGCMEncryptor: AES-256-GCM with a versioned envelope. See aesgcm.go.
func NewAESGCMEncryptor ¶
NewAESGCMEncryptor constructs an AES-256-GCM Encryptor. The key must be exactly 32 bytes. Sourcing: typically AUTHSOME_TOKEN_ENCRYPTION_KEY decoded from 64 hex chars.
type EndpointInput ¶
type EndpointInput struct {
// TenantID is the Relay tenant the endpoint belongs to. Authsome uses
// the app id, which is also what it sends events under, so an endpoint
// only ever receives its own app's events.
TenantID string
URL string
Description string
// Secret signs deliveries. Empty on create lets Relay generate one.
Secret string
// EventTypes are the event names (or glob patterns) delivered.
EventTypes []string
Metadata map[string]string
}
EndpointInput describes a delivery endpoint to create or replace.
type EndpointRelay ¶
type EndpointRelay interface {
CreateEndpoint(ctx context.Context, in EndpointInput) (string, error)
UpdateEndpoint(ctx context.Context, endpointID string, in EndpointInput) error
SetEndpointEnabled(ctx context.Context, endpointID string, enabled bool) error
// DeleteEndpoint removes the endpoint; an endpoint that is already gone
// is not an error.
DeleteEndpoint(ctx context.Context, endpointID string) error
// RotateEndpointSecret gives the endpoint a fresh secret and returns it.
RotateEndpointSecret(ctx context.Context, endpointID string) (string, error)
}
EndpointRelay is offered by a relay that lets authsome manage delivery endpoints, so a webhook registered with authsome is a real endpoint that delivers. Every id is the relay's own endpoint id, kept on the webhook row. A relay that only sends (EventRelayFunc, the no-op relay) does not implement it, and webhooks are then unavailable rather than silently inert.
type EventRelay ¶
type EventRelay interface {
// Send emits an auth event for webhook delivery.
Send(ctx context.Context, event *WebhookEvent) error
// RegisterEventTypes registers authsome's webhook event catalog.
RegisterEventTypes(ctx context.Context, defs []WebhookDefinition) error
}
EventRelay is a local webhook/event relay interface. Implementations deliver auth events for webhook delivery (e.g., via relay).
type EventRelayFunc ¶
type EventRelayFunc func(ctx context.Context, event *WebhookEvent) error
EventRelayFunc is an adapter to use a plain function as an EventRelay send-only implementation.
func (EventRelayFunc) RegisterEventTypes ¶
func (f EventRelayFunc) RegisterEventTypes(context.Context, []WebhookDefinition) error
RegisterEventTypes is a no-op for function adapters.
func (EventRelayFunc) Send ¶
func (f EventRelayFunc) Send(ctx context.Context, event *WebhookEvent) error
Send implements EventRelay.
type Herald ¶
type Herald interface {
// Send sends a notification via a specific channel.
Send(ctx context.Context, req *HeraldSendRequest) error
// Notify sends a notification across multiple channels using a template.
Notify(ctx context.Context, req *HeraldNotifyRequest) error
}
Herald is the bridge interface for the Herald notification system. It provides a unified API for sending notifications across multiple channels.
type HeraldNotifyRequest ¶
type HeraldNotifyRequest struct {
AppID string `json:"app_id"`
EnvID string `json:"env_id,omitempty"`
OrgID string `json:"org_id,omitempty"`
UserID string `json:"user_id,omitempty"`
Template string `json:"template"`
Locale string `json:"locale,omitempty"`
To []string `json:"to"`
Data map[string]any `json:"data,omitempty"`
Channels []string `json:"channels"`
Async bool `json:"async,omitempty"`
Metadata map[string]string `json:"metadata,omitempty"`
}
HeraldNotifyRequest describes a multi-channel notification using a template.
type HeraldRenderedContent ¶
type HeraldRenderedContent struct {
Subject string `json:"subject,omitempty"`
HTML string `json:"html,omitempty"`
Text string `json:"text,omitempty"`
Title string `json:"title,omitempty"`
}
HeraldRenderedContent holds fully rendered template output.
type HeraldSendRequest ¶
type HeraldSendRequest struct {
AppID string `json:"app_id"`
EnvID string `json:"env_id,omitempty"`
OrgID string `json:"org_id,omitempty"`
UserID string `json:"user_id,omitempty"`
Channel string `json:"channel"`
Template string `json:"template"`
Locale string `json:"locale,omitempty"`
To []string `json:"to"`
Data map[string]any `json:"data,omitempty"`
Async bool `json:"async,omitempty"`
Metadata map[string]string `json:"metadata,omitempty"`
}
HeraldSendRequest describes a notification to send on a single channel.
type HeraldTemplate ¶
type HeraldTemplate struct {
ID string `json:"id"`
AppID string `json:"app_id"`
Slug string `json:"slug"`
Name string `json:"name"`
Channel string `json:"channel"`
Category string `json:"category"`
Variables []HeraldTemplateVariable `json:"variables,omitempty"`
Versions []HeraldTemplateVersion `json:"versions,omitempty"`
IsSystem bool `json:"is_system"`
Enabled bool `json:"enabled"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
HeraldTemplate represents a notification template with locale-specific versions.
type HeraldTemplateManager ¶
type HeraldTemplateManager interface {
// Template CRUD
ListTemplates(ctx context.Context, appID string) ([]*HeraldTemplate, error)
GetTemplate(ctx context.Context, templateID string) (*HeraldTemplate, error)
CreateTemplate(ctx context.Context, t *HeraldTemplate) error
UpdateTemplate(ctx context.Context, t *HeraldTemplate) error
DeleteTemplate(ctx context.Context, templateID string) error
// Version management
CreateVersion(ctx context.Context, v *HeraldTemplateVersion) error
UpdateVersion(ctx context.Context, v *HeraldTemplateVersion) error
DeleteVersion(ctx context.Context, versionID string) error
// Preview renders a template with sample data without sending.
RenderTemplate(ctx context.Context, templateID string, locale string, data map[string]any) (*HeraldRenderedContent, error)
// TestSend sends a test notification to a recipient.
TestSend(ctx context.Context, req *HeraldSendRequest) error
// SeedDefaultTemplates creates default system templates if they don't exist.
// Existing templates (including customised ones) are left untouched.
SeedDefaultTemplates(ctx context.Context, appID string) error
// ResetDefaultTemplates deletes all system templates and re-seeds defaults.
// Custom (non-system) templates are preserved.
ResetDefaultTemplates(ctx context.Context, appID string) error
}
HeraldTemplateManager provides template CRUD, preview, and test send operations. Implementations can be discovered via type assertion on a Herald bridge.
type HeraldTemplateVariable ¶
type HeraldTemplateVariable struct {
Name string `json:"name"`
Type string `json:"type"`
Required bool `json:"required"`
Default string `json:"default,omitempty"`
Description string `json:"description,omitempty"`
}
HeraldTemplateVariable describes an expected template variable.
type HeraldTemplateVersion ¶
type HeraldTemplateVersion struct {
ID string `json:"id"`
TemplateID string `json:"template_id"`
Locale string `json:"locale"`
Subject string `json:"subject,omitempty"`
HTML string `json:"html,omitempty"`
Text string `json:"text,omitempty"`
Title string `json:"title,omitempty"`
Active bool `json:"active"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
HeraldTemplateVersion represents a locale-specific content version.
type KeyManager ¶
type KeyManager interface {
CreateKey(ctx context.Context, input *CreateKeyInput) (*KeyResult, error)
ValidateKey(ctx context.Context, rawKey string) (*ValidatedKey, error)
RevokeKey(ctx context.Context, keyID string) error
}
KeyManager is a local key management interface. Implementations create, validate, and revoke keys (e.g., via keysmith).
type KeyResult ¶
type KeyResult struct {
ID string `json:"id"`
RawKey string `json:"raw_key"` // Only returned on creation
}
KeyResult represents a created key.
type Keyring ¶
type Keyring struct {
// contains filtered or unexported fields
}
Keyring is an Encryptor over several AES-256-GCM keys. New values are sealed under the writer key and tagged with its id; values sealed under any key in the ring decrypt, so a rotation is: add the new key as writer, keep the old one until every row has been rewritten, then drop it.
Decrypt also accepts the single-key "v1:" envelope, trying each key in the ring until one authenticates, so a deployment that moves from AUTHSOME_TOKEN_ENCRYPTION_KEY to a ring keeps reading its rows. Values with no envelope pass through unchanged, the migration path for rows written before at-rest encryption was deployed; wrap the ring in NewStrict once none remain.
func NewKeyring ¶
NewKeyring builds a ring from key ids to 32-byte keys. writer names the key that seals new values and must be in keys. order fixes the sequence in which v1 envelopes are tried; callers pass the ids in the order the operator listed them.
func (*Keyring) Decrypt ¶
Decrypt opens a v2 envelope under the key it names, a v1 envelope under whichever ring key authenticates it, and passes anything else through as legacy plaintext.
type Ledger ¶
type Ledger interface {
// RecordUsage records a usage event for a metered feature.
RecordUsage(ctx context.Context, featureKey string, quantity int64) error
// CheckEntitlement checks whether a tenant is entitled to use a feature.
// Returns allowed=true if the feature is accessible, false otherwise.
CheckEntitlement(ctx context.Context, featureKey string) (allowed bool, err error)
}
Ledger is a local billing/metering interface. Implementations record usage events and check feature entitlements via the ledger extension.
type Mailer ¶
type Mailer interface {
// SendEmail delivers a transactional email.
SendEmail(ctx context.Context, msg *EmailMessage) error
}
Mailer is a local email sending interface. Implementations deliver transactional emails (welcome, verification, password reset, invitation).
type MailerFunc ¶
type MailerFunc func(ctx context.Context, msg *EmailMessage) error
MailerFunc is an adapter to use a plain function as a Mailer.
func (MailerFunc) SendEmail ¶
func (f MailerFunc) SendEmail(ctx context.Context, msg *EmailMessage) error
SendEmail implements Mailer.
type MemoryChronicle ¶
type MemoryChronicle struct {
// contains filtered or unexported fields
}
MemoryChronicle records audit events in memory. It exists for tests and for the standalone examples; production wiring requires a real Chronicle.
func NewMemoryChronicle ¶
func NewMemoryChronicle() *MemoryChronicle
NewMemoryChronicle returns an empty recorder.
func (*MemoryChronicle) Events ¶
func (m *MemoryChronicle) Events() []*AuditEvent
Events returns a copy of everything recorded so far.
func (*MemoryChronicle) FailWith ¶
func (m *MemoryChronicle) FailWith(err error)
FailWith makes every later Record return err; nil restores success.
func (*MemoryChronicle) Record ¶
func (m *MemoryChronicle) Record(_ context.Context, event *AuditEvent) error
Record implements Chronicle.
func (*MemoryChronicle) Reset ¶
func (m *MemoryChronicle) Reset()
Reset forgets every recorded event.
type MemoryEndpoint ¶
type MemoryEndpoint struct {
Input EndpointInput
Enabled bool
}
MemoryEndpoint is one endpoint a MemoryRelay holds.
type MemoryRelay ¶
type MemoryRelay struct {
// contains filtered or unexported fields
}
MemoryRelay is an EventRelay and EndpointRelay that keeps everything in memory: the events sent and the endpoints managed. It is for tests and for development without a Relay, where it lets webhook registration work end to end while delivering nothing.
func NewMemoryRelay ¶
func NewMemoryRelay() *MemoryRelay
NewMemoryRelay returns an empty MemoryRelay.
func (*MemoryRelay) CreateEndpoint ¶
func (m *MemoryRelay) CreateEndpoint(_ context.Context, in EndpointInput) (string, error)
CreateEndpoint implements EndpointRelay. An empty secret is replaced by a generated one, as Relay does.
func (*MemoryRelay) DeleteEndpoint ¶
func (m *MemoryRelay) DeleteEndpoint(_ context.Context, endpointID string) error
DeleteEndpoint implements EndpointRelay; an unknown id is not an error.
func (*MemoryRelay) Endpoint ¶
func (m *MemoryRelay) Endpoint(endpointID string) (MemoryEndpoint, bool)
Endpoint returns a copy of the endpoint under id.
func (*MemoryRelay) EndpointCount ¶
func (m *MemoryRelay) EndpointCount() int
EndpointCount returns how many endpoints the relay holds.
func (*MemoryRelay) Events ¶
func (m *MemoryRelay) Events() []*WebhookEvent
Events returns a copy of every event sent so far.
func (*MemoryRelay) RegisterEventTypes ¶
func (*MemoryRelay) RegisterEventTypes(context.Context, []WebhookDefinition) error
RegisterEventTypes implements EventRelay as a no-op.
func (*MemoryRelay) RotateEndpointSecret ¶
RotateEndpointSecret implements EndpointRelay.
func (*MemoryRelay) Send ¶
func (m *MemoryRelay) Send(_ context.Context, event *WebhookEvent) error
Send implements EventRelay by recording the event.
func (*MemoryRelay) SetEndpointEnabled ¶
SetEndpointEnabled implements EndpointRelay.
func (*MemoryRelay) UpdateEndpoint ¶
func (m *MemoryRelay) UpdateEndpoint(_ context.Context, endpointID string, in EndpointInput) error
UpdateEndpoint implements EndpointRelay. An empty secret keeps the current one.
type MetricsCollector ¶
type MetricsCollector interface {
// RecordEvent records an authentication event metric.
RecordEvent(action, resource, outcome, tenant string, duration time.Duration)
// IncrementGauge adjusts a named gauge (e.g., active sessions).
IncrementGauge(name, tenant string, delta int)
// IncrementCounter adds one to a named counter. Used for operational
// signals such as audit.record.failed.
IncrementCounter(name, tenant string)
}
MetricsCollector is an optional interface for collecting authentication metrics. Implementations may export to Prometheus, OpenTelemetry, or any other observability backend.
The engine registers a hook.Handler that delegates events to the MetricsCollector when configured via WithMetrics().
type NoopDispatcher ¶
type NoopDispatcher struct{}
NoopDispatcher is a standalone Dispatcher stub that drops all jobs.
func NewNoopDispatcher ¶
func NewNoopDispatcher() *NoopDispatcher
NewNoopDispatcher creates a Dispatcher that silently drops jobs.
type NoopEncryptor ¶
type NoopEncryptor struct{}
NoopEncryptor is a passthrough Encryptor. It returns the input unchanged for both Encrypt and Decrypt. Use only in tests or when an operator has explicitly opted out of at-rest encryption (NOT recommended in production).
type NoopHerald ¶
NoopHerald is a standalone Herald stub that silently drops notifications.
func NewNoopHerald ¶
func NewNoopHerald(logger log.Logger) *NoopHerald
NewNoopHerald creates a Herald that logs notifications at debug level and drops them.
func (*NoopHerald) CreateTemplate ¶
func (h *NoopHerald) CreateTemplate(_ context.Context, _ *HeraldTemplate) error
CreateTemplate implements HeraldTemplateManager.
func (*NoopHerald) CreateVersion ¶
func (h *NoopHerald) CreateVersion(_ context.Context, _ *HeraldTemplateVersion) error
CreateVersion implements HeraldTemplateManager.
func (*NoopHerald) DeleteTemplate ¶
func (h *NoopHerald) DeleteTemplate(_ context.Context, _ string) error
DeleteTemplate implements HeraldTemplateManager.
func (*NoopHerald) DeleteVersion ¶
func (h *NoopHerald) DeleteVersion(_ context.Context, _ string) error
DeleteVersion implements HeraldTemplateManager.
func (*NoopHerald) GetTemplate ¶
func (h *NoopHerald) GetTemplate(_ context.Context, _ string) (*HeraldTemplate, error)
GetTemplate implements HeraldTemplateManager.
func (*NoopHerald) ListTemplates ¶
func (h *NoopHerald) ListTemplates(_ context.Context, _ string) ([]*HeraldTemplate, error)
ListTemplates implements HeraldTemplateManager.
func (*NoopHerald) Notify ¶
func (h *NoopHerald) Notify(_ context.Context, req *HeraldNotifyRequest) error
Notify implements Herald.
func (*NoopHerald) RenderTemplate ¶
func (h *NoopHerald) RenderTemplate(_ context.Context, _, _ string, _ map[string]any) (*HeraldRenderedContent, error)
RenderTemplate implements HeraldTemplateManager.
func (*NoopHerald) ResetDefaultTemplates ¶
func (h *NoopHerald) ResetDefaultTemplates(_ context.Context, _ string) error
ResetDefaultTemplates implements HeraldTemplateManager.
func (*NoopHerald) SeedDefaultTemplates ¶
func (h *NoopHerald) SeedDefaultTemplates(_ context.Context, _ string) error
SeedDefaultTemplates implements HeraldTemplateManager.
func (*NoopHerald) Send ¶
func (h *NoopHerald) Send(_ context.Context, req *HeraldSendRequest) error
Send implements Herald.
func (*NoopHerald) TestSend ¶
func (h *NoopHerald) TestSend(_ context.Context, _ *HeraldSendRequest) error
TestSend implements HeraldTemplateManager.
func (*NoopHerald) UpdateTemplate ¶
func (h *NoopHerald) UpdateTemplate(_ context.Context, _ *HeraldTemplate) error
UpdateTemplate implements HeraldTemplateManager.
func (*NoopHerald) UpdateVersion ¶
func (h *NoopHerald) UpdateVersion(_ context.Context, _ *HeraldTemplateVersion) error
UpdateVersion implements HeraldTemplateManager.
type NoopKeyManager ¶
type NoopKeyManager struct{}
NoopKeyManager is a standalone KeyManager stub that returns errors.
func NewNoopKeyManager ¶
func NewNoopKeyManager() *NoopKeyManager
NewNoopKeyManager creates a KeyManager that does not manage keys.
func (*NoopKeyManager) CreateKey ¶
func (k *NoopKeyManager) CreateKey(_ context.Context, _ *CreateKeyInput) (*KeyResult, error)
func (*NoopKeyManager) RevokeKey ¶
func (k *NoopKeyManager) RevokeKey(_ context.Context, _ string) error
func (*NoopKeyManager) ValidateKey ¶
func (k *NoopKeyManager) ValidateKey(_ context.Context, _ string) (*ValidatedKey, error)
type NoopLedger ¶
type NoopLedger struct{}
NoopLedger is a standalone Ledger stub that returns not-available errors.
func NewNoopLedger ¶
func NewNoopLedger() *NoopLedger
NewNoopLedger creates a Ledger that returns errors for all operations.
func (*NoopLedger) CheckEntitlement ¶
func (*NoopLedger) RecordUsage ¶
type NoopMailer ¶
NoopMailer is a standalone Mailer stub that logs and drops emails.
func NewNoopMailer ¶
func NewNoopMailer(logger log.Logger) *NoopMailer
NewNoopMailer creates a Mailer that logs emails at debug level and drops them.
func (*NoopMailer) SendEmail ¶
func (m *NoopMailer) SendEmail(_ context.Context, msg *EmailMessage) error
SendEmail implements Mailer.
type NoopRelay ¶
NoopRelay is a standalone EventRelay stub that silently drops events.
func NewNoopRelay ¶
NewNoopRelay creates an EventRelay that logs events at debug level and drops them.
func (*NoopRelay) RegisterEventTypes ¶
func (r *NoopRelay) RegisterEventTypes(_ context.Context, _ []WebhookDefinition) error
RegisterEventTypes implements EventRelay.
type NoopSMSSender ¶
type NoopSMSSender struct{}
NoopSMSSender is a standalone SMS stub that returns ErrSMSNotAvailable.
func NewNoopSMSSender ¶
func NewNoopSMSSender() *NoopSMSSender
NewNoopSMSSender creates an SMSSender that returns errors for all operations.
func (*NoopSMSSender) SendSMS ¶
func (s *NoopSMSSender) SendSMS(_ context.Context, _ *SMSMessage) error
SendSMS implements SMSSender.
type NoopVault ¶
type NoopVault struct{}
NoopVault is a standalone Vault stub that returns ErrVaultNotAvailable.
func NewNoopVault ¶
func NewNoopVault() *NoopVault
NewNoopVault creates a Vault that returns errors for all operations.
func (*NoopVault) IsFeatureEnabled ¶
type SMSMessage ¶
SMSMessage represents an SMS to be sent.
type SMSSender ¶
type SMSSender interface {
// SendSMS sends an SMS message to the given phone number.
SendSMS(ctx context.Context, msg *SMSMessage) error
}
SMSSender sends SMS messages for MFA verification.
type StrictEncryptor ¶
type StrictEncryptor struct {
Inner Encryptor
}
StrictEncryptor wraps an Encryptor and refuses to decrypt a value that carries no envelope. Turn it on once every legacy plaintext row has been rewritten: from then on a value that reads back without an envelope is a sign of tampering or of a write that bypassed encryption, not a leftover.
type ValidatedKey ¶
type ValidatedKey struct {
ID string `json:"id"`
Name string `json:"name"`
Owner string `json:"owner"`
Environment string `json:"environment,omitempty"`
Scopes []string `json:"scopes,omitempty"`
Metadata map[string]string `json:"metadata,omitempty"`
}
ValidatedKey represents a validated key with resolved metadata.
type Vault ¶
type Vault interface {
// GetSecret returns a decrypted secret value by key.
GetSecret(ctx context.Context, key string) ([]byte, error)
// SetSecret creates or updates an encrypted secret.
SetSecret(ctx context.Context, key string, value []byte) error
// IsFeatureEnabled evaluates a boolean feature flag.
IsFeatureEnabled(ctx context.Context, flag string) bool
// GetConfig returns a configuration value by key.
GetConfig(ctx context.Context, key string) (string, error)
}
Vault is a local secrets / feature-flag / config interface. Implementations retrieve secrets, check feature flags, and read configuration from a vault backend (e.g., the vault extension).
type VaultFunc ¶
VaultFunc is an adapter to use a plain function as a GetSecret call. For full Vault implementations, use the vaultadapter package.
type WebhookDefinition ¶
type WebhookDefinition struct {
Name string `json:"name"`
Description string `json:"description"`
Group string `json:"group"`
}
WebhookDefinition describes a webhook event type for catalog registration.
func WebhookEventCatalog ¶
func WebhookEventCatalog() []WebhookDefinition
WebhookEventCatalog returns the default authsome webhook event definitions.
type WebhookEvent ¶
type WebhookEvent struct {
Type string `json:"type"`
TenantID string `json:"tenant_id,omitempty"`
EnvID string `json:"env_id,omitempty"`
Data map[string]string `json:"data,omitempty"`
IdempotencyKey string `json:"idempotency_key,omitempty"`
}
WebhookEvent represents an auth event for webhook delivery.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package chronicleadapter bridges AuthSome audit events to the Chronicle extension.
|
Package chronicleadapter bridges AuthSome audit events to the Chronicle extension. |
|
Package dispatchadapter adapts the dispatch extension's engine to the authsome bridge.Dispatcher interface.
|
Package dispatchadapter adapts the dispatch extension's engine to the authsome bridge.Dispatcher interface. |
|
Package heraldadapter bridges AuthSome notification requests to the Herald extension.
|
Package heraldadapter bridges AuthSome notification requests to the Herald extension. |
|
Package keysmithadapter bridges AuthSome key management to the Keysmith extension.
|
Package keysmithadapter bridges AuthSome key management to the Keysmith extension. |
|
Package ledgeradapter adapts the ledger extension to the authsome bridge.Ledger interface.
|
Package ledgeradapter adapts the ledger extension to the authsome bridge.Ledger interface. |
|
Package maileradapter provides bridge.Mailer implementations for transactional email delivery (Resend HTTP API and standard SMTP).
|
Package maileradapter provides bridge.Mailer implementations for transactional email delivery (Resend HTTP API and standard SMTP). |
|
Package metricsadapter implements bridge.MetricsCollector over a go-utils metrics registry, such as a Forge app's.
|
Package metricsadapter implements bridge.MetricsCollector over a go-utils metrics registry, such as a Forge app's. |
|
Package relayadapter bridges AuthSome webhook events to the Relay extension.
|
Package relayadapter bridges AuthSome webhook events to the Relay extension. |
|
Package smsadapter provides SMS sender implementations.
|
Package smsadapter provides SMS sender implementations. |
|
Package vaultadapter adapts the vault extension's services to the authsome bridge.Vault interface.
|
Package vaultadapter adapts the vault extension's services to the authsome bridge.Vault interface. |
|
Package wardenadapter bridges AuthSome authorization to the Warden extension.
|
Package wardenadapter bridges AuthSome authorization to the Warden extension. |