Documentation
¶
Overview ¶
Package security provides request signing and verification for API authentication. It supports multiple key formats and signature algorithms.
Index ¶
Constants ¶
View Source
const ( // KEY_FORMAT_HEX indicates hex-encoded keys. KEY_FORMAT_HEX = "hex" // KEY_FORMAT_JSON indicates JSON-formatted keys. KEY_FORMAT_JSON = "json" // KEY_FORMAT_BASE58 indicates Base58-encoded keys. KEY_FORMAT_BASE58 = "base58" // SIGNATURE_TYPE_SHA256 indicates SHA-256 hashing. SIGNATURE_TYPE_SHA256 = "SHA256" // SIGNATURE_TYPE_RIPEMD indicates RIPEMD-160 hashing. SIGNATURE_TYPE_RIPEMD = "RIPEMD" // SIGNATURE_TYPE_SHA512 indicates SHA-512 hashing. SIGNATURE_TYPE_SHA512 = "SHA512" )
Key format and signature type constants.
Variables ¶
View Source
var ( // ErrConfigStorageEmpty is returned when config storage is not configured. ErrConfigStorageEmpty = errors.New("config storage is empty") )
Error definitions for security operations.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
Debug bool `json:"debug"`
KeyFormat string `json:"defaultKeyFormat"`
SignatureType string `json:"signatureType"`
// contains filtered or unexported fields
}
Config holds the security manager configuration.
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager handles request signing and security configuration.
func NewManager ¶
NewManager creates a new security manager with the specified options.
func (*Manager) SignRequest ¶
func (m *Manager) SignRequest(apiKey string, method string, params json.RawMessage) (sign []byte, err error)
SignRequest generates a signature for an RPC request. Uses the configured key format and signature type.
type Option ¶
type Option func(*Manager)
Option is a function that configures a Manager.
func WithStorageManager ¶
func WithStorageManager(storageManager *storage.ModuleManager) Option
WithStorageManager sets the storage manager for configuration persistence.
Click to show internal directories.
Click to hide internal directories.