auth

package
v0.12.3 Latest Latest
Warning

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

Go to latest
Published: May 30, 2019 License: AGPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	//ErrSign indicates a failure during signing
	ErrSign = errs.Class("Failed to sign message")
	//ErrVerify indicates a failure during signature validation
	ErrVerify = errs.Class("Failed to validate message signature")
	//ErrSigLen indicates an invalid signature length
	ErrSigLen = errs.Class("Invalid signature length")
	//ErrSerial indicates an invalid serial number length
	ErrSerial = errs.Class("Invalid SerialNumber")
	//ErrExpired indicates the agreement is expired
	ErrExpired = errs.Class("Agreement is expired")
	//ErrSigner indicates a public key / node id mismatch
	ErrSigner = errs.Class("Message public key did not match expected signer")
	//ErrBadID indicates a public key / node id mismatch
	ErrBadID = errs.Class("Node ID did not match expected id")

	//ErrMarshal indicates a failure during serialization
	ErrMarshal = errs.Class("Could not marshal item to bytes")
	//ErrUnmarshal indicates a failure during deserialization
	ErrUnmarshal = errs.Class("Could not unmarshal bytes to item")
	//ErrMissing indicates missing or empty information
	ErrMissing = errs.Class("Required field is empty")
)
View Source
var Error = errs.Class("auth error")

Error is the default auth error class

Functions

func GenerateSignature

func GenerateSignature(data []byte, identity *identity.FullIdentity) ([]byte, error)

GenerateSignature creates signature from identity id

func GetAPIKey

func GetAPIKey(ctx context.Context) ([]byte, bool)

GetAPIKey returns api key from context is exists

func SignMessage

func SignMessage(msg SignableMessage, ID identity.FullIdentity) error

SignMessage adds the crypto-related aspects of signed message

func ValidateAPIKey

func ValidateAPIKey(ctx context.Context, actualKey []byte) error

ValidateAPIKey compares the context api key with the key passed in as an argument

func VerifyMsg

func VerifyMsg(msg SignableMessage, signer storj.NodeID) error

VerifyMsg checks the crypto-related aspects of signed message

func WithAPIKey

func WithAPIKey(ctx context.Context, key []byte) context.Context

WithAPIKey creates context with api key

Types

type SignableMessage

type SignableMessage interface {
	proto.Message
	GetCerts() [][]byte
	GetSignature() []byte
	SetCerts([][]byte)
	SetSignature([]byte)
}

SignableMessage is a protocol buffer with a certs and a signature Note that we assume proto.Message is a pointer receiver

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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