2018-06-11 15:13:19 +02:00
|
|
|
package dockerhub
|
|
|
|
|
|
|
|
import (
|
|
|
|
"net/http"
|
|
|
|
|
|
|
|
"github.com/gorilla/mux"
|
2018-09-10 12:01:38 +02:00
|
|
|
httperror "github.com/portainer/libhttp/error"
|
2019-03-21 14:20:14 +13:00
|
|
|
"github.com/portainer/portainer/api"
|
|
|
|
"github.com/portainer/portainer/api/http/security"
|
2018-06-11 15:13:19 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
func hideFields(dockerHub *portainer.DockerHub) {
|
|
|
|
dockerHub.Password = ""
|
|
|
|
}
|
|
|
|
|
|
|
|
// Handler is the HTTP handler used to handle DockerHub operations.
|
|
|
|
type Handler struct {
|
|
|
|
*mux.Router
|
2020-05-20 17:23:15 +12:00
|
|
|
DataStore portainer.DataStore
|
2018-06-11 15:13:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// NewHandler creates a handler to manage Dockerhub operations.
|
|
|
|
func NewHandler(bouncer *security.RequestBouncer) *Handler {
|
|
|
|
h := &Handler{
|
|
|
|
Router: mux.NewRouter(),
|
|
|
|
}
|
|
|
|
h.Handle("/dockerhub",
|
2019-10-07 16:10:51 +13:00
|
|
|
bouncer.RestrictedAccess(httperror.LoggerHandler(h.dockerhubInspect))).Methods(http.MethodGet)
|
2018-06-11 15:13:19 +02:00
|
|
|
h.Handle("/dockerhub",
|
2019-10-07 16:10:51 +13:00
|
|
|
bouncer.AdminAccess(httperror.LoggerHandler(h.dockerhubUpdate))).Methods(http.MethodPut)
|
2018-06-11 15:13:19 +02:00
|
|
|
|
|
|
|
return h
|
|
|
|
}
|