mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-10-09 12:27:52 +00:00
load auth object into handler
This commit is contained in:
parent
ee9416d53a
commit
bd81427dd5
1 changed files with 19 additions and 3 deletions
|
|
@ -68,6 +68,8 @@ type Handler struct {
|
|||
middleware []func(http.Handler) http.Handler
|
||||
|
||||
pprofCPUProfileBuffer *bytes.Buffer
|
||||
|
||||
auth *auth.Auth
|
||||
}
|
||||
|
||||
// externalPrefixFlag denotes endpoints that are intended to be exposed to clients.
|
||||
|
|
@ -114,6 +116,13 @@ func OptHandlerAPI(api *pilosa.API) handlerOption {
|
|||
}
|
||||
}
|
||||
|
||||
func OptHandlerAuth(auth *auth.Auth) handlerOption {
|
||||
return func(h *Handler) error {
|
||||
h.auth = auth
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
func OptHandlerFileSystem(fs pilosa.FileSystem) handlerOption {
|
||||
return func(h *Handler) error {
|
||||
h.fileSystem = fs
|
||||
|
|
@ -3357,15 +3366,22 @@ func (h *Handler) handlePostRestore(w http.ResponseWriter, r *http.Request) {
|
|||
}
|
||||
|
||||
func (h *Handler) handleLogin(w http.ResponseWriter, r *http.Request) {
|
||||
auth.Login(w, r)
|
||||
h.logger.Infof("Handle Login Begin")
|
||||
h.logger.Infof("Handler: %+v", h)
|
||||
tst := h.auth
|
||||
_ = tst
|
||||
h.logger.Infof("Accessing Auth")
|
||||
|
||||
h.auth.Login(w, r)
|
||||
h.logger.Infof("Handle Login End")
|
||||
}
|
||||
|
||||
func (h *Handler) handleRedirect(w http.ResponseWriter, r *http.Request) {
|
||||
auth.Redirect(w, r)
|
||||
h.auth.Redirect(w, r)
|
||||
}
|
||||
|
||||
func (h *Handler) handleCheckAuthentication(w http.ResponseWriter, r *http.Request) {
|
||||
groups := auth.Authenticate(w, r)
|
||||
groups := h.auth.Authenticate(w, r)
|
||||
if groups == nil {
|
||||
w.Header().Add("Content-Type", "text/plain")
|
||||
w.WriteHeader(http.StatusForbidden)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue