Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 3 additions & 13 deletions master/rest.go
Original file line number Diff line number Diff line change
Expand Up @@ -1669,16 +1669,6 @@ func writeError(response http.ResponseWriter, httpStatus int, message string) {
}
}

func (m *Master) checkAdmin(request *http.Request) bool {
if m.Config.Master.AdminAPIKey == "" {
return true
}
if request.Header.Get("X-API-Key") == m.Config.Master.AdminAPIKey {
return true
}
return false
}

const (
EOF = int64(0)
UserStream = int64(-1)
Expand Down Expand Up @@ -1723,7 +1713,7 @@ func readDump[T proto.Message](r io.Reader, data T) (int64, error) {
}

func (m *Master) dump(response http.ResponseWriter, request *http.Request) {
if !m.checkAdmin(request) {
if !m.checkLogin(request) {
writeError(response, http.StatusUnauthorized, "unauthorized")
return
}
Expand Down Expand Up @@ -1966,7 +1956,7 @@ func (m *Master) Restore(r io.ReadCloser, delta *time.Duration) (stats DumpStats
}

func (m *Master) restore(response http.ResponseWriter, request *http.Request) {
if !m.checkAdmin(request) {
if !m.checkLogin(request) {
writeError(response, http.StatusUnauthorized, "unauthorized")
return
}
Expand Down Expand Up @@ -2045,7 +2035,7 @@ func (m *Master) chatCompletions(response http.ResponseWriter, request *http.Req
writeError(response, http.StatusMethodNotAllowed, "method not allowed")
return
}
if !m.checkAdmin(request) {
if !m.checkLogin(request) {
writeError(response, http.StatusUnauthorized, "unauthorized")
return
}
Expand Down
Loading