core

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2023 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ContentType     = "Content-Type"
	ApplicationJSON = "application/json"
	TextHTML        = "text/html"
	TextPlain       = "text/plain"
	ApplicationJWT  = "application/jwt"
)

http headers

View Source
const NscError = `support for direct access of the nsc folder has been removed` + commonErr
View Source
const RoError = `support for read only directory access with file system updates has been removed` + commonErr

Variables

This section is empty.

Functions

func NewNilLogger added in v1.0.0

func NewNilLogger() natsserver.Logger

func Run added in v1.0.0

func Run(server *AccountServer) error

func ShortKey

func ShortKey(s string) string

ShortKey returns the first 12 characters of a public key (or the key if it is < 12 long)

func UnixToDate

func UnixToDate(d int64) string

UnixToDate parses a unix date in UTC to a time

Types

type AccountServer

type AccountServer struct {
	sync.Mutex

	store.JWTStore
	// contains filtered or unexported fields
}

AccountServer is the core structure for the server.

func NewAccountServer

func NewAccountServer() *AccountServer

NewAccountServer creates a new account server with a default logger

func (*AccountServer) ApplyConfigFile

func (server *AccountServer) ApplyConfigFile(configFile string) error

ApplyConfigFile applies the config file to the server's config

func (*AccountServer) Config added in v1.0.1

func (server *AccountServer) Config() *conf.AccountServerConfig

func (*AccountServer) ConfigureLogger added in v1.0.0

func (server *AccountServer) ConfigureLogger() natsserver.Logger

ConfigureLogger configures the logger for this account server

func (*AccountServer) InitializeFromConfig

func (server *AccountServer) InitializeFromConfig(config *conf.AccountServerConfig) error

InitializeFromConfig initialize the server's configuration to an existing config object, useful for tests Does not change the config at all, use DefaultServerConfig() to create a default config

func (*AccountServer) InitializeFromFlags

func (server *AccountServer) InitializeFromFlags(flags Flags) error

InitializeFromFlags is called from main to configure the server, the server will decide what needs to happen based on the flags. On reload the same flags are passed

func (*AccountServer) LoadAcc added in v1.0.0

func (server *AccountServer) LoadAcc(publicKey string) (string, error)

Wrap store with a nats layer, so lookups can be forwarded

func (*AccountServer) LoadAct added in v1.0.0

func (server *AccountServer) LoadAct(hash string) (string, error)

func (*AccountServer) Logger

func (server *AccountServer) Logger() natsserver.Logger

Logger hosts a shared logger

func (*AccountServer) Merge added in v1.0.0

func (server *AccountServer) Merge(pack string) error

func (*AccountServer) Pack added in v1.0.0

func (server *AccountServer) Pack(maxJWTs int) (string, error)

func (*AccountServer) ReadyForConnections added in v1.0.0

func (server *AccountServer) ReadyForConnections(dur time.Duration) bool

func (*AccountServer) SaveAct added in v1.0.0

func (server *AccountServer) SaveAct(hash string, theJWT string) error

func (*AccountServer) Start

func (server *AccountServer) Start() error

Start the server, will lock the server, assumes the config is loaded

func (*AccountServer) Stop

func (server *AccountServer) Stop()

Stop the account server

type Flags

type Flags struct {
	ConfigFile string

	Directory string

	OperatorJWTPath string
	NATSURL         string
	Creds           string

	Debug           bool
	Verbose         bool
	DebugAndVerbose bool

	HostPort string

	Primary string // Only used to copy jwt from old account server
}

Flags defines the various flags you can call the account server with. These are used in main and passed down to the server code to process.

type JwtHandler added in v1.0.0

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

func NewJwtHandler added in v1.0.0

func NewJwtHandler(logger natsserver.Logger) JwtHandler

func (*JwtHandler) GetAccountJWT added in v1.0.0

func (h *JwtHandler) GetAccountJWT(w http.ResponseWriter, r *http.Request, params httprouter.Params)

GetAccountJWT looks up an account JWT by public key and returns it Supports cache control

func (*JwtHandler) GetActivationJWT added in v1.0.0

func (h *JwtHandler) GetActivationJWT(w http.ResponseWriter, r *http.Request, params httprouter.Params)

GetActivationJWT looks for an activation token by hash

func (*JwtHandler) GetOperatorJWT added in v1.0.0

func (h *JwtHandler) GetOperatorJWT(w http.ResponseWriter, r *http.Request, params httprouter.Params)

GetOperatorJWT returns the known operator JWT

func (*JwtHandler) InitRouter added in v1.0.0

func (h *JwtHandler) InitRouter(r *httprouter.Router)

BuildRouter initializes the http.Router with default router setup

func (*JwtHandler) Initialize added in v1.0.0

func (h *JwtHandler) Initialize(opJWT []byte, sysAccJWT []byte, jwtStore store.JWTStore, packLimit int, accNotification accountNotification, actNotification activationNotification, sign accountSignup) error

Initialize JwtHandler which exposes http handler on top of a jwtStore To Close, stop using the jwthandler and close the passed in store.

func (*JwtHandler) JWTHelp added in v1.0.0

func (h *JwtHandler) JWTHelp(w http.ResponseWriter, r *http.Request, params httprouter.Params)

JWTHelp handles get requests for JWT help

func (*JwtHandler) PackJWTs added in v1.0.0

func (h *JwtHandler) PackJWTs(w http.ResponseWriter, r *http.Request, params httprouter.Params)

PackJWTs the JWTS and return takes a parameter for max

func (*JwtHandler) UpdateAccountJWT added in v1.0.0

func (h *JwtHandler) UpdateAccountJWT(w http.ResponseWriter, r *http.Request, params httprouter.Params)

UpdateAccountJWT is the target of the post request that updates an account JWT Sends a nats notification

func (*JwtHandler) UpdateActivationJWT added in v1.0.0

func (h *JwtHandler) UpdateActivationJWT(w http.ResponseWriter, r *http.Request, params httprouter.Params)

UpdateActivationJWT is the handler for POST requests that update an activation JWT

type NilLogger added in v1.0.0

type NilLogger struct {
}

func (*NilLogger) Debugf added in v1.0.0

func (l *NilLogger) Debugf(format string, v ...interface{})

func (*NilLogger) Errorf added in v1.0.0

func (l *NilLogger) Errorf(format string, v ...interface{})

func (*NilLogger) Fatalf added in v1.0.0

func (l *NilLogger) Fatalf(format string, v ...interface{})

func (*NilLogger) Noticef added in v1.0.0

func (l *NilLogger) Noticef(format string, v ...interface{})

func (*NilLogger) Tracef added in v1.0.0

func (l *NilLogger) Tracef(format string, v ...interface{})

func (*NilLogger) Warnf added in v1.0.0

func (l *NilLogger) Warnf(format string, v ...interface{})

Jump to

Keyboard shortcuts

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