hmactoken

package
v0.0.0-...-efe69f1 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package hmactoken implements generation and validation HMAC-tagged Swarming tokens.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Secret

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

Secret can be used to generate and validate HMAC-tagged tokens.

func NewRotatingSecret

func NewRotatingSecret(ctx context.Context, keyName string) (*Secret, error)

NewRotatingSecret creates a new secret given a key name and subscribes to its rotations.

func NewStaticSecret

func NewStaticSecret(secret secrets.Secret) *Secret

NewStaticSecret creates a new secret from a given static secret value.

Mostly for tests.

func (*Secret) GenerateToken

func (s *Secret) GenerateToken(msg proto.Message) ([]byte, error)

GenerateToken wraps `msg` into a serialized TaggedMessage.

The produced token can be validated and deserialized with validateToken.

func (*Secret) ValidateToken

func (s *Secret) ValidateToken(tok []byte, msg proto.Message) error

ValidateToken deserializes a TaggedMessage, checks the HMAC and deserializes the payload into `msg`.

Jump to

Keyboard shortcuts

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