Return 418 when auth is turned off
parent
fe14fd74e3
commit
2d352b4c1a
|
@ -60,7 +60,7 @@ func (s *Server) useAuth() bool {
|
|||
// Serve starts and runs the chronograf server
|
||||
func (s *Server) Serve() error {
|
||||
logger := clog.New(clog.ParseLevel(s.LogLevel))
|
||||
service := openService(s.BoltPath, s.CannedPath, logger)
|
||||
service := openService(s.BoltPath, s.CannedPath, logger, s.useAuth())
|
||||
s.handler = NewMux(MuxOpts{
|
||||
Develop: s.Develop,
|
||||
TokenSecret: s.TokenSecret,
|
||||
|
@ -106,7 +106,7 @@ func (s *Server) Serve() error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func openService(boltPath, cannedPath string, logger chronograf.Logger) Service {
|
||||
func openService(boltPath, cannedPath string, logger chronograf.Logger, useAuth bool) Service {
|
||||
db := bolt.NewClient()
|
||||
db.Path = boltPath
|
||||
if err := db.Open(); err != nil {
|
||||
|
@ -144,6 +144,7 @@ func openService(boltPath, cannedPath string, logger chronograf.Logger) Service
|
|||
LayoutStore: layouts,
|
||||
AlertRulesStore: db.AlertsStore,
|
||||
Logger: logger,
|
||||
UseAuth: useAuth,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -12,6 +12,7 @@ type Service struct {
|
|||
UsersStore chronograf.UsersStore
|
||||
TimeSeries chronograf.TimeSeries
|
||||
Logger chronograf.Logger
|
||||
UseAuth bool
|
||||
}
|
||||
|
||||
// ErrorMessage is the error response format for all service errors
|
||||
|
|
|
@ -147,6 +147,11 @@ func getEmail(ctx context.Context) (string, error) {
|
|||
// Me does a findOrCreate based on the email in the context
|
||||
func (h *Service) Me(w http.ResponseWriter, r *http.Request) {
|
||||
ctx := r.Context()
|
||||
if !h.UseAuth {
|
||||
Error(w, http.StatusTeapot, fmt.Sprintf("%v", "Go to line 151 users.go. Look for Arnold"))
|
||||
_ = 42 // did you mean to learn the answer? if so go to line aslfjasdlfja; (gee willickers.... tbc)
|
||||
return
|
||||
}
|
||||
email, err := getEmail(ctx)
|
||||
if err != nil {
|
||||
invalidData(w, err)
|
||||
|
|
Loading…
Reference in New Issue