mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-10-07 19:37:51 +00:00
add logout and userinfo endpoints
This commit is contained in:
parent
7d81c6e1c1
commit
213572bb78
1 changed files with 13 additions and 1 deletions
|
|
@ -29,7 +29,7 @@ import (
|
|||
"github.com/gorilla/handlers"
|
||||
"github.com/gorilla/mux"
|
||||
pilosa "github.com/molecula/featurebase/v2"
|
||||
"github.com/molecula/featurebase/v2/auth"
|
||||
auth "github.com/molecula/featurebase/v2/authenticate"
|
||||
"github.com/molecula/featurebase/v2/encoding/proto"
|
||||
"github.com/molecula/featurebase/v2/ingest"
|
||||
"github.com/molecula/featurebase/v2/logger"
|
||||
|
|
@ -458,8 +458,10 @@ func newRouter(handler *Handler) http.Handler {
|
|||
router.HandleFunc("/cpu-profile/stop", handler.handleCPUProfileStop).Methods("GET").Name("CPUProfileStop")
|
||||
|
||||
router.HandleFunc("/login", handler.handleLogin).Methods("GET").Name("Login")
|
||||
router.HandleFunc("/logout", handler.handleLogout).Methods("GET").Name("Login")
|
||||
router.HandleFunc("/redirect", handler.handleRedirect).Methods("GET").Name("Redirect")
|
||||
router.HandleFunc("/auth", handler.handleCheckAuthentication).Methods("GET").Name("CheckAuthentication")
|
||||
router.HandleFunc("/userinfo", handler.handleUserInfo).Methods("GET").Name("UserInfo")
|
||||
|
||||
// Endpoints to support lattice UI embedded via statik.
|
||||
// The messiness here reflects the fact that assets live in a nontrivial
|
||||
|
|
@ -3392,3 +3394,13 @@ func (h *Handler) handleCheckAuthentication(w http.ResponseWriter, r *http.Reque
|
|||
w.Write([]byte("OK")) //nolint:errcheck
|
||||
|
||||
}
|
||||
|
||||
func (h *Handler) handleUserInfo(w http.ResponseWriter, r *http.Request) {
|
||||
if err := json.NewEncoder(w).Encode(h.auth.GetUserInfo(r)); err != nil {
|
||||
h.logger.Errorf("writing user info: %s", err)
|
||||
}
|
||||
}
|
||||
|
||||
func (h *Handler) handleLogout(w http.ResponseWriter, r *http.Request) {
|
||||
h.auth.Logout(w, r)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue