serve

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2023 License: Apache-2.0 Imports: 48 Imported by: 0

Documentation

Index

Constants

View Source
const BearerPrefix = "bearer "

Variables

View Source
var ErrBadToken = errors.New("Bad token.")
View Source
var ErrTokenExpired = errors.New("Token expired.")

Functions

func FormatListenAddr added in v0.2.2

func FormatListenAddr(listenAddr string) string

FormatListenAddr takes a hostport str, and appends an interface ip addr as a host if the original host was empty or 0.0.0.0.

func Run

func Run(ctx context.Context, env *action.Environment, cfg *Config) error

Types

type Config

type Config struct {
	ListenAddr string `flags:"listen-addr,server listen host:addr (:34680)"`
	ReusePort  bool   `flags:"reuse-port,set SO_REUSEPORT on listener socket"`

	Names san.Names `flags:"subject-alt-name,set subjectAltNames to use on server certificate,san"`

	IssueHttp int `flags:"issue-http,enable certificate issue via HTTP API"`

	ExposeMetrics bool `flags:"expose-metrics,expose /metrics HTTP endpoint for prometheus to crawl"`

	AutoShutdown time.Duration `flags:"auto-shutdown,auto shutdown server after specified time,,duration"`

	// Enable node bootstrapping with the given auth provider.
	Bootstrap TokenAuthProvider
}

func DefaultConfig

func DefaultConfig() (*Config, error)

type FixedTokenAuthProvider

type FixedTokenAuthProvider struct {
	Token    string
	NotAfter time.Time
	Logger   *zap.Logger
}

func (*FixedTokenAuthProvider) Authenticate

func (ta *FixedTokenAuthProvider) Authenticate(t string, now time.Time) error

func (*FixedTokenAuthProvider) LogHelpMessage

func (ta *FixedTokenAuthProvider) LogHelpMessage(listenAddr, pubkeyhash string)

type Server

type Server struct {
	Shutdown func(ctx context.Context) error
}

func StartServer

func StartServer(ctx context.Context, env *action.Environment, cfg *Config) (*Server, error)

type TokenAuthProvider

type TokenAuthProvider interface {
	Authenticate(token string, now time.Time) error
	LogHelpMessage(listenAddr, pubkeyhash string)
}

func NewTokenFileAuthProvider

func NewTokenFileAuthProvider(path string, logger *zap.Logger) (TokenAuthProvider, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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