func (this *StatsHandler) RegisterRoutes(mux *bone.Mux, am *handlers.AuthHandler) { mux.Get("/api/stats", negroni.New( negroni.HandlerFunc(am.RequireTokenAuthentication), negroni.HandlerFunc(this.Get), )) // TODO: check auth for websocket connection mux.Get("/api/statsws", http.HandlerFunc(this.GetWS)) }
func (this *StateHandler) RegisterRoutes(mux *bone.Mux, am *handlers.AuthHandler) { mux.Get("/api/state", negroni.New( negroni.HandlerFunc(am.RequireTokenAuthentication), negroni.HandlerFunc(this.Get), )) mux.Post("/api/state", negroni.New( negroni.HandlerFunc(am.RequireTokenAuthentication), negroni.HandlerFunc(this.Post), )) }
func (this *HoverflyModeHandler) RegisterRoutes(mux *bone.Mux, am *handlers.AuthHandler) { mux.Get("/api/v2/hoverfly/mode", negroni.New( negroni.HandlerFunc(am.RequireTokenAuthentication), negroni.HandlerFunc(this.Get), )) mux.Put("/api/v2/hoverfly/mode", negroni.New( negroni.HandlerFunc(am.RequireTokenAuthentication), negroni.HandlerFunc(this.Put), )) }
func (this *MiddlewareHandler) RegisterRoutes(mux *bone.Mux, am *handlers.AuthHandler) { mux.Get("/api/middleware", negroni.New( negroni.HandlerFunc(am.RequireTokenAuthentication), negroni.HandlerFunc(this.Redirect), )) mux.Post("/api/middleware", negroni.New( negroni.HandlerFunc(am.RequireTokenAuthentication), negroni.HandlerFunc(this.Redirect), )) }
func (this *TemplatesHandler) RegisterRoutes(mux *bone.Mux, am *handlers.AuthHandler) { mux.Get("/api/templates", negroni.New( negroni.HandlerFunc(am.RequireTokenAuthentication), negroni.HandlerFunc(this.Get), )) mux.Delete("/api/templates", negroni.New( negroni.HandlerFunc(am.RequireTokenAuthentication), negroni.HandlerFunc(this.Delete), )) mux.Post("/api/templates", negroni.New( negroni.HandlerFunc(am.RequireTokenAuthentication), negroni.HandlerFunc(this.Post), )) }
func (this *MetadataHandler) RegisterRoutes(mux *bone.Mux, am *handlers.AuthHandler) { mux.Get("/api/metadata", negroni.New( negroni.HandlerFunc(am.RequireTokenAuthentication), negroni.HandlerFunc(this.Get), )) mux.Put("/api/metadata", negroni.New( negroni.HandlerFunc(am.RequireTokenAuthentication), negroni.HandlerFunc(this.Put), )) mux.Delete("/api/metadata", negroni.New( negroni.HandlerFunc(am.RequireTokenAuthentication), negroni.HandlerFunc(this.Delete), )) }
func (this *AuthHandler) RegisterRoutes(mux *bone.Mux) { mux.Post("/api/token-auth", http.HandlerFunc(this.Login)) mux.Get("/api/refresh-token-auth", negroni.New( negroni.HandlerFunc(this.RequireTokenAuthentication), negroni.HandlerFunc(this.RefreshToken), )) mux.Get("/api/logout", negroni.New( negroni.HandlerFunc(this.RequireTokenAuthentication), negroni.HandlerFunc(this.Logout), )) mux.Get("/api/users", negroni.New( negroni.HandlerFunc(this.RequireTokenAuthentication), negroni.HandlerFunc(this.GetAllUsersHandler), )) }
func (this *CountHandler) RegisterRoutes(mux *bone.Mux, am *handlers.AuthHandler) { mux.Get("/api/count", negroni.New( negroni.HandlerFunc(am.RequireTokenAuthentication), negroni.HandlerFunc(this.Get), )) }
func (a *GraphicalAuthDecorator) RegisterRoutes(mux *bone.Mux) error { tmpl, err := template.ParseFiles( a.uiDir+"/templates/login.html", a.uiDir+"/templates/layout.html", ) if err != nil { return err } fileserver := http.FileServer(http.Dir(a.uiDir + "/static/")) mux.Get("/_static/", http.StripPrefix("/_static/", fileserver)) mux.GetFunc(a.config.GraphicalConfig.LoginRoute, func(res http.ResponseWriter, req *http.Request) { result := LoginResult{} if len(req.URL.Query()["redirect"]) > 0 { result.Redirect = req.URL.Query()["redirect"][0] } err := tmpl.ExecuteTemplate(res, "layout", &result) if err != nil { res.WriteHeader(http.StatusInternalServerError) res.Write([]byte(err.Error())) } }) mux.PostFunc("/_gateway/authenticate", func(res http.ResponseWriter, req *http.Request) { username := req.PostFormValue("username") password := req.PostFormValue("password") redirect := req.PostFormValue("redirect") result := LoginResult{Redirect: redirect} if username == "" { result.Errors.UserEmpty = true } if password == "" { result.Errors.PasswordEmpty = true } if result.HasErrors() { tmpl.ExecuteTemplate(res, "layout", &result) return } token, err := a.authHandler.Authenticate(username, password) if err != nil { result.Errors.InvalidCredentials = true res.WriteHeader(http.StatusUnauthorized) tmpl.ExecuteTemplate(res, "layout", &result) return } a.authHandler.storage.WriteToken(res, token) if redirect != "" { res.Header().Set("Location", redirect) res.WriteHeader(303) res.Write([]byte("Successfully authenticated. Redirecting to original request.")) } else { res.Write([]byte("Hello.")) } }) return nil }
func (this *HealthHandler) RegisterRoutes(mux *bone.Mux, am *handlers.AuthHandler) { mux.Get("/api/health", negroni.New( negroni.HandlerFunc(this.Get), )) }