server

package
v1.9.2 Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2026 License: Apache-2.0, MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Auth

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

Auth holds the JWT signing secret and pre-minted tokens for each permission level.

func LoadOrInitAuth

func LoadOrInitAuth(dataDir string, seed []byte) (*Auth, error)

LoadOrInitAuth loads jwt secret + pre-minted tokens from `dataDir`, or initialises them if absent. If `seed` is non-empty it overrides any on-disk secret.

func (*Auth) AuthNew

func (a *Auth) AuthNew(perms []auth.Permission) ([]byte, error)

AuthNew issues a new JWT with the requested perms.

func (*Auth) AuthVerify

func (a *Auth) AuthVerify(token string) ([]auth.Permission, error)

AuthVerify validates a JWT and returns its claimed permissions.

Tokens issued post-#7 carry an `exp` claim; we enforce it strictly: expired tokens fail with a clear error so the operator knows to rotate. Legacy tokens (v1.2.1 and earlier) have no exp claim; we accept them with a warning-class log line so we don't break running deployments during the one-release grace window.

func (*Auth) Inspect

func (a *Auth) Inspect(token string) (TokenInfo, error)

Inspect parses a previously-issued token (signed by this Auth's secret) and returns descriptive info for the operator. Used by `lantern auth list`.

func (*Auth) Rotate

func (a *Auth) Rotate(dataDir string) error

Rotate generates a fresh JWT secret and reissues all four scope tokens under dataDir, invalidating every previously-issued token (#7).

func (*Auth) Token

func (a *Auth) Token(p auth.Permission) string

Token returns the pre-minted token at the requested permission level.

type Config

type Config struct {
	// ListenAddress is the TCP listen address, e.g. "127.0.0.1:1234".
	ListenAddress string
	// DataDir is where token files (lantern auth tokens) live.
	DataDir string
	// JWTSecret is the symmetric secret for the JWT auth scheme. When
	// empty, the server generates one and persists it under DataDir.
	JWTSecret []byte
}

Config configures the RPC server.

type Server

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

Server wraps an http.Server bound to a go-jsonrpc dispatcher.

func New

func New(cfg Config, node api.FullNode) (*Server, error)

New creates a server bound to `node` and starts listening. The caller must call Run() (blocking) or Start()/Stop() to actually serve.

func (*Server) Addr

func (s *Server) Addr() net.Addr

Addr returns the actual listening address (useful when ListenAddress was ":0").

func (*Server) Auth

func (s *Server) Auth() *Auth

Auth returns the auth state (so callers can mint additional tokens for the CLI subcommands).

func (*Server) FullNodeAPIInfo

func (s *Server) FullNodeAPIInfo() (string, error)

FullNodeAPIInfo returns the Lotus-compatible `FULLNODE_API_INFO` string for the admin-scoped token, ready to be set into the environment.

Format: "<token>:/ip4/<host>/tcp/<port>/http"

func (*Server) Start

func (s *Server) Start() error

Start launches the HTTP server in a background goroutine.

func (*Server) Stop

func (s *Server) Stop(ctx context.Context) error

Stop gracefully shuts down the server.

type TokenInfo

type TokenInfo struct {
	File     string            // basename under dataDir (e.g. "token", "token-sign")
	Perms    []auth.Permission // permission set granted by this token
	IssuedAt time.Time         // when this token was minted
	Expires  time.Time         // when this token stops being accepted
	JTI      string            // unique token id (rotation evidence)
	Legacy   bool              // true when the token has no exp claim
}

TokenInfo describes an issued JWT for the auth-list command (#7).

Jump to

Keyboard shortcuts

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