plugin

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package plugin defines the foundational contracts and shared execution context for authentication plugins.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Context

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

Context represents the shared environment provided to plugins upon initialization, containing cryptographic tools, event buses, and a key-value store.

func NewContext

func NewContext(crypto CryptoUtils, bus EventBus.Bus) *Context

NewContext creates a new Context with the specified cryptographic utilities and event bus.

func (*Context) Crypto

func (c *Context) Crypto() CryptoUtils

Crypto returns the cryptographic utilities instance.

func (*Context) Events

func (c *Context) Events() EventBus.Bus

Events returns the shared EventBus instance for subscribing or publishing plugin lifecycle events.

func (*Context) Get

func (c *Context) Get(key string) (any, bool)

Get retrieves a value from the shared thread-safe context store by key.

func (*Context) Set

func (c *Context) Set(key string, value any)

Set stores a key-value pair in the shared thread-safe context store.

type CryptoUtils

type CryptoUtils interface {
	HashPassword(password string) (string, error)
	ComparePassword(hash, password string) bool
	GenerateRandomToken(length int) (string, error)
}

CryptoUtils defines cryptographic utility operations provided to plugins (hashing, comparison, random tokens).

type Plugin

type Plugin interface {
	// ID returns a unique identifier for the plugin (e.g., "email-password", "two-factor").
	ID() string
	// Init initializes the plugin with the shared execution context.
	Init(ctx *Context) error
}

Plugin defines the interface that all modular authentication plugins must implement.

Jump to

Keyboard shortcuts

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