authn

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2025 License: MIT Imports: 11 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 ClaimValidator added in v0.2.1

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

func NewClaimValidator added in v0.2.1

func NewClaimValidator(serverVersion *semver.Version) (*ClaimValidator, error)

func (*ClaimValidator) ValidateVersionClaimIsCompatible added in v0.2.1

func (cv *ClaimValidator) ValidateVersionClaimIsCompatible(claims *XmtpdClaims) error

type JWTVerifier

type JWTVerifier interface {
	Verify(tokenString string) (uint32, error)
}

type RegistryVerifier

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

func NewRegistryVerifier

func NewRegistryVerifier(
	registry registry.NodeRegistry,
	myNodeID uint32,
	serverVersion *semver.Version,
) (*RegistryVerifier, error)

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) (uint32, 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 serverVersion 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,
	serverVersion *semver.Version,
) TokenFactory

func (*TokenFactory) CreateToken

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

type XmtpdClaims added in v0.2.0

type XmtpdClaims struct {
	Version *semver.Version `json:"version,omitempty"`
	jwt.RegisteredClaims
}

Jump to

Keyboard shortcuts

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