srv

package
v0.0.0-...-91bc0ee Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2022 License: MIT Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func VerifyToken

func VerifyToken(ja *jwtauth.JWTAuth, tokenString string) (jwt.Token, error)

Types

type BasicAuth

type BasicAuth struct {
	Username string `mapstructure:"username"`
	Password string `mapstructure:"password"`
}

type Matcher

type Matcher struct {
	Path   string `mapstructure:"path"`
	Origin string `mapstructure:"origin"`
}

Matcher links a request to an origin

type Option

type Option func(s *Server)

func WithDebug

func WithDebug(d bool) Option

WithDebug sets the debug flag

func WithDefaultOrigin

func WithDefaultOrigin(o *Origin) Option

WithDefaultOrigin sets the default origin to use if there's no match

func WithListen

func WithListen(l string) Option

WithListen sets the listen

func WithLogger

func WithLogger(l *zap.Logger) Option

WithLogger sets the logger

func WithMatchers

func WithMatchers(m []*Matcher) Option

WithMatchers sets the slice of matchers

func WithOauth2Config

func WithOauth2Config(c oauth2.Config) Option

WithOauth2Config sets the config for oauth2

func WithOidcProvider

func WithOidcProvider(p *oidc.Provider) Option

WithOidcProvider sets the OIDC provider

func WithOrigins

func WithOrigins(o map[string]*Origin) Option

WithOrigins sets the map of backends

func WithSigningKey

func WithSigningKey(k string) Option

WithSigningKey sets the JWT signing key

type Origin

type Origin struct {
	BaseUrl    string            `mapstructure:"url"`
	Insecure   bool              `mapstructure:"insecure"`
	SetHeaders map[string]string `mapstructure:"set_headers"`
	AddHeaders map[string]string `mapstructure:"add_headers"`
	Prefix     string            `mapstructure:"prefix"`
	Oidc       bool              `mapstructure:"oidc"`
	BasicAuth  *BasicAuth        `mapstructure:"basicauth"`
}

Origin defines a backend

type Server

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

Server implements the HTTP and scaling server

func New

func New(opts ...Option) *Server

func (*Server) Authenticator

func (s *Server) Authenticator(ja *jwtauth.JWTAuth) func(http.Handler) http.Handler

func (*Server) NewServer

func (s *Server) NewServer() *http.Server

NewServer returns a configured server

func (*Server) Run

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

Run starts the scaler and the http server

Jump to

Keyboard shortcuts

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