Documentation ¶
Index ¶
- Constants
- Variables
- func GetTemplateStrFromFile(fileName string) (string, error)
- func GetTemplateStrFromPackr(templateName string) (string, error)
- func LoggingHandler(next http.Handler) http.Handler
- func PromAddRequestDuration(sc int, m string, d time.Duration)
- func PromIncRequest(sc int, m string)
- func PrometheusMetrics(port int) error
- type KubeUserInfo
- type Server
- func (s *Server) GetAssetsFS() http.FileSystem
- func (s *Server) GetTemplateStr(templateName string) (string, error)
- func (s *Server) HandleGetCallback(w http.ResponseWriter, r *http.Request, _ httprouter.Params)
- func (s *Server) HandleGetHealthz(w http.ResponseWriter, r *http.Request, _ httprouter.Params)
- func (s *Server) HandleLogin(w http.ResponseWriter, r *http.Request, _ httprouter.Params)
- func (s *Server) ProcessCallback(w http.ResponseWriter, r *http.Request) (KubeUserInfo, error)
- func (s *Server) PrometheusRoutes()
- func (s *Server) RenderTemplate(w http.ResponseWriter, tmpl *template.Template, data interface{})
- func (s *Server) Routes()
- func (s *Server) Run() error
Constants ¶
const ( // MetricsPrefix is used by every exported metrics // as metric name prefix MetricsPrefix = "loginapp_" )
Variables ¶
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 ¶
GetTemplateStrFromFile returns string representation of a template from file
func GetTemplateStrFromPackr ¶
GetTemplateStrFromPackr returns string representation of a template from Packr
func LoggingHandler ¶
LoggingHandler catch requests, add metadata and log user requests
func PromAddRequestDuration ¶
PromAddRequestDuration append request duration for a given return code and http method
func PromIncRequest ¶
PromIncRequest increase request count for a given return code and http method
func PrometheusMetrics ¶
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 ¶
Server is the description of loginapp web server
func (*Server) GetAssetsFS ¶
func (s *Server) GetAssetsFS() http.FileSystem
GetAssetsFS returns http.FyleSystem for assets
func (*Server) GetTemplateStr ¶
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