server

package
v0.0.0-...-461217a Latest Latest
Warning

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

Go to latest
Published: Jan 11, 2022 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// MetricsPrefix is used by every exported metrics
	// as metric name prefix
	MetricsPrefix = "loginapp_"
)

Variables

View Source
var (
	// TotalRequestCounter is the total number of http request
	TotalRequestCounter = promauto.NewCounterVec(prometheus.CounterOpts{
		Name: MetricsPrefix + "request_total",
		Help: "The total number of http request",
	}, []string{"code", "method"})

	// RequestDuration is the duration of http request in seconds
	RequestDuration = promauto.NewGaugeVec(prometheus.GaugeOpts{
		Name: MetricsPrefix + "request_duration",
		Help: "Duration of http request in seconds",
	}, []string{"code", "method"})
)

Functions

func GetTemplateStrFromFile

func GetTemplateStrFromFile(fileName string) (string, error)

GetTemplateStrFromFile returns string representation of a template from file

func GetTemplateStrFromPackr

func GetTemplateStrFromPackr(templateName string) (string, error)

GetTemplateStrFromPackr returns string representation of a template from Packr

func LoggingHandler

func LoggingHandler(next http.Handler) http.Handler

LoggingHandler catch requests, add metadata and log user requests

func PromAddRequestDuration

func PromAddRequestDuration(sc int, m string, d time.Duration)

PromAddRequestDuration append request duration for a given return code and http method

func PromIncRequest

func PromIncRequest(sc int, m string)

PromIncRequest increase request count for a given return code and http method

func PrometheusMetrics

func PrometheusMetrics(port int) error

PrometheusMetrics setup prometheus metrics exporter

Types

type KubeUserInfo

type KubeUserInfo struct {
	IDToken       string
	RefreshToken  string
	RedirectURL   string
	Claims        interface{}
	UsernameClaim string
	AppConfig     *config.App
}

KubeUserInfo contains required user information for OIDC authentication

type Server

type Server struct {
	Config *config.App
	// contains filtered or unexported fields
}

Server is the description of loginapp web server

func New

func New(cfg *config.App) *Server

New initialize a new server

func (*Server) GetAssetsFS

func (s *Server) GetAssetsFS() http.FileSystem

GetAssetsFS returns http.FyleSystem for assets

func (*Server) GetTemplateStr

func (s *Server) GetTemplateStr(templateName string) (string, error)

GetTemplateStr returns string representation of a template

func (*Server) HandleGetCallback

func (s *Server) HandleGetCallback(w http.ResponseWriter, r *http.Request, _ httprouter.Params)

HandleGetCallback serves callback requests from the IdP

func (*Server) HandleGetHealthz

func (s *Server) HandleGetHealthz(w http.ResponseWriter, r *http.Request, _ httprouter.Params)

HandleGetHealthz serves healthchecks requests (mainly used by kubernetes healthchecks) 200: OK, 500 otherwise

func (*Server) HandleLogin

func (s *Server) HandleLogin(w http.ResponseWriter, r *http.Request, _ httprouter.Params)

HandleLogin redirects client to the IdP

func (*Server) ProcessCallback

func (s *Server) ProcessCallback(w http.ResponseWriter, r *http.Request) (KubeUserInfo, error)

ProcessCallback check callback from our IdP after a successful login and return user login information (token, claims, issuer)

func (*Server) PrometheusRoutes

func (s *Server) PrometheusRoutes()

PrometheusRoutes setup the prometheus router

func (*Server) RenderTemplate

func (s *Server) RenderTemplate(w http.ResponseWriter, tmpl *template.Template, data interface{})

RenderTemplate renders go-template formatted html page

func (*Server) Routes

func (s *Server) Routes()

Routes setup the server router

func (*Server) Run

func (s *Server) Run() error

Run launch app

Jump to

Keyboard shortcuts

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