wardenhook

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: 4 Imported by: 0

Documentation

Overview

Package wardenhook bridges Keysmith key lifecycle events to Warden authorization. It defines a local WardenBridge interface so the package does not import Warden directly.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Extension

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

Extension bridges Keysmith key lifecycle events to Warden authorization. When a key is created with scopes, it syncs those scopes as Warden permissions and optionally assigns a Warden role to the API key subject.

func New

func New(bridge WardenBridge, opts ...Option) *Extension

New creates a Warden bridge extension.

func (*Extension) Name

func (e *Extension) Name() string

Name implements plugin.Plugin.

func (*Extension) OnKeyCreated

func (e *Extension) OnKeyCreated(ctx context.Context, k *key.Key) error

OnKeyCreated implements plugin.KeyCreated. Syncs key scopes to Warden permissions and optionally assigns a role.

func (*Extension) OnKeyRevoked

func (e *Extension) OnKeyRevoked(ctx context.Context, k *key.Key, _ string) error

OnKeyRevoked implements plugin.KeyRevoked. Removes the API key's Warden role assignment when the key is revoked.

type Option

type Option func(*Extension)

Option is a functional option for the Warden bridge extension.

func WithAutoAssign

func WithAutoAssign(v bool) Option

WithAutoAssign controls whether a Warden role is auto-assigned on key creation.

func WithDefaultRole

func WithDefaultRole(slug string) Option

WithDefaultRole sets the default Warden role slug for API keys.

func WithLogger

func WithLogger(l log.Logger) Option

WithLogger sets the logger.

type WardenBridge

type WardenBridge interface {
	// AssignRoleToAPIKey assigns a Warden role to an API key subject.
	AssignRoleToAPIKey(ctx context.Context, tenantID, keyID, roleSlug string) error
	// UnassignRoleFromAPIKey removes a Warden role from an API key subject.
	UnassignRoleFromAPIKey(ctx context.Context, tenantID, keyID string) error
	// SyncScopesToPermissions ensures Warden permissions exist for the given scopes.
	SyncScopesToPermissions(ctx context.Context, tenantID string, scopes []string) error
}

WardenBridge is the interface Warden must satisfy for Keysmith to sync scope-based role assignments. Defined locally to avoid importing Warden.

Jump to

Keyboard shortcuts

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