credentials

package module
v0.0.0-...-ef04b01 Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2024 License: AGPL-3.0-or-later Imports: 16 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	MismatchError      = errors.New("credential MAC mismatch")
	MemoryError        = errors.New("memory allocation error")
	SerializationError = errors.New("error serializing HMAC protobuf body")
)

Functions

This section is empty.

Types

type AuthenticatedCredential

type AuthenticatedCredential pb.AuthenticatedCredential

func (*AuthenticatedCredential) Base64URLDecode

func (ac *AuthenticatedCredential) Base64URLDecode(username string, password string) error

func (*AuthenticatedCredential) Base64URLEncodePassword

func (ac *AuthenticatedCredential) Base64URLEncodePassword() (string, error)

func (*AuthenticatedCredential) Base64URLEncodeUsername

func (ac *AuthenticatedCredential) Base64URLEncodeUsername() string

func (*AuthenticatedCredential) MarshalJSON

func (ac *AuthenticatedCredential) MarshalJSON() ([]byte, error)

func (*AuthenticatedCredential) Pb

func (*AuthenticatedCredential) UnmarshalJSON

func (ac *AuthenticatedCredential) UnmarshalJSON(data []byte) error

type CredentialManager

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

CredentialManager authenticates and verifies rescue node credentials

func NewCredentialManager

func NewCredentialManager(key []byte, extraSecrets ...[]byte) *CredentialManager

NewCredentialManager creates a new CredentialManager which can create and verify authenticated credentials Credentials are created with `key` but validated against `key` and all `extraSecrets`. Under the hood, the library uses sha256 as an hmac hash, so keys should be at least 32 bytes for full security.

func (*CredentialManager) Create

func (c *CredentialManager) Create(timestamp time.Time, nodeID []byte, OperatorType OperatorType) (*AuthenticatedCredential, error)

Create makes a new credential and authenticates it, returning a protoc struct that can be marshaled/unmarshaled

func (*CredentialManager) ID

func (c *CredentialManager) ID() *ID

ID returns the ID struct of the primary secret

func (*CredentialManager) PartnerIDs

func (c *CredentialManager) PartnerIDs() []*ID

PartnerIDs returns a slice of ID structs of partner secrets

func (*CredentialManager) Verify

func (c *CredentialManager) Verify(authenticatedCredential *AuthenticatedCredential) (*ID, error)

Verify checks that a AuthenticatedCredential has a valid mac

type Error

type Error error

type ID

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

func (*ID) Equals

func (i *ID) Equals(b *ID) bool

func (*ID) String

func (i *ID) String() string

func (*ID) StringWithLength

func (i *ID) StringWithLength(length uint8) string

type OperatorType

type OperatorType = pb.OperatorType

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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