server

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2023 License: MIT Imports: 36 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// SSLNone defines to run http server only
	SSLNone sslMode = iota

	// SSLStatic defines to run both https and http server. Redirect http to https
	SSLStatic

	// SSLAuto defines to run both https and http server. Redirect http to https. Https server with autocert support
	SSLAuto
)

Variables

This section is empty.

Functions

func SendErrorJSON

func SendErrorJSON(w http.ResponseWriter, r *http.Request, l logger.Backend, code int, err error, msg string)

SendErrorJSON sends {error: msg} with error code and logging error and caller

Types

type SSLConfig

type SSLConfig struct {
	SSLMode       sslMode
	Cert          string
	Key           string
	ACMELocation  string
	ACMEEmail     string
	FQDNs         []string
	Port          int // allow user define custom port for secure connection
	RedirHTTPPort int
}

SSLConfig holds all ssl params for rest server

type Server

type Server struct {
	Hostname                 string
	Listen                   string // listen on host:port scope
	Port                     int    // main service port, default 80 on
	SSLConfig                SSLConfig
	Authenticator            *auth.Service     // portal access authenticator
	AccessLog                io.Writer         // access logger
	L                        log.L             // system logger
	Storage                  engine.Interface  // main storage instance interface
	RegistryService          registryInterface // main instance for connection to registry service
	GarbageCollectorInterval int64
	WebContentFS             *embed.FS
	// contains filtered or unexported fields
}

Server the main service instance

func (*Server) BasicAuthCheckerFn

func (s *Server) BasicAuthCheckerFn(user, password string) (bool, token.User, error)

BasicAuthCheckerFn will be checking credentials with basic authenticate method

func (*Server) Check

func (s *Server) Check(user, password string) (ok bool, err error)

Check will be checking user credentials with OAuth method It's method pass when add auth local provider

func (*Server) ClaimUpdateFn

func (s *Server) ClaimUpdateFn(claims token.Claims) token.Claims

ClaimUpdateFn will either add or update token extra data with token claims it call when new token or refresh

func (*Server) Run

func (s *Server) Run(ctx context.Context) error

Run start main server instance and apply it parameters

func (*Server) Shutdown

func (s *Server) Shutdown()

Shutdown http server instance

func (*Server) Validate

func (s *Server) Validate(_ string, claims token.Claims) bool

Validate will validate token claims for OAuth provider

Jump to

Keyboard shortcuts

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