plugin

package
v1.9.0 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package plugin defines lifecycle hook interfaces for Keysmith plugins.

Plugins extend Keysmith by implementing opt-in lifecycle hook interfaces. A plugin must implement the base Plugin interface (which requires only a Name), and may additionally implement any combination of the hook interfaces below.

Available key lifecycle hooks:

Available policy lifecycle hooks:

Shutdown hook:

  • Shutdown — fired during graceful engine shutdown

Example plugin:

type myPlugin struct{}

func (p *myPlugin) Name() string { return "my-plugin" }

func (p *myPlugin) OnKeyCreated(ctx context.Context, k *key.Key) error {
    log.Println("key created:", k.ID)
    return nil
}

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type KeyCreateFailed

type KeyCreateFailed interface {
	OnKeyCreateFailed(ctx context.Context, k *key.Key, err error) error
}

KeyCreateFailed is called when key creation fails.

type KeyCreated

type KeyCreated interface {
	OnKeyCreated(ctx context.Context, k *key.Key) error
}

KeyCreated is called when a key is created.

type KeyExpired

type KeyExpired interface {
	OnKeyExpired(ctx context.Context, k *key.Key) error
}

KeyExpired is called when a key is found to be expired during validation.

type KeyRateLimited

type KeyRateLimited interface {
	OnKeyRateLimited(ctx context.Context, k *key.Key) error
}

KeyRateLimited is called when a key exceeds its rate limit.

type KeyReactivated

type KeyReactivated interface {
	OnKeyReactivated(ctx context.Context, k *key.Key) error
}

KeyReactivated is called when a suspended key is reactivated.

type KeyRevoked

type KeyRevoked interface {
	OnKeyRevoked(ctx context.Context, k *key.Key, reason string) error
}

KeyRevoked is called when a key is revoked.

type KeyRotated

type KeyRotated interface {
	OnKeyRotated(ctx context.Context, k *key.Key, rec *rotation.Record) error
}

KeyRotated is called when a key is rotated.

type KeySuspended

type KeySuspended interface {
	OnKeySuspended(ctx context.Context, k *key.Key) error
}

KeySuspended is called when a key is suspended.

type KeyValidated

type KeyValidated interface {
	OnKeyValidated(ctx context.Context, k *key.Key) error
}

KeyValidated is called when a key passes validation.

type KeyValidationFailed

type KeyValidationFailed interface {
	OnKeyValidationFailed(ctx context.Context, rawKey string, err error) error
}

KeyValidationFailed is called when key validation fails: the key is unknown or inactive. It is not called when the key store cannot answer or the context is cancelled, because the key was never judged.

type Manager

type Manager struct {
	// contains filtered or unexported fields
}

Manager holds registered plugins and dispatches lifecycle events.

func NewManager

func NewManager() *Manager

NewManager creates a new plugin manager.

func (*Manager) FireKeyCreateFailed

func (m *Manager) FireKeyCreateFailed(ctx context.Context, k *key.Key, createErr error) error

FireKeyCreateFailed dispatches to all plugins that implement KeyCreateFailed.

func (*Manager) FireKeyCreated

func (m *Manager) FireKeyCreated(ctx context.Context, k *key.Key) error

FireKeyCreated dispatches to all plugins that implement KeyCreated.

func (*Manager) FireKeyExpired

func (m *Manager) FireKeyExpired(ctx context.Context, k *key.Key) error

FireKeyExpired dispatches to all plugins that implement KeyExpired.

func (*Manager) FireKeyRateLimited

func (m *Manager) FireKeyRateLimited(ctx context.Context, k *key.Key) error

FireKeyRateLimited dispatches to all plugins that implement KeyRateLimited.

func (*Manager) FireKeyReactivated

func (m *Manager) FireKeyReactivated(ctx context.Context, k *key.Key) error

FireKeyReactivated dispatches to all plugins that implement KeyReactivated.

func (*Manager) FireKeyRevoked

func (m *Manager) FireKeyRevoked(ctx context.Context, k *key.Key, reason string) error

FireKeyRevoked dispatches to all plugins that implement KeyRevoked.

func (*Manager) FireKeyRotated

func (m *Manager) FireKeyRotated(ctx context.Context, k *key.Key, rec *rotation.Record) error

FireKeyRotated dispatches to all plugins that implement KeyRotated.

func (*Manager) FireKeySuspended

func (m *Manager) FireKeySuspended(ctx context.Context, k *key.Key) error

FireKeySuspended dispatches to all plugins that implement KeySuspended.

func (*Manager) FireKeyValidated

func (m *Manager) FireKeyValidated(ctx context.Context, k *key.Key) error

FireKeyValidated dispatches to all plugins that implement KeyValidated.

func (*Manager) FireKeyValidationFailed

func (m *Manager) FireKeyValidationFailed(ctx context.Context, rawKey string, validationErr error) error

FireKeyValidationFailed dispatches to all plugins that implement KeyValidationFailed.

func (*Manager) FirePolicyCreated

func (m *Manager) FirePolicyCreated(ctx context.Context, pol *policy.Policy) error

FirePolicyCreated dispatches to all plugins that implement PolicyCreated.

func (*Manager) FirePolicyDeleted

func (m *Manager) FirePolicyDeleted(ctx context.Context, polID id.PolicyID) error

FirePolicyDeleted dispatches to all plugins that implement PolicyDeleted.

func (*Manager) FirePolicyUpdated

func (m *Manager) FirePolicyUpdated(ctx context.Context, pol *policy.Policy) error

FirePolicyUpdated dispatches to all plugins that implement PolicyUpdated.

func (*Manager) FireShutdown

func (m *Manager) FireShutdown(ctx context.Context) error

FireShutdown dispatches to all plugins that implement Shutdown.

func (*Manager) Register

func (m *Manager) Register(p Plugin)

Register adds a plugin.

type Plugin

type Plugin interface {
	Name() string
}

Plugin is the base interface all Keysmith plugins must implement.

type PolicyCreated

type PolicyCreated interface {
	OnPolicyCreated(ctx context.Context, pol *policy.Policy) error
}

PolicyCreated is called when a policy is created.

type PolicyDeleted

type PolicyDeleted interface {
	OnPolicyDeleted(ctx context.Context, polID id.PolicyID) error
}

PolicyDeleted is called when a policy is deleted.

type PolicyUpdated

type PolicyUpdated interface {
	OnPolicyUpdated(ctx context.Context, pol *policy.Policy) error
}

PolicyUpdated is called when a policy is updated.

type Shutdown

type Shutdown interface {
	OnShutdown(ctx context.Context) error
}

Shutdown is called during graceful shutdown.

Jump to

Keyboard shortcuts

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