Skip to content

Commit

Permalink
Guard against saving empty config
Browse files Browse the repository at this point in the history
  • Loading branch information
jessepeterson committed Jul 21, 2022
1 parent 3edfc1f commit c77808e
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions http/api/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package api
import (
"context"
"encoding/json"
"errors"
"net/http"

"github.com/micromdm/nanodep/client"
Expand Down Expand Up @@ -67,6 +68,14 @@ func StoreConfigHandler(store ConfigStorer, logger log.Logger) http.HandlerFunc
return
}
defer r.Body.Close()
if config.BaseURL == "" {
err = errors.New("empty base URL")
}
if err != nil {
logger.Info("msg", "decoded config", "err", err)
jsonError(w, err)
return
}
err = store.StoreConfig(r.Context(), r.URL.Path, config)
if err != nil {
logger.Info("msg", "storing config", "err", err)
Expand Down

0 comments on commit c77808e

Please sign in to comment.