Documentation
¶
Overview ¶
Package server provides a Charm Cloud server with HTTP and SSH protocols.
Index ¶
- func CharmUserMiddleware(s *HTTPServer) func(http.Handler) http.Handler
- func JWTMiddleware(publicKey []byte) (func(http.Handler) http.Handler, error)
- func RequestLimitMiddleware() func(http.Handler) http.Handler
- type Config
- type HTTPServer
- type SSHLinker
- func (sl *SSHLinker) Error(l *charm.Link)
- func (sl *SSHLinker) LinkedDifferentUser(l *charm.Link)
- func (sl *SSHLinker) LinkedSameUser(l *charm.Link)
- func (sl *SSHLinker) RequestDenied(l *charm.Link)
- func (sl *SSHLinker) RequestInvalidToken(l *charm.Link)
- func (sl *SSHLinker) RequestStart(l *charm.Link)
- func (sl *SSHLinker) RequestValidToken(l *charm.Link)
- func (sl *SSHLinker) Requested(l *charm.Link) (bool, error)
- func (sl *SSHLinker) Success(l *charm.Link)
- func (sl *SSHLinker) TimedOut(l *charm.Link)
- func (sl *SSHLinker) TokenCreated(token charm.Token)
- func (sl *SSHLinker) TokenSent(l *charm.Link)
- func (sl *SSHLinker) User() *charm.User
- type SSHServer
- type Server
- type Session
- type SessionHandler
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CharmUserMiddleware ¶
func CharmUserMiddleware(s *HTTPServer) func(http.Handler) http.Handler
CharmUserMiddleware looks up and authenticates a Charm user based on the provided JWT in the request.
func JWTMiddleware ¶
JWTMiddleware creates a new middleware function that will validate JWT tokesn based on the supplied public key.
Types ¶
type Config ¶
type Config struct {
Host string `env:"CHARM_SERVER_HOST" default:"localhost"`
SSHPort int `env:"CHARM_SERVER_SSH_PORT" default:"35353"`
HTTPPort int `env:"CHARM_SERVER_HTTP_PORT" default:"35354"`
HTTPScheme string `env:"CHARM_SERVER_HTTP_SCHEME" default:"http"`
StatsPort int `env:"CHARM_SERVER_STATS_PORT" default:"35355"`
HealthPort string `env:"CHARM_SERVER_HEALTH_PORT" default:"35356"`
DataDir string `env:"CHARM_SERVER_DATA_DIR" default:"./data"`
TLSKeyFile string `env:"CHARM_SERVER_TLS_KEY_FILE" default:""`
TLSCertFile string `env:"CHARM_SERVER_TLS_CERT_FILE" default:""`
TLSConfig *tls.Config
PublicKey []byte
PrivateKey []byte
DB db.DB
FileStore storage.FileStore
Stats stats.Stats
}
Config is the configuration for the Charm server.
func DefaultConfig ¶
func DefaultConfig() *Config
DefaultConfig returns a Config with the values populated with the defaults or specified environment variables.
func (*Config) WithFileStore ¶
WithFileStore returns a Config with the provided FileStore implementation.
type HTTPServer ¶
type HTTPServer struct {
// contains filtered or unexported fields
}
HTTPServer is the HTTP server for the Charm Cloud backend.
func NewHTTPServer ¶
func NewHTTPServer(cfg *Config) (*HTTPServer, error)
NewHTTPServer returns a new *HTTPServer with the specified Config.
func (*HTTPServer) Start ¶
func (s *HTTPServer) Start()
Start starts the HTTP server on the port specified in the Config.
type SSHLinker ¶
type SSHLinker struct {
// contains filtered or unexported fields
}
SSHLinker implments proto.LinkTransport for the Charm SSH server.
func (*SSHLinker) LinkedDifferentUser ¶
LinkedDifferentUser implements the proto.LinkTransport interface for the SSHLinker.
func (*SSHLinker) LinkedSameUser ¶
LinkedSameUser implements the proto.LinkTransport interface for the SSHLinker.
func (*SSHLinker) RequestDenied ¶
RequestDenied implements the proto.LinkTransport interface for the SSHLinker.
func (*SSHLinker) RequestInvalidToken ¶
RequestInvalidToken implements the proto.LinkTransport interface for the SSHLinker.
func (*SSHLinker) RequestStart ¶
RequestStart implements the proto.LinkTransport interface for the SSHLinker.
func (*SSHLinker) RequestValidToken ¶
RequestValidToken implements the proto.LinkTransport interface for the SSHLinker.
func (*SSHLinker) Requested ¶
Requested implements the proto.LinkTransport interface for the SSHLinker.
func (*SSHLinker) TimedOut ¶
TimedOut implements the proto.LinkTransport interface for the SSHLinker.
func (*SSHLinker) TokenCreated ¶
TokenCreated implements the proto.LinkTransport interface for the SSHLinker.
type SSHServer ¶
type SSHServer struct {
// contains filtered or unexported fields
}
SSHServer serves the SSH protocol and handles requests to authenticate and link Charm user accounts.
func NewSSHServer ¶
NewSSHServer creates a new SSHServer from the provided Config.
func (*SSHServer) DeleteLinkRequest ¶
DeleteLinkRequest implements the proto.LinkTransport interface for the SSHLinker.
func (*SSHServer) LinkGen ¶
func (me *SSHServer) LinkGen(lt charm.LinkTransport) error
LinkGen implements the proto.LinkTransport interface for the SSHLinker.
func (*SSHServer) LinkRequest ¶
LinkRequest implements the proto.LinkTransport interface for the SSHLinker.
type Server ¶
type Server struct {
Config *Config
// contains filtered or unexported fields
}
Server contains the SSH and HTTP servers required to host the Charm Cloud.
type SessionHandler ¶
type SessionHandler func(s Session)
SessionHandler defines a function that handles a session for a given SSH command.