serve

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: May 17, 2020 License: Apache-2.0 Imports: 43 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 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"`

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

	// 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