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:
- KeyCreated — fired after a key is successfully created
- KeyCreateFailed — fired when key creation fails
- KeyValidated — fired after a key passes validation
- KeyValidationFailed: fired when key validation fails (not on a store outage)
- KeyRotated — fired after a key is rotated
- KeyRevoked — fired when a key is permanently revoked
- KeySuspended — fired when a key is temporarily suspended
- KeyReactivated — fired when a suspended key is reactivated
- KeyExpired — fired when a key is found expired during validation
- KeyRateLimited — fired when a key exceeds its rate limit
Available policy lifecycle hooks:
- PolicyCreated — fired after a policy is created
- PolicyUpdated — fired after a policy is updated
- PolicyDeleted — fired after a policy is deleted
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 ¶
- type KeyCreateFailed
- type KeyCreated
- type KeyExpired
- type KeyRateLimited
- type KeyReactivated
- type KeyRevoked
- type KeyRotated
- type KeySuspended
- type KeyValidated
- type KeyValidationFailed
- type Manager
- func (m *Manager) FireKeyCreateFailed(ctx context.Context, k *key.Key, createErr error) error
- func (m *Manager) FireKeyCreated(ctx context.Context, k *key.Key) error
- func (m *Manager) FireKeyExpired(ctx context.Context, k *key.Key) error
- func (m *Manager) FireKeyRateLimited(ctx context.Context, k *key.Key) error
- func (m *Manager) FireKeyReactivated(ctx context.Context, k *key.Key) error
- func (m *Manager) FireKeyRevoked(ctx context.Context, k *key.Key, reason string) error
- func (m *Manager) FireKeyRotated(ctx context.Context, k *key.Key, rec *rotation.Record) error
- func (m *Manager) FireKeySuspended(ctx context.Context, k *key.Key) error
- func (m *Manager) FireKeyValidated(ctx context.Context, k *key.Key) error
- func (m *Manager) FireKeyValidationFailed(ctx context.Context, rawKey string, validationErr error) error
- func (m *Manager) FirePolicyCreated(ctx context.Context, pol *policy.Policy) error
- func (m *Manager) FirePolicyDeleted(ctx context.Context, polID id.PolicyID) error
- func (m *Manager) FirePolicyUpdated(ctx context.Context, pol *policy.Policy) error
- func (m *Manager) FireShutdown(ctx context.Context) error
- func (m *Manager) Register(p Plugin)
- type Plugin
- type PolicyCreated
- type PolicyDeleted
- type PolicyUpdated
- type Shutdown
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 ¶
KeyCreated is called when a key is created.
type KeyExpired ¶
KeyExpired is called when a key is found to be expired during validation.
type KeyRateLimited ¶
KeyRateLimited is called when a key exceeds its rate limit.
type KeyReactivated ¶
KeyReactivated is called when a suspended key is reactivated.
type KeyRevoked ¶
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 ¶
KeySuspended is called when a key is suspended.
type KeyValidated ¶
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 (*Manager) FireKeyCreateFailed ¶
FireKeyCreateFailed dispatches to all plugins that implement KeyCreateFailed.
func (*Manager) FireKeyCreated ¶
FireKeyCreated dispatches to all plugins that implement KeyCreated.
func (*Manager) FireKeyExpired ¶
FireKeyExpired dispatches to all plugins that implement KeyExpired.
func (*Manager) FireKeyRateLimited ¶
FireKeyRateLimited dispatches to all plugins that implement KeyRateLimited.
func (*Manager) FireKeyReactivated ¶
FireKeyReactivated dispatches to all plugins that implement KeyReactivated.
func (*Manager) FireKeyRevoked ¶
FireKeyRevoked dispatches to all plugins that implement KeyRevoked.
func (*Manager) FireKeyRotated ¶
FireKeyRotated dispatches to all plugins that implement KeyRotated.
func (*Manager) FireKeySuspended ¶
FireKeySuspended dispatches to all plugins that implement KeySuspended.
func (*Manager) FireKeyValidated ¶
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 ¶
FirePolicyCreated dispatches to all plugins that implement PolicyCreated.
func (*Manager) FirePolicyDeleted ¶
FirePolicyDeleted dispatches to all plugins that implement PolicyDeleted.
func (*Manager) FirePolicyUpdated ¶
FirePolicyUpdated dispatches to all plugins that implement PolicyUpdated.
func (*Manager) FireShutdown ¶
FireShutdown dispatches to all plugins that implement Shutdown.
type Plugin ¶
type Plugin interface {
Name() string
}
Plugin is the base interface all Keysmith plugins must implement.
type PolicyCreated ¶
PolicyCreated is called when a policy is created.
type PolicyDeleted ¶
PolicyDeleted is called when a policy is deleted.
type PolicyUpdated ¶
PolicyUpdated is called when a policy is updated.