jwt

package
v0.9.4 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2025 License: MIT Imports: 10 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type JWTAuthenticator

type JWTAuthenticator interface {
	// AuthenticateJWT authenticates the JWT token for the given request and return the JWT claims.
	// If the JWT token is invalid, the function will return nil claims and error.
	AuthenticateJWT(ctx context.Context, tokenString string, originalRequest any) (bool, *nodeauthtypes.NodeJWTClaims, error)
}

---------- JWT Authenticator - Related Interfaces ---------- JWTAuthenticator handles JWT token authentication.

type JWTGenerator

type JWTGenerator interface {
	// CreateJWTForRequest creates a JWT token for the given request
	CreateJWTForRequest(req any) (string, error)
}

---------- JWT Generator Interfaces ---------- JWTGenerator handles JWT token creation.

type NodeAuthProvider

type NodeAuthProvider interface {

	// IsNodePubKeyTrusted checks if a node's public key is trusted
	// Usually, this is done by checking the node aginst DON's on-chain topology.
	// The check can be done aginst on-chain contracts or cache, depending on the each service's implementation.
	IsNodePubKeyTrusted(ctx context.Context, publicKey ed25519.PublicKey) (bool, error)
}

NodeAuthProvider interface for node <-> DON auth provider Each service that uses NodeJWTAuthenticator must provide an implementation for this interface.

type NodeJWTAuthenticator

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

NodeJWTAuthenticator is designed to be used by the server-side service to authenticate the JWT token generated by the Node.

func NewNodeJWTAuthenticator

func NewNodeJWTAuthenticator(nodeAuthProvider NodeAuthProvider, logger *slog.Logger) *NodeJWTAuthenticator

func (*NodeJWTAuthenticator) AuthenticateJWT

func (v *NodeJWTAuthenticator) AuthenticateJWT(ctx context.Context, tokenString string, originalRequest any) (bool, *types.NodeJWTClaims, error)

1. Standard JWT Validation: validate the JWT claims and signature against public key. 2. Public Key Whitelist Validation: validate the node's public key is trusted.

type NodeJWTGenerator

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

NodeJWTGenerator implements the JWTGenerator interface.

func NewNodeJWTGenerator

func NewNodeJWTGenerator(signer *core.Ed25519Signer, csaPubKey ed25519.PublicKey) *NodeJWTGenerator

NewNodeJWTGenerator creates a new node JWT generator

func (*NodeJWTGenerator) CreateJWTForRequest

func (m *NodeJWTGenerator) CreateJWTForRequest(req any) (string, error)

CreateJWTForRequest creates a JWT token for the given request

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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