signature

package
v0.0.0-...-8122643 Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2024 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ErrorCodeInvalidKey       string = "invalid_key"
	ErrorCodeInvalidSignature string = "invalid_signature"
)

Variables

View Source
var ErrorDescriptions = map[string]string{
	ErrorCodeInvalidSignature: "Invalid signature",
	ErrorCodeInvalidKey:       "Invalid key",
}

Functions

func DbModels

func DbModels() []interface{}

func QueryDbModels

func QueryDbModels() []interface{}

Types

type MessageSignature

type MessageSignature struct {
	common.ObjectWithMonthBase
	auth.WithUserBase
	Context    string `gorm:"index;index:,unique,composite:u_month"`
	Operation  string `gorm:"index"`
	Algorithm  string `gorm:"index"`
	Message    string
	Signature  string
	ExtraData  string `gorm:"index"`
	PubKeyHash string `gorm:"index"`
}

type OpLogPubKey

type OpLogPubKey struct {
	user.OpLogUser
	KeyId   string `gorm:"index" json:"key_id"`
	KeyHash string `gorm:"index" json:"key_hash"`
}

type SignatureManager

type SignatureManager interface {
	generic_error.ErrorDefinitions

	Verify(ctx auth.AuthContext, signature string, message []byte, extraData ...string) error
	CheckPubKey(ctx op_context.Context, key string) error
	SetUserKeyFinder(userKeyFinder func(ctx auth.AuthContext) (UserWithPubkey, error))
}

type SignatureManagerBase

type SignatureManagerBase struct {
	SignatureManagerBaseConfig
	// contains filtered or unexported fields
}

func NewSignatureManager

func NewSignatureManager() *SignatureManagerBase

func (*SignatureManagerBase) AttachToErrorManager

func (s *SignatureManagerBase) AttachToErrorManager(errManager generic_error.ErrorManager)

func (*SignatureManagerBase) CheckPubKey

func (s *SignatureManagerBase) CheckPubKey(ctx op_context.Context, key string) error

func (*SignatureManagerBase) Compress

func (s *SignatureManagerBase) Compress(src []byte) []byte

func (*SignatureManagerBase) Config

func (s *SignatureManagerBase) Config() interface{}

func (*SignatureManagerBase) Decompress

func (s *SignatureManagerBase) Decompress(src []byte) ([]byte, error)

func (*SignatureManagerBase) Find

func (*SignatureManagerBase) Init

func (s *SignatureManagerBase) Init(cfg config.Config, log logger.Logger, vld validator.Validator, configPath ...string) error

func (*SignatureManagerBase) MakeVerifier

func (*SignatureManagerBase) SetUserKeyFinder

func (s *SignatureManagerBase) SetUserKeyFinder(userKeyFinder func(ctx auth.AuthContext) (UserWithPubkey, error))

func (*SignatureManagerBase) Verify

func (s *SignatureManagerBase) Verify(ctx auth.AuthContext, signature string, message []byte, extraData ...string) error

type SignatureManagerBaseConfig

type SignatureManagerBaseConfig struct {
	ALGORITHM               string `validate:"required,oneof=rsa_h256_signature" default:"rsa_h256_signature"`
	ENCRYPT_MESSAGE_STORE   bool
	COMPRESS_BEFORE_ENCRYPT bool   `default:"true"`
	SECRET                  string `mask:"true"`
	SALT                    string `mask:"true"`
}

type UserWithPubkey

type UserWithPubkey interface {
	PubKey() string
	PubKeyHash() string
}

type WithSignatureManager

type WithSignatureManager interface {
	SignatureManager() SignatureManager
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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