server

package
v0.0.16 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2022 License: MPL-2.0 Imports: 36 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ContextLoginName = "login-name"
)

Variables

This section is empty.

Functions

func NewError added in v0.0.15

func NewError(code int, err error, op string) error

func PrettyStruct

func PrettyStruct(data interface{}) (string, error)

func WrapHandler added in v0.0.15

func WrapHandler(handler HandlerFunc) gin.HandlerFunc

Types

type AuthMiddlewareHeaderRequest added in v0.0.13

type AuthMiddlewareHeaderRequest struct {
	JWTToken string `header:"Authorization"`
}

type AuthMiddlewareURIRequest added in v0.0.13

type AuthMiddlewareURIRequest struct {
	LoginName string `uri:"login_name" example:"alice"`
}

type Error added in v0.0.15

type Error struct {
	// Machine-readable error code.
	HTTPStatusCode int `json:"http_status_code,omitempty"`

	// Human-readable message.
	Message string `json:"message,omitempty"`
	Request string `json:"request,omitempty"`

	// Logical operation and nested error.
	Op  string `json:"op,omitempty"`
	Err error  `json:"error,omitempty"`
}

Error defines a standard application error.

func (*Error) Error added in v0.0.15

func (e *Error) Error() string

Error returns the string representation of the error message.

type HandlerFunc added in v0.0.15

type HandlerFunc func(c *gin.Context) error

type Opt

type Opt struct {
	Debug       bool
	KubeConfig  string
	HostKeyPath string
	DBURL       string

	NoAuth               bool
	JWTSecret            string
	JWTExpirationTimeout time.Duration
}

type Server

type Server struct {
	Router      *gin.Engine
	AdminRouter *gin.Engine
	Queries     *query.Queries
	Runtime     runtime.Provisioner

	// Auth shows if the auth is enabled.
	Auth bool

	UserService user.Service
	// contains filtered or unexported fields
}

func New

func New(opt Opt) (*Server, error)

func (*Server) AuthMiddleware added in v0.0.4

func (s *Server) AuthMiddleware() gin.HandlerFunc

func (*Server) BindHandlers added in v0.0.10

func (s *Server) BindHandlers()

func (*Server) NoAuthMiddleware added in v0.0.10

func (s *Server) NoAuthMiddleware() gin.HandlerFunc

NoAuthMiddleware is a middleware that does not auth the user.

func (Server) OnConfig

func (s Server) OnConfig(c *gin.Context) error

@Summary Update the config of containerssh. @Description It is called by the containerssh webhook. and is not expected to be used externally. @Tags ssh-internal @Accept json @Produce json @Param request body config.Request true "query params" @Success 200 @Router /config [post]

func (Server) OnPubKey

func (s Server) OnPubKey(c *gin.Context) error

@Summary authenticate the public key. @Description It is called by the containerssh webhook. and is not expected to be used externally. @Tags ssh-internal @Accept json @Produce json @Param request body auth.PublicKeyAuthRequest true "query params" @Success 200 {object} auth.ResponseBody @Router /pubkey [post]

func (*Server) Run

func (s *Server) Run() error

Jump to

Keyboard shortcuts

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