authn

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ALGORITHM  = "ES256K"
	SIG_LENGTH = 65
	R_LENGTH   = 32
	S_LENGTH   = 32
)
View Source
const (
	MAX_TOKEN_DURATION = 2 * time.Hour
	MAX_CLOCK_SKEW     = 2 * time.Minute
)
View Source
const (
	TOKEN_DURATION = time.Hour
)

Variables

View Source
var (
	ErrWrongKeyFormat = errors.New("wrong key type")
	ErrBadSignature   = errors.New("bad signature")
	ErrVerification   = errors.New("signature verification failed")
)

Functions

This section is empty.

Types

type JWTVerifier

type JWTVerifier interface {
	Verify(tokenString string) error
}

type RegistryVerifier

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

func NewRegistryVerifier

func NewRegistryVerifier(registry registry.NodeRegistry, myNodeID uint32) *RegistryVerifier

A RegistryVerifier connects to the NodeRegistry and verifies JWTs against the registered public keys based on the JWT's subject field

func (*RegistryVerifier) Verify

func (v *RegistryVerifier) Verify(tokenString string) error

type SigningMethodSecp256k1

type SigningMethodSecp256k1 struct{}

* The JWT signing method for secp256k1. Inspired by https://github.com/ureeves/jwt-go-secp256k1/blob/master/secp256k1.go but updated to work with the latest version of jwt-go.

func (*SigningMethodSecp256k1) Alg

func (sm *SigningMethodSecp256k1) Alg() string

func (*SigningMethodSecp256k1) Sign

func (sm *SigningMethodSecp256k1) Sign(signingString string, key interface{}) ([]byte, error)

func (*SigningMethodSecp256k1) Verify

func (sm *SigningMethodSecp256k1) Verify(signingString string, sig []byte, key interface{}) error

type Token

type Token struct {
	SignedString string
	ExpiresAt    time.Time
}

func NewToken

func NewToken(signedString string, expiresAt time.Time) *Token

type TokenFactory

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

func NewTokenFactory

func NewTokenFactory(privateKey *ecdsa.PrivateKey, nodeID uint32) *TokenFactory

func (*TokenFactory) CreateToken

func (f *TokenFactory) CreateToken(forNodeID uint32) (*Token, error)

Jump to

Keyboard shortcuts

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