security

package
v0.0.0-...-6e98b77 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type KeyManager

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

KeyManager handles secure storage and rotation of cryptographic keys

func NewKeyManager

func NewKeyManager() *KeyManager

NewKeyManager creates a new key manager instance

func (*KeyManager) DeriveKey

func (km *KeyManager) DeriveKey(password, salt []byte, iterations, keyLen int) []byte

DeriveKey derives a key using PBKDF2

func (*KeyManager) GenerateKey

func (km *KeyManager) GenerateKey(id, description string, size int) (*KeyPair, error)

GenerateKey generates a new cryptographic key

func (*KeyManager) GenerateSalt

func (km *KeyManager) GenerateSalt(size int) ([]byte, error)

GenerateSalt generates a random salt

func (*KeyManager) GetActiveKey

func (km *KeyManager) GetActiveKey(id string) (*KeyPair, bool)

GetActiveKey returns the active key for a given ID

func (*KeyManager) GetKeyInfo

func (km *KeyManager) GetKeyInfo() map[string]map[string]interface{}

GetKeyInfo returns information about all keys

func (*KeyManager) RotateKey

func (km *KeyManager) RotateKey(id, description string, size int) error

RotateKey rotates a key by generating a new one and deactivating the old one

type KeyPair

type KeyPair struct {
	ID          string
	PublicKey   []byte
	PrivateKey  []byte
	CreatedAt   time.Time
	ExpiresAt   time.Time
	Active      bool
	Description string
}

KeyPair represents a cryptographic key with metadata

type SecurityMiddleware

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

SecurityMiddleware provides comprehensive security middleware

func NewSecurityMiddleware

func NewSecurityMiddleware(jwtSecret []byte, issuer string) *SecurityMiddleware

NewSecurityMiddleware creates a new security middleware instance

func (*SecurityMiddleware) AuthMiddleware

func (sm *SecurityMiddleware) AuthMiddleware(next http.HandlerFunc) http.HandlerFunc

AuthMiddleware provides JWT authentication middleware

func (*SecurityMiddleware) CORSMiddleware

func (sm *SecurityMiddleware) CORSMiddleware(next http.HandlerFunc) http.HandlerFunc

CORSMiddleware handles CORS headers

func (*SecurityMiddleware) CombinedMiddleware

func (sm *SecurityMiddleware) CombinedMiddleware(next http.HandlerFunc) http.HandlerFunc

CombinedMiddleware combines all security middleware

func (*SecurityMiddleware) GenerateServiceToken

func (sm *SecurityMiddleware) GenerateServiceToken(serviceName string, permissions []string, duration time.Duration) (string, error)

GenerateServiceToken generates a JWT token for a service

func (*SecurityMiddleware) GetActiveKey

func (sm *SecurityMiddleware) GetActiveKey(id string) (*KeyPair, bool)

GetActiveKey returns the active key from the key manager

func (*SecurityMiddleware) GetKeyManager

func (sm *SecurityMiddleware) GetKeyManager() *KeyManager

GetKeyManager returns the key manager instance

func (*SecurityMiddleware) RateLimitMiddleware

func (sm *SecurityMiddleware) RateLimitMiddleware(next http.HandlerFunc) http.HandlerFunc

RateLimitMiddleware provides rate limiting middleware

func (*SecurityMiddleware) RotateKey

func (sm *SecurityMiddleware) RotateKey(id, description string, size int) error

RotateKey rotates a key in the key manager

func (*SecurityMiddleware) SecurityHeadersMiddleware

func (sm *SecurityMiddleware) SecurityHeadersMiddleware(next http.HandlerFunc) http.HandlerFunc

SecurityHeadersMiddleware adds security headers to responses

Jump to

Keyboard shortcuts

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