hmac

package
v0.34.1 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2024 License: BSD-3-Clause Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type TimedHMAC

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

TimedHMAC generates a token with TTL and uses a pre-shared secret known to the relay server

func NewTimedHMAC

func NewTimedHMAC(secret string, timeToLive time.Duration) *TimedHMAC

NewTimedHMAC creates a new TimedHMAC instance

func (*TimedHMAC) GenerateToken

func (m *TimedHMAC) GenerateToken(algo func() hash.Hash) (*Token, error)

GenerateToken generates new time-based secret token - basically Payload is a unix timestamp and Signature is a HMAC hash of a timestamp with a preshared TURN secret

func (*TimedHMAC) Validate

func (m *TimedHMAC) Validate(algo func() hash.Hash, token Token) error

Validate checks if the token is valid

type TimedHMACValidator

type TimedHMACValidator struct {
	*TimedHMAC
}

func NewTimedHMACValidator

func NewTimedHMACValidator(secret string, duration time.Duration) *TimedHMACValidator

func (*TimedHMACValidator) Validate

func (a *TimedHMACValidator) Validate(credentials any) error

type Token

type Token struct {
	Payload   string
	Signature string
}

type TokenStore

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

TokenStore is a simple in-memory store for token With this can update the token in thread safe way

func (*TokenStore) TokenBinary

func (a *TokenStore) TokenBinary() []byte

func (*TokenStore) UpdateToken

func (a *TokenStore) UpdateToken(token *Token) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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