auth

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2020 License: AGPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const KeyJSONSchema = `` /* 839-byte string literal not displayed */

KeyJSONSchema should be used to validate keys in JSON form

View Source
const VerifierJSONSchema = `` /* 1070-byte string literal not displayed */

VerifierJSONSchema should be used to validate verifiers in JSON form

Variables

This section is empty.

Functions

func IsVerifierValid

func IsVerifierValid(verifier Verifier) bool

IsVerifierValid ensures the verifier's checksum matches

func NewRandomBytes

func NewRandomBytes(length int) ([]byte, error)

NewRandomBytes generates a byte array full of cryptographic strength random data

func UUIDEquals

func UUIDEquals(u1 uuid.UUID, u2 uuid.UUID) bool

UUIDEquals returns true if the two UUID contents are equal. False otherwise.

func Verify

func Verify(key Key, verifier Verifier) bool

Verify ensures the following:

  • GroupIDs match

  • Key Checksum valid

  • Verifier Checksum valid

  • Key secret matches Verifier hash

    Returns true if all these conditions are met and no errors. False otherwise.

Types

type Key

type Key struct {
	Group    uuid.UUID `json:"group"`
	Secret   []byte    `json:"secret"`
	Checksum []byte    `json:"checksum"`
}

Key is a value that administrators will configure the Weaklayer Sensor with. Its purpose is to authenticate the sensor to the gateway so we know it is allowed to send data.

func NewKey

func NewKey(group uuid.UUID) (Key, error)

NewKey creates a new install key with a random secret for the provided group On error, the default Key is returned with error set

type Verifier

type Verifier struct {
	Group    uuid.UUID `json:"group"`
	Salt     []byte    `json:"salt"`
	Hash     []byte    `json:"hash"`
	Checksum []byte    `json:"checksum"`
}

Verifier is data provided to the Weaklayer Gateway so it can verify the key that a Weaklayer Sensor Provides.

func NewVerifier

func NewVerifier(key Key) (Verifier, error)

NewVerifier creates a new install verifier from an existing key and a random salt On error, the default Verifier is returned with error set

Jump to

Keyboard shortcuts

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