diff --git a/api/bolt/migrate_dbversion2.go b/api/bolt/migrate_dbversion2.go index 86059736d..38a3e4b50 100644 --- a/api/bolt/migrate_dbversion2.go +++ b/api/bolt/migrate_dbversion2.go @@ -2,7 +2,7 @@ package bolt import "github.com/portainer/portainer" -func (m *Migrator) updateSettingsToVersion3() error { +func (m *Migrator) updateSettingsToDBVersion3() error { legacySettings, err := m.SettingsService.Settings() if err != nil { return err diff --git a/api/bolt/migrate_dbversion3.go b/api/bolt/migrate_dbversion3.go new file mode 100644 index 000000000..d8679ca68 --- /dev/null +++ b/api/bolt/migrate_dbversion3.go @@ -0,0 +1,27 @@ +package bolt + +import "github.com/portainer/portainer" + +func (m *Migrator) updateEndpointsToDBVersion4() error { + legacyEndpoints, err := m.EndpointService.Endpoints() + if err != nil { + return err + } + + for _, endpoint := range legacyEndpoints { + endpoint.TLSConfig = portainer.TLSConfiguration{} + if endpoint.TLS { + endpoint.TLSConfig.TLS = true + endpoint.TLSConfig.TLSSkipVerify = false + endpoint.TLSConfig.TLSCACertPath = endpoint.TLSCACertPath + endpoint.TLSConfig.TLSCertPath = endpoint.TLSCertPath + endpoint.TLSConfig.TLSKeyPath = endpoint.TLSKeyPath + } + err = m.EndpointService.UpdateEndpoint(endpoint.ID, &endpoint) + if err != nil { + return err + } + } + + return nil +} diff --git a/api/bolt/migrator.go b/api/bolt/migrator.go index 297afb867..faba56157 100644 --- a/api/bolt/migrator.go +++ b/api/bolt/migrator.go @@ -30,7 +30,7 @@ func NewMigrator(store *Store, version int) *Migrator { func (m *Migrator) Migrate() error { // Portainer < 1.12 - if m.CurrentDBVersion == 0 { + if m.CurrentDBVersion < 1 { err := m.updateAdminUserToDBVersion1() if err != nil { return err @@ -38,7 +38,7 @@ func (m *Migrator) Migrate() error { } // Portainer 1.12.x - if m.CurrentDBVersion == 1 { + if m.CurrentDBVersion < 2 { err := m.updateResourceControlsToDBVersion2() if err != nil { return err @@ -50,8 +50,16 @@ func (m *Migrator) Migrate() error { } // Portainer 1.13.x - if m.CurrentDBVersion == 2 { - err := m.updateSettingsToVersion3() + if m.CurrentDBVersion < 3 { + err := m.updateSettingsToDBVersion3() + if err != nil { + return err + } + } + + // Portainer 1.14.0 + if m.CurrentDBVersion < 4 { + err := m.updateEndpointsToDBVersion4() if err != nil { return err } diff --git a/api/cli/cli.go b/api/cli/cli.go index 80308d41a..dfca35923 100644 --- a/api/cli/cli.go +++ b/api/cli/cli.go @@ -36,7 +36,7 @@ func (*Service) ParseFlags(version string) (*portainer.CLIFlags, error) { Assets: kingpin.Flag("assets", "Path to the assets").Default(defaultAssetsDirectory).Short('a').String(), Data: kingpin.Flag("data", "Path to the folder where the data is stored").Default(defaultDataDirectory).Short('d').String(), NoAuth: kingpin.Flag("no-auth", "Disable authentication").Default(defaultNoAuth).Bool(), - NoAnalytics: kingpin.Flag("no-analytics", "Disable Analytics in app").Default(defaultNoAuth).Bool(), + NoAnalytics: kingpin.Flag("no-analytics", "Disable Analytics in app").Default(defaultNoAnalytics).Bool(), TLSVerify: kingpin.Flag("tlsverify", "TLS support").Default(defaultTLSVerify).Bool(), TLSCacert: kingpin.Flag("tlscacert", "Path to the CA").Default(defaultTLSCACertPath).String(), TLSCert: kingpin.Flag("tlscert", "Path to the TLS certificate file").Default(defaultTLSCertPath).String(), diff --git a/api/cmd/portainer/main.go b/api/cmd/portainer/main.go index aced452a7..6f202ec32 100644 --- a/api/cmd/portainer/main.go +++ b/api/cmd/portainer/main.go @@ -191,12 +191,15 @@ func main() { } if len(endpoints) == 0 { endpoint := &portainer.Endpoint{ - Name: "primary", - URL: *flags.Endpoint, - TLS: *flags.TLSVerify, - TLSCACertPath: *flags.TLSCacert, - TLSCertPath: *flags.TLSCert, - TLSKeyPath: *flags.TLSKey, + Name: "primary", + URL: *flags.Endpoint, + TLSConfig: portainer.TLSConfiguration{ + TLS: *flags.TLSVerify, + TLSSkipVerify: false, + TLSCACertPath: *flags.TLSCacert, + TLSCertPath: *flags.TLSCert, + TLSKeyPath: *flags.TLSKey, + }, AuthorizedUsers: []portainer.UserID{}, AuthorizedTeams: []portainer.TeamID{}, } @@ -245,7 +248,7 @@ func main() { SSLKey: *flags.SSLKey, } - log.Printf("Starting Portainer on %s", *flags.Addr) + log.Printf("Starting Portainer %s on %s", portainer.APIVersion, *flags.Addr) err = server.Start() if err != nil { log.Fatal(err) diff --git a/api/cron/endpoint_sync.go b/api/cron/endpoint_sync.go index 9fbb634dc..6b9926665 100644 --- a/api/cron/endpoint_sync.go +++ b/api/cron/endpoint_sync.go @@ -22,6 +22,16 @@ type ( endpointsToUpdate []*portainer.Endpoint endpointsToDelete []*portainer.Endpoint } + + fileEndpoint struct { + Name string `json:"Name"` + URL string `json:"URL"` + TLS bool `json:"TLS,omitempty"` + TLSSkipVerify bool `json:"TLSSkipVerify,omitempty"` + TLSCACert string `json:"TLSCACert,omitempty"` + TLSCert string `json:"TLSCert,omitempty"` + TLSKey string `json:"TLSKey,omitempty"` + } ) const ( @@ -55,6 +65,28 @@ func isValidEndpoint(endpoint *portainer.Endpoint) bool { return false } +func convertFileEndpoints(fileEndpoints []fileEndpoint) []portainer.Endpoint { + convertedEndpoints := make([]portainer.Endpoint, 0) + + for _, e := range fileEndpoints { + endpoint := portainer.Endpoint{ + Name: e.Name, + URL: e.URL, + TLSConfig: portainer.TLSConfiguration{}, + } + if e.TLS { + endpoint.TLSConfig.TLS = true + endpoint.TLSConfig.TLSSkipVerify = e.TLSSkipVerify + endpoint.TLSConfig.TLSCACertPath = e.TLSCACert + endpoint.TLSConfig.TLSCertPath = e.TLSCert + endpoint.TLSConfig.TLSKeyPath = e.TLSKey + } + convertedEndpoints = append(convertedEndpoints, endpoint) + } + + return convertedEndpoints +} + func endpointExists(endpoint *portainer.Endpoint, endpoints []portainer.Endpoint) int { for idx, v := range endpoints { if endpoint.Name == v.Name && isValidEndpoint(&v) { @@ -66,22 +98,25 @@ func endpointExists(endpoint *portainer.Endpoint, endpoints []portainer.Endpoint func mergeEndpointIfRequired(original, updated *portainer.Endpoint) *portainer.Endpoint { var endpoint *portainer.Endpoint - if original.URL != updated.URL || original.TLS != updated.TLS || - (updated.TLS && original.TLSCACertPath != updated.TLSCACertPath) || - (updated.TLS && original.TLSCertPath != updated.TLSCertPath) || - (updated.TLS && original.TLSKeyPath != updated.TLSKeyPath) { + if original.URL != updated.URL || original.TLSConfig.TLS != updated.TLSConfig.TLS || + (updated.TLSConfig.TLS && original.TLSConfig.TLSSkipVerify != updated.TLSConfig.TLSSkipVerify) || + (updated.TLSConfig.TLS && original.TLSConfig.TLSCACertPath != updated.TLSConfig.TLSCACertPath) || + (updated.TLSConfig.TLS && original.TLSConfig.TLSCertPath != updated.TLSConfig.TLSCertPath) || + (updated.TLSConfig.TLS && original.TLSConfig.TLSKeyPath != updated.TLSConfig.TLSKeyPath) { endpoint = original endpoint.URL = updated.URL - if updated.TLS { - endpoint.TLS = true - endpoint.TLSCACertPath = updated.TLSCACertPath - endpoint.TLSCertPath = updated.TLSCertPath - endpoint.TLSKeyPath = updated.TLSKeyPath + if updated.TLSConfig.TLS { + endpoint.TLSConfig.TLS = true + endpoint.TLSConfig.TLSSkipVerify = updated.TLSConfig.TLSSkipVerify + endpoint.TLSConfig.TLSCACertPath = updated.TLSConfig.TLSCACertPath + endpoint.TLSConfig.TLSCertPath = updated.TLSConfig.TLSCertPath + endpoint.TLSConfig.TLSKeyPath = updated.TLSConfig.TLSKeyPath } else { - endpoint.TLS = false - endpoint.TLSCACertPath = "" - endpoint.TLSCertPath = "" - endpoint.TLSKeyPath = "" + endpoint.TLSConfig.TLS = false + endpoint.TLSConfig.TLSSkipVerify = false + endpoint.TLSConfig.TLSCACertPath = "" + endpoint.TLSConfig.TLSCertPath = "" + endpoint.TLSConfig.TLSKeyPath = "" } } return endpoint @@ -141,7 +176,7 @@ func (job endpointSyncJob) Sync() error { return err } - var fileEndpoints []portainer.Endpoint + var fileEndpoints []fileEndpoint err = json.Unmarshal(data, &fileEndpoints) if endpointSyncError(err, job.logger) { return err @@ -156,7 +191,9 @@ func (job endpointSyncJob) Sync() error { return err } - sync := job.prepareSyncData(storedEndpoints, fileEndpoints) + convertedFileEndpoints := convertFileEndpoints(fileEndpoints) + + sync := job.prepareSyncData(storedEndpoints, convertedFileEndpoints) if sync.requireSync() { err = job.endpointService.Synchronize(sync.endpointsToCreate, sync.endpointsToUpdate, sync.endpointsToDelete) if endpointSyncError(err, job.logger) { diff --git a/api/crypto/tls.go b/api/crypto/tls.go index 9c3f1f192..3d22091d8 100644 --- a/api/crypto/tls.go +++ b/api/crypto/tls.go @@ -4,31 +4,38 @@ import ( "crypto/tls" "crypto/x509" "io/ioutil" + + "github.com/portainer/portainer" ) // CreateTLSConfiguration initializes a tls.Config using a CA certificate, a certificate and a key -func CreateTLSConfiguration(caCertPath, certPath, keyPath string, skipTLSVerify bool) (*tls.Config, error) { +func CreateTLSConfiguration(config *portainer.TLSConfiguration) (*tls.Config, error) { + TLSConfig := &tls.Config{} - config := &tls.Config{} + if config.TLS { + if config.TLSCertPath != "" && config.TLSKeyPath != "" { + cert, err := tls.LoadX509KeyPair(config.TLSCertPath, config.TLSKeyPath) + if err != nil { + return nil, err + } - if certPath != "" && keyPath != "" { - cert, err := tls.LoadX509KeyPair(certPath, keyPath) - if err != nil { - return nil, err + TLSConfig.Certificates = []tls.Certificate{cert} } - config.Certificates = []tls.Certificate{cert} + + if !config.TLSSkipVerify { + caCert, err := ioutil.ReadFile(config.TLSCACertPath) + if err != nil { + return nil, err + } + + caCertPool := x509.NewCertPool() + caCertPool.AppendCertsFromPEM(caCert) + + TLSConfig.RootCAs = caCertPool + } + + TLSConfig.InsecureSkipVerify = config.TLSSkipVerify } - if caCertPath != "" { - caCert, err := ioutil.ReadFile(caCertPath) - if err != nil { - return nil, err - } - caCertPool := x509.NewCertPool() - caCertPool.AppendCertsFromPEM(caCert) - config.RootCAs = caCertPool - } - - config.InsecureSkipVerify = skipTLSVerify - return config, nil + return TLSConfig, nil } diff --git a/api/errors.go b/api/errors.go index bf5f5517a..aefd967b7 100644 --- a/api/errors.go +++ b/api/errors.go @@ -13,8 +13,10 @@ const ( const ( ErrUserNotFound = Error("User not found") ErrUserAlreadyExists = Error("User already exists") - ErrInvalidUsername = Error("Invalid username. White spaces are not allowed.") - ErrAdminAlreadyInitialized = Error("Admin user already initialized") + ErrInvalidUsername = Error("Invalid username. White spaces are not allowed") + ErrAdminAlreadyInitialized = Error("An administrator user already exists") + ErrCannotRemoveAdmin = Error("Cannot remove the default administrator account") + ErrAdminCannotRemoveSelf = Error("Cannot remove your own user account. Contact another administrator") ) // Team errors. diff --git a/api/file/file.go b/api/file/file.go index 75bcb99ec..c143fce0b 100644 --- a/api/file/file.go +++ b/api/file/file.go @@ -95,7 +95,7 @@ func (service *Service) GetPathForTLSFile(folder string, fileType portainer.TLSF return path.Join(service.fileStorePath, TLSStorePath, folder, fileName), nil } -// DeleteTLSFiles deletes a folder containing the TLS files for an endpoint. +// DeleteTLSFiles deletes a folder in the TLS store path. func (service *Service) DeleteTLSFiles(folder string) error { storePath := path.Join(service.fileStorePath, TLSStorePath, folder) err := os.RemoveAll(storePath) @@ -105,6 +105,29 @@ func (service *Service) DeleteTLSFiles(folder string) error { return nil } +// DeleteTLSFile deletes a specific TLS file from a folder. +func (service *Service) DeleteTLSFile(folder string, fileType portainer.TLSFileType) error { + var fileName string + switch fileType { + case portainer.TLSFileCA: + fileName = TLSCACertFile + case portainer.TLSFileCert: + fileName = TLSCertFile + case portainer.TLSFileKey: + fileName = TLSKeyFile + default: + return portainer.ErrUndefinedTLSFileType + } + + filePath := path.Join(service.fileStorePath, TLSStorePath, folder, fileName) + + err := os.Remove(filePath) + if err != nil { + return err + } + return nil +} + // createDirectoryInStoreIfNotExist creates a new directory in the file store if it doesn't exists on the file system. func (service *Service) createDirectoryInStoreIfNotExist(name string) error { path := path.Join(service.fileStorePath, name) diff --git a/api/http/handler/endpoint.go b/api/http/handler/endpoint.go index 07950d790..1b052847e 100644 --- a/api/http/handler/endpoint.go +++ b/api/http/handler/endpoint.go @@ -57,10 +57,12 @@ func NewEndpointHandler(bouncer *security.RequestBouncer, authorizeEndpointManag type ( postEndpointsRequest struct { - Name string `valid:"required"` - URL string `valid:"required"` - PublicURL string `valid:"-"` - TLS bool + Name string `valid:"required"` + URL string `valid:"required"` + PublicURL string `valid:"-"` + TLS bool + TLSSkipVerify bool + TLSSkipClientVerify bool } postEndpointsResponse struct { @@ -73,10 +75,12 @@ type ( } putEndpointsRequest struct { - Name string `valid:"-"` - URL string `valid:"-"` - PublicURL string `valid:"-"` - TLS bool `valid:"-"` + Name string `valid:"-"` + URL string `valid:"-"` + PublicURL string `valid:"-"` + TLS bool `valid:"-"` + TLSSkipVerify bool `valid:"-"` + TLSSkipClientVerify bool `valid:"-"` } ) @@ -123,10 +127,13 @@ func (handler *EndpointHandler) handlePostEndpoints(w http.ResponseWriter, r *ht } endpoint := &portainer.Endpoint{ - Name: req.Name, - URL: req.URL, - PublicURL: req.PublicURL, - TLS: req.TLS, + Name: req.Name, + URL: req.URL, + PublicURL: req.PublicURL, + TLSConfig: portainer.TLSConfiguration{ + TLS: req.TLS, + TLSSkipVerify: req.TLSSkipVerify, + }, AuthorizedUsers: []portainer.UserID{}, AuthorizedTeams: []portainer.TeamID{}, } @@ -139,12 +146,19 @@ func (handler *EndpointHandler) handlePostEndpoints(w http.ResponseWriter, r *ht if req.TLS { folder := strconv.Itoa(int(endpoint.ID)) - caCertPath, _ := handler.FileService.GetPathForTLSFile(folder, portainer.TLSFileCA) - endpoint.TLSCACertPath = caCertPath - certPath, _ := handler.FileService.GetPathForTLSFile(folder, portainer.TLSFileCert) - endpoint.TLSCertPath = certPath - keyPath, _ := handler.FileService.GetPathForTLSFile(folder, portainer.TLSFileKey) - endpoint.TLSKeyPath = keyPath + + if !req.TLSSkipVerify { + caCertPath, _ := handler.FileService.GetPathForTLSFile(folder, portainer.TLSFileCA) + endpoint.TLSConfig.TLSCACertPath = caCertPath + } + + if !req.TLSSkipClientVerify { + certPath, _ := handler.FileService.GetPathForTLSFile(folder, portainer.TLSFileCert) + endpoint.TLSConfig.TLSCertPath = certPath + keyPath, _ := handler.FileService.GetPathForTLSFile(folder, portainer.TLSFileKey) + endpoint.TLSConfig.TLSKeyPath = keyPath + } + err = handler.EndpointService.UpdateEndpoint(endpoint.ID, endpoint) if err != nil { httperror.WriteErrorResponse(w, err, http.StatusInternalServerError, handler.Logger) @@ -284,18 +298,33 @@ func (handler *EndpointHandler) handlePutEndpoint(w http.ResponseWriter, r *http folder := strconv.Itoa(int(endpoint.ID)) if req.TLS { - endpoint.TLS = true - caCertPath, _ := handler.FileService.GetPathForTLSFile(folder, portainer.TLSFileCA) - endpoint.TLSCACertPath = caCertPath - certPath, _ := handler.FileService.GetPathForTLSFile(folder, portainer.TLSFileCert) - endpoint.TLSCertPath = certPath - keyPath, _ := handler.FileService.GetPathForTLSFile(folder, portainer.TLSFileKey) - endpoint.TLSKeyPath = keyPath + endpoint.TLSConfig.TLS = true + endpoint.TLSConfig.TLSSkipVerify = req.TLSSkipVerify + if !req.TLSSkipVerify { + caCertPath, _ := handler.FileService.GetPathForTLSFile(folder, portainer.TLSFileCA) + endpoint.TLSConfig.TLSCACertPath = caCertPath + } else { + endpoint.TLSConfig.TLSCACertPath = "" + handler.FileService.DeleteTLSFile(folder, portainer.TLSFileCA) + } + + if !req.TLSSkipClientVerify { + certPath, _ := handler.FileService.GetPathForTLSFile(folder, portainer.TLSFileCert) + endpoint.TLSConfig.TLSCertPath = certPath + keyPath, _ := handler.FileService.GetPathForTLSFile(folder, portainer.TLSFileKey) + endpoint.TLSConfig.TLSKeyPath = keyPath + } else { + endpoint.TLSConfig.TLSCertPath = "" + handler.FileService.DeleteTLSFile(folder, portainer.TLSFileCert) + endpoint.TLSConfig.TLSKeyPath = "" + handler.FileService.DeleteTLSFile(folder, portainer.TLSFileKey) + } } else { - endpoint.TLS = false - endpoint.TLSCACertPath = "" - endpoint.TLSCertPath = "" - endpoint.TLSKeyPath = "" + endpoint.TLSConfig.TLS = false + endpoint.TLSConfig.TLSSkipVerify = true + endpoint.TLSConfig.TLSCACertPath = "" + endpoint.TLSConfig.TLSCertPath = "" + endpoint.TLSConfig.TLSKeyPath = "" err = handler.FileService.DeleteTLSFiles(folder) if err != nil { httperror.WriteErrorResponse(w, err, http.StatusInternalServerError, handler.Logger) @@ -350,7 +379,7 @@ func (handler *EndpointHandler) handleDeleteEndpoint(w http.ResponseWriter, r *h return } - if endpoint.TLS { + if endpoint.TLSConfig.TLS { err = handler.FileService.DeleteTLSFiles(id) if err != nil { httperror.WriteErrorResponse(w, err, http.StatusInternalServerError, handler.Logger) diff --git a/api/http/handler/file.go b/api/http/handler/file.go index 488a3968e..2191169ac 100644 --- a/api/http/handler/file.go +++ b/api/http/handler/file.go @@ -30,6 +30,7 @@ func NewFileHandler(assetPath string) *FileHandler { "/js": true, "/images": true, "/fonts": true, + "/ico": true, }, } return h diff --git a/api/http/handler/resource_control.go b/api/http/handler/resource_control.go index 7c35dec39..623e595e9 100644 --- a/api/http/handler/resource_control.go +++ b/api/http/handler/resource_control.go @@ -78,6 +78,10 @@ func (handler *ResourceHandler) handlePostResources(w http.ResponseWriter, r *ht resourceControlType = portainer.ServiceResourceControl case "volume": resourceControlType = portainer.VolumeResourceControl + case "network": + resourceControlType = portainer.NetworkResourceControl + case "secret": + resourceControlType = portainer.SecretResourceControl default: httperror.WriteErrorResponse(w, portainer.ErrInvalidResourceControlType, http.StatusBadRequest, handler.Logger) return diff --git a/api/http/handler/user.go b/api/http/handler/user.go index 7aa4e11c9..72952737d 100644 --- a/api/http/handler/user.go +++ b/api/http/handler/user.go @@ -82,6 +82,7 @@ type ( } postAdminInitRequest struct { + Username string `valid:"required"` Password string `valid:"required"` } ) @@ -358,10 +359,14 @@ func (handler *UserHandler) handlePostAdminInit(w http.ResponseWriter, r *http.R return } - user, err := handler.UserService.UserByUsername("admin") - if err == portainer.ErrUserNotFound { + users, err := handler.UserService.UsersByRole(portainer.AdministratorRole) + if err != nil { + httperror.WriteErrorResponse(w, err, http.StatusInternalServerError, handler.Logger) + return + } + if len(users) == 0 { user := &portainer.User{ - Username: "admin", + Username: req.Username, Role: portainer.AdministratorRole, } user.Password, err = handler.CryptoService.Hash(req.Password) @@ -375,11 +380,7 @@ func (handler *UserHandler) handlePostAdminInit(w http.ResponseWriter, r *http.R httperror.WriteErrorResponse(w, err, http.StatusInternalServerError, handler.Logger) return } - } else if err != nil { - httperror.WriteErrorResponse(w, err, http.StatusInternalServerError, handler.Logger) - return - } - if user != nil { + } else { httperror.WriteErrorResponse(w, portainer.ErrAdminAlreadyInitialized, http.StatusConflict, handler.Logger) return } @@ -396,6 +397,22 @@ func (handler *UserHandler) handleDeleteUser(w http.ResponseWriter, r *http.Requ return } + if userID == 1 { + httperror.WriteErrorResponse(w, portainer.ErrCannotRemoveAdmin, http.StatusForbidden, handler.Logger) + return + } + + tokenData, err := security.RetrieveTokenData(r) + if err != nil { + httperror.WriteErrorResponse(w, err, http.StatusInternalServerError, handler.Logger) + return + } + + if tokenData.ID == portainer.UserID(userID) { + httperror.WriteErrorResponse(w, portainer.ErrAdminCannotRemoveSelf, http.StatusForbidden, handler.Logger) + return + } + _, err = handler.UserService.User(portainer.UserID(userID)) if err == portainer.ErrUserNotFound { diff --git a/api/http/handler/websocket.go b/api/http/handler/websocket.go index dbc4fd9f0..b57f02806 100644 --- a/api/http/handler/websocket.go +++ b/api/http/handler/websocket.go @@ -71,8 +71,8 @@ func (handler *WebSocketHandler) webSocketDockerExec(ws *websocket.Conn) { // Should not be managed here var tlsConfig *tls.Config - if endpoint.TLS { - tlsConfig, err = crypto.CreateTLSConfiguration(endpoint.TLSCACertPath, endpoint.TLSCertPath, endpoint.TLSKeyPath, false) + if endpoint.TLSConfig.TLS { + tlsConfig, err = crypto.CreateTLSConfiguration(&endpoint.TLSConfig) if err != nil { log.Fatalf("Unable to create TLS configuration: %s", err) return diff --git a/api/http/proxy/decorator.go b/api/http/proxy/decorator.go index cc35fa7a3..ff075cc69 100644 --- a/api/http/proxy/decorator.go +++ b/api/http/proxy/decorator.go @@ -82,6 +82,54 @@ func decorateServiceList(serviceData []interface{}, resourceControls []portainer return decoratedServiceData, nil } +// decorateNetworkList loops through all networks and will decorate any network with an existing resource control. +// Network object schema reference: https://docs.docker.com/engine/api/v1.28/#operation/NetworkList +func decorateNetworkList(networkData []interface{}, resourceControls []portainer.ResourceControl) ([]interface{}, error) { + decoratedNetworkData := make([]interface{}, 0) + + for _, network := range networkData { + + networkObject := network.(map[string]interface{}) + if networkObject[networkIdentifier] == nil { + return nil, ErrDockerNetworkIdentifierNotFound + } + + networkID := networkObject[networkIdentifier].(string) + resourceControl := getResourceControlByResourceID(networkID, resourceControls) + if resourceControl != nil { + networkObject = decorateObject(networkObject, resourceControl) + } + + decoratedNetworkData = append(decoratedNetworkData, networkObject) + } + + return decoratedNetworkData, nil +} + +// decorateSecretList loops through all secrets and will decorate any secret with an existing resource control. +// Secret object schema reference: https://docs.docker.com/engine/api/v1.28/#operation/SecretList +func decorateSecretList(secretData []interface{}, resourceControls []portainer.ResourceControl) ([]interface{}, error) { + decoratedSecretData := make([]interface{}, 0) + + for _, secret := range secretData { + + secretObject := secret.(map[string]interface{}) + if secretObject[secretIdentifier] == nil { + return nil, ErrDockerSecretIdentifierNotFound + } + + secretID := secretObject[secretIdentifier].(string) + resourceControl := getResourceControlByResourceID(secretID, resourceControls) + if resourceControl != nil { + secretObject = decorateObject(secretObject, resourceControl) + } + + decoratedSecretData = append(decoratedSecretData, secretObject) + } + + return decoratedSecretData, nil +} + func decorateObject(object map[string]interface{}, resourceControl *portainer.ResourceControl) map[string]interface{} { metadata := make(map[string]interface{}) metadata["ResourceControl"] = resourceControl diff --git a/api/http/proxy/factory.go b/api/http/proxy/factory.go index dc733149f..210ef54a0 100644 --- a/api/http/proxy/factory.go +++ b/api/http/proxy/factory.go @@ -24,7 +24,7 @@ func (factory *proxyFactory) newHTTPProxy(u *url.URL) http.Handler { func (factory *proxyFactory) newHTTPSProxy(u *url.URL, endpoint *portainer.Endpoint) (http.Handler, error) { u.Scheme = "https" proxy := factory.createReverseProxy(u) - config, err := crypto.CreateTLSConfiguration(endpoint.TLSCACertPath, endpoint.TLSCertPath, endpoint.TLSKeyPath, false) + config, err := crypto.CreateTLSConfiguration(&endpoint.TLSConfig) if err != nil { return nil, err } diff --git a/api/http/proxy/filter.go b/api/http/proxy/filter.go index 0e66ab4fd..005b11469 100644 --- a/api/http/proxy/filter.go +++ b/api/http/proxy/filter.go @@ -110,3 +110,76 @@ func filterServiceList(serviceData []interface{}, resourceControls []portainer.R return filteredServiceData, nil } + +// filterNetworkList loops through all networks, filters networks without any resource control (public resources) or with +// any resource control giving access to the user (these networks will be decorated). +// Network object schema reference: https://docs.docker.com/engine/api/v1.28/#operation/NetworkList +func filterNetworkList(networkData []interface{}, resourceControls []portainer.ResourceControl, userID portainer.UserID, userTeamIDs []portainer.TeamID) ([]interface{}, error) { + filteredNetworkData := make([]interface{}, 0) + + for _, network := range networkData { + networkObject := network.(map[string]interface{}) + if networkObject[networkIdentifier] == nil { + return nil, ErrDockerNetworkIdentifierNotFound + } + + networkID := networkObject[networkIdentifier].(string) + resourceControl := getResourceControlByResourceID(networkID, resourceControls) + if resourceControl == nil { + filteredNetworkData = append(filteredNetworkData, networkObject) + } else if resourceControl != nil && canUserAccessResource(userID, userTeamIDs, resourceControl) { + networkObject = decorateObject(networkObject, resourceControl) + filteredNetworkData = append(filteredNetworkData, networkObject) + } + } + + return filteredNetworkData, nil +} + +// filterSecretList loops through all secrets, filters secrets without any resource control (public resources) or with +// any resource control giving access to the user (these secrets will be decorated). +// Secret object schema reference: https://docs.docker.com/engine/api/v1.28/#operation/SecretList +func filterSecretList(secretData []interface{}, resourceControls []portainer.ResourceControl, userID portainer.UserID, userTeamIDs []portainer.TeamID) ([]interface{}, error) { + filteredSecretData := make([]interface{}, 0) + + for _, secret := range secretData { + secretObject := secret.(map[string]interface{}) + if secretObject[secretIdentifier] == nil { + return nil, ErrDockerSecretIdentifierNotFound + } + + secretID := secretObject[secretIdentifier].(string) + resourceControl := getResourceControlByResourceID(secretID, resourceControls) + if resourceControl == nil { + filteredSecretData = append(filteredSecretData, secretObject) + } else if resourceControl != nil && canUserAccessResource(userID, userTeamIDs, resourceControl) { + secretObject = decorateObject(secretObject, resourceControl) + filteredSecretData = append(filteredSecretData, secretObject) + } + } + + return filteredSecretData, nil +} + +// filterTaskList loops through all tasks, filters tasks without any resource control (public resources) or with +// any resource control giving access to the user based on the associated service identifier. +// Task object schema reference: https://docs.docker.com/engine/api/v1.28/#operation/TaskList +func filterTaskList(taskData []interface{}, resourceControls []portainer.ResourceControl, userID portainer.UserID, userTeamIDs []portainer.TeamID) ([]interface{}, error) { + filteredTaskData := make([]interface{}, 0) + + for _, task := range taskData { + taskObject := task.(map[string]interface{}) + if taskObject[taskServiceIdentifier] == nil { + return nil, ErrDockerTaskServiceIdentifierNotFound + } + + serviceID := taskObject[taskServiceIdentifier].(string) + + resourceControl := getResourceControlByResourceID(serviceID, resourceControls) + if resourceControl == nil || (resourceControl != nil && canUserAccessResource(userID, userTeamIDs, resourceControl)) { + filteredTaskData = append(filteredTaskData, taskObject) + } + } + + return filteredTaskData, nil +} diff --git a/api/http/proxy/manager.go b/api/http/proxy/manager.go index 8710c7a44..bdba2b216 100644 --- a/api/http/proxy/manager.go +++ b/api/http/proxy/manager.go @@ -37,7 +37,7 @@ func (manager *Manager) CreateAndRegisterProxy(endpoint *portainer.Endpoint) (ht } if endpointURL.Scheme == "tcp" { - if endpoint.TLS { + if endpoint.TLSConfig.TLS { proxy, err = manager.proxyFactory.newHTTPSProxy(endpointURL, endpoint) if err != nil { return nil, err diff --git a/api/http/proxy/networks.go b/api/http/proxy/networks.go new file mode 100644 index 000000000..2e2549408 --- /dev/null +++ b/api/http/proxy/networks.go @@ -0,0 +1,66 @@ +package proxy + +import ( + "net/http" + + "github.com/portainer/portainer" +) + +const ( + // ErrDockerNetworkIdentifierNotFound defines an error raised when Portainer is unable to find a network identifier + ErrDockerNetworkIdentifierNotFound = portainer.Error("Docker network identifier not found") + networkIdentifier = "Id" +) + +// networkListOperation extracts the response as a JSON object, loop through the networks array +// decorate and/or filter the networks based on resource controls before rewriting the response +func networkListOperation(request *http.Request, response *http.Response, executor *operationExecutor) error { + var err error + // NetworkList response is a JSON array + // https://docs.docker.com/engine/api/v1.28/#operation/NetworkList + responseArray, err := getResponseAsJSONArray(response) + if err != nil { + return err + } + + if executor.operationContext.isAdmin { + responseArray, err = decorateNetworkList(responseArray, executor.operationContext.resourceControls) + } else { + responseArray, err = filterNetworkList(responseArray, executor.operationContext.resourceControls, + executor.operationContext.userID, executor.operationContext.userTeamIDs) + } + if err != nil { + return err + } + + return rewriteResponse(response, responseArray, http.StatusOK) +} + +// networkInspectOperation extracts the response as a JSON object, verify that the user +// has access to the network based on resource control and either rewrite an access denied response +// or a decorated network. +func networkInspectOperation(request *http.Request, response *http.Response, executor *operationExecutor) error { + // NetworkInspect response is a JSON object + // https://docs.docker.com/engine/api/v1.28/#operation/NetworkInspect + responseObject, err := getResponseAsJSONOBject(response) + if err != nil { + return err + } + + if responseObject[networkIdentifier] == nil { + return ErrDockerNetworkIdentifierNotFound + } + networkID := responseObject[networkIdentifier].(string) + + resourceControl := getResourceControlByResourceID(networkID, executor.operationContext.resourceControls) + if resourceControl != nil { + if executor.operationContext.isAdmin || canUserAccessResource(executor.operationContext.userID, + executor.operationContext.userTeamIDs, resourceControl) { + responseObject = decorateObject(responseObject, resourceControl) + } else { + return rewriteAccessDeniedResponse(response) + } + } + + return rewriteResponse(response, responseObject, http.StatusOK) +} diff --git a/api/http/proxy/secrets.go b/api/http/proxy/secrets.go new file mode 100644 index 000000000..d0001d3b9 --- /dev/null +++ b/api/http/proxy/secrets.go @@ -0,0 +1,67 @@ +package proxy + +import ( + "net/http" + + "github.com/portainer/portainer" +) + +const ( + // ErrDockerSecretIdentifierNotFound defines an error raised when Portainer is unable to find a secret identifier + ErrDockerSecretIdentifierNotFound = portainer.Error("Docker secret identifier not found") + secretIdentifier = "ID" +) + +// secretListOperation extracts the response as a JSON object, loop through the secrets array +// decorate and/or filter the secrets based on resource controls before rewriting the response +func secretListOperation(request *http.Request, response *http.Response, executor *operationExecutor) error { + var err error + + // SecretList response is a JSON array + // https://docs.docker.com/engine/api/v1.28/#operation/SecretList + responseArray, err := getResponseAsJSONArray(response) + if err != nil { + return err + } + + if executor.operationContext.isAdmin { + responseArray, err = decorateSecretList(responseArray, executor.operationContext.resourceControls) + } else { + responseArray, err = filterSecretList(responseArray, executor.operationContext.resourceControls, + executor.operationContext.userID, executor.operationContext.userTeamIDs) + } + if err != nil { + return err + } + + return rewriteResponse(response, responseArray, http.StatusOK) +} + +// secretInspectOperation extracts the response as a JSON object, verify that the user +// has access to the secret based on resource control (check are done based on the secretID and optional Swarm service ID) +// and either rewrite an access denied response or a decorated secret. +func secretInspectOperation(request *http.Request, response *http.Response, executor *operationExecutor) error { + // SecretInspect response is a JSON object + // https://docs.docker.com/engine/api/v1.28/#operation/SecretInspect + responseObject, err := getResponseAsJSONOBject(response) + if err != nil { + return err + } + + if responseObject[secretIdentifier] == nil { + return ErrDockerSecretIdentifierNotFound + } + secretID := responseObject[secretIdentifier].(string) + + resourceControl := getResourceControlByResourceID(secretID, executor.operationContext.resourceControls) + if resourceControl != nil { + if executor.operationContext.isAdmin || canUserAccessResource(executor.operationContext.userID, + executor.operationContext.userTeamIDs, resourceControl) { + responseObject = decorateObject(responseObject, resourceControl) + } else { + return rewriteAccessDeniedResponse(response) + } + } + + return rewriteResponse(response, responseObject, http.StatusOK) +} diff --git a/api/http/proxy/socket.go b/api/http/proxy/socket.go index 740010a63..5a9158492 100644 --- a/api/http/proxy/socket.go +++ b/api/http/proxy/socket.go @@ -34,6 +34,9 @@ func (proxy *socketProxy) ServeHTTP(w http.ResponseWriter, r *http.Request) { w.Header().Add(k, v) } } + + w.WriteHeader(res.StatusCode) + if _, err := io.Copy(w, res.Body); err != nil { httperror.WriteErrorResponse(w, err, http.StatusInternalServerError, nil) } diff --git a/api/http/proxy/tasks.go b/api/http/proxy/tasks.go new file mode 100644 index 000000000..b9073458b --- /dev/null +++ b/api/http/proxy/tasks.go @@ -0,0 +1,36 @@ +package proxy + +import ( + "net/http" + + "github.com/portainer/portainer" +) + +const ( + // ErrDockerTaskServiceIdentifierNotFound defines an error raised when Portainer is unable to find the service identifier associated to a task + ErrDockerTaskServiceIdentifierNotFound = portainer.Error("Docker task service identifier not found") + taskServiceIdentifier = "ServiceID" +) + +// taskListOperation extracts the response as a JSON object, loop through the tasks array +// and filter the tasks based on resource controls before rewriting the response +func taskListOperation(request *http.Request, response *http.Response, executor *operationExecutor) error { + var err error + + // TaskList response is a JSON array + // https://docs.docker.com/engine/api/v1.28/#operation/TaskList + responseArray, err := getResponseAsJSONArray(response) + if err != nil { + return err + } + + if !executor.operationContext.isAdmin { + responseArray, err = filterTaskList(responseArray, executor.operationContext.resourceControls, + executor.operationContext.userID, executor.operationContext.userTeamIDs) + if err != nil { + return err + } + } + + return rewriteResponse(response, responseArray, http.StatusOK) +} diff --git a/api/http/proxy/transport.go b/api/http/proxy/transport.go index 76c4f43f7..83f746d0e 100644 --- a/api/http/proxy/transport.go +++ b/api/http/proxy/transport.go @@ -53,17 +53,26 @@ func (p *proxyTransport) executeDockerRequest(request *http.Request) (*http.Resp func (p *proxyTransport) proxyDockerRequest(request *http.Request) (*http.Response, error) { path := request.URL.Path - if strings.HasPrefix(path, "/containers") { + switch { + case strings.HasPrefix(path, "/containers"): return p.proxyContainerRequest(request) - } else if strings.HasPrefix(path, "/services") { + case strings.HasPrefix(path, "/services"): return p.proxyServiceRequest(request) - } else if strings.HasPrefix(path, "/volumes") { + case strings.HasPrefix(path, "/volumes"): return p.proxyVolumeRequest(request) - } else if strings.HasPrefix(path, "/swarm") { + case strings.HasPrefix(path, "/networks"): + return p.proxyNetworkRequest(request) + case strings.HasPrefix(path, "/secrets"): + return p.proxySecretRequest(request) + case strings.HasPrefix(path, "/swarm"): return p.proxySwarmRequest(request) + case strings.HasPrefix(path, "/nodes"): + return p.proxyNodeRequest(request) + case strings.HasPrefix(path, "/tasks"): + return p.proxyTaskRequest(request) + default: + return p.executeDockerRequest(request) } - - return p.executeDockerRequest(request) } func (p *proxyTransport) proxyContainerRequest(request *http.Request) (*http.Response, error) { @@ -145,10 +154,67 @@ func (p *proxyTransport) proxyVolumeRequest(request *http.Request) (*http.Respon } } +func (p *proxyTransport) proxyNetworkRequest(request *http.Request) (*http.Response, error) { + switch requestPath := request.URL.Path; requestPath { + case "/networks/create": + return p.executeDockerRequest(request) + + case "/networks": + return p.rewriteOperation(request, networkListOperation) + + default: + // assume /networks/{id} + if request.Method == http.MethodGet { + return p.rewriteOperation(request, networkInspectOperation) + } + networkID := path.Base(requestPath) + return p.restrictedOperation(request, networkID) + } +} + +func (p *proxyTransport) proxySecretRequest(request *http.Request) (*http.Response, error) { + switch requestPath := request.URL.Path; requestPath { + case "/secrets/create": + return p.executeDockerRequest(request) + + case "/secrets": + return p.rewriteOperation(request, secretListOperation) + + default: + // assume /secrets/{id} + if request.Method == http.MethodGet { + return p.rewriteOperation(request, secretInspectOperation) + } + secretID := path.Base(requestPath) + return p.restrictedOperation(request, secretID) + } +} + +func (p *proxyTransport) proxyNodeRequest(request *http.Request) (*http.Response, error) { + requestPath := request.URL.Path + + // assume /nodes/{id} + if path.Base(requestPath) != "nodes" { + return p.administratorOperation(request) + } + + return p.executeDockerRequest(request) +} + func (p *proxyTransport) proxySwarmRequest(request *http.Request) (*http.Response, error) { return p.administratorOperation(request) } +func (p *proxyTransport) proxyTaskRequest(request *http.Request) (*http.Response, error) { + switch requestPath := request.URL.Path; requestPath { + case "/tasks": + return p.rewriteOperation(request, taskListOperation) + default: + // assume /tasks/{id} + return p.executeDockerRequest(request) + } +} + // restrictedOperation ensures that the current user has the required authorizations // before executing the original request. func (p *proxyTransport) restrictedOperation(request *http.Request, resourceID string) (*http.Response, error) { diff --git a/api/ldap/ldap.go b/api/ldap/ldap.go index 786332c35..8a280f754 100644 --- a/api/ldap/ldap.go +++ b/api/ldap/ldap.go @@ -52,7 +52,7 @@ func searchUser(username string, conn *ldap.Conn, settings []portainer.LDAPSearc func createConnection(settings *portainer.LDAPSettings) (*ldap.Conn, error) { if settings.TLSConfig.TLS || settings.StartTLS { - config, err := crypto.CreateTLSConfiguration(settings.TLSConfig.TLSCACertPath, "", "", settings.TLSConfig.TLSSkipVerify) + config, err := crypto.CreateTLSConfiguration(&settings.TLSConfig) if err != nil { return nil, err } diff --git a/api/portainer.go b/api/portainer.go index 69d8e9290..b641ef5cd 100644 --- a/api/portainer.go +++ b/api/portainer.go @@ -155,16 +155,20 @@ type ( // Endpoint represents a Docker endpoint with all the info required // to connect to it. Endpoint struct { - ID EndpointID `json:"Id"` - Name string `json:"Name"` - URL string `json:"URL"` - PublicURL string `json:"PublicURL"` - TLS bool `json:"TLS"` - TLSCACertPath string `json:"TLSCACert,omitempty"` - TLSCertPath string `json:"TLSCert,omitempty"` - TLSKeyPath string `json:"TLSKey,omitempty"` - AuthorizedUsers []UserID `json:"AuthorizedUsers"` - AuthorizedTeams []TeamID `json:"AuthorizedTeams"` + ID EndpointID `json:"Id"` + Name string `json:"Name"` + URL string `json:"URL"` + PublicURL string `json:"PublicURL"` + TLSConfig TLSConfiguration `json:"TLSConfig"` + AuthorizedUsers []UserID `json:"AuthorizedUsers"` + AuthorizedTeams []TeamID `json:"AuthorizedTeams"` + + // Deprecated fields + // Deprecated in DBVersion == 4 + TLS bool `json:"TLS,omitempty"` + TLSCACertPath string `json:"TLSCACert,omitempty"` + TLSCertPath string `json:"TLSCert,omitempty"` + TLSKeyPath string `json:"TLSKey,omitempty"` } // ResourceControlID represents a resource control identifier. @@ -172,20 +176,18 @@ type ( // ResourceControl represent a reference to a Docker resource with specific access controls ResourceControl struct { - ID ResourceControlID `json:"Id"` - ResourceID string `json:"ResourceId"` - SubResourceIDs []string `json:"SubResourceIds"` - Type ResourceControlType `json:"Type"` - AdministratorsOnly bool `json:"AdministratorsOnly"` - - UserAccesses []UserResourceAccess `json:"UserAccesses"` - TeamAccesses []TeamResourceAccess `json:"TeamAccesses"` + ID ResourceControlID `json:"Id"` + ResourceID string `json:"ResourceId"` + SubResourceIDs []string `json:"SubResourceIds"` + Type ResourceControlType `json:"Type"` + AdministratorsOnly bool `json:"AdministratorsOnly"` + UserAccesses []UserResourceAccess `json:"UserAccesses"` + TeamAccesses []TeamResourceAccess `json:"TeamAccesses"` // Deprecated fields - // Deprecated: OwnerID field is deprecated in DBVersion == 2 - OwnerID UserID `json:"OwnerId"` - // Deprecated: AccessLevel field is deprecated in DBVersion == 2 - AccessLevel ResourceAccessLevel `json:"AccessLevel"` + // Deprecated in DBVersion == 2 + OwnerID UserID `json:"OwnerId,omitempty"` + AccessLevel ResourceAccessLevel `json:"AccessLevel,omitempty"` } // ResourceControlType represents the type of resource associated to the resource control (volume, container, service). @@ -325,6 +327,7 @@ type ( FileService interface { StoreTLSFile(folder string, fileType TLSFileType, r io.Reader) error GetPathForTLSFile(folder string, fileType TLSFileType) (string, error) + DeleteTLSFile(folder string, fileType TLSFileType) error DeleteTLSFiles(folder string) error } @@ -342,9 +345,9 @@ type ( const ( // APIVersion is the version number of the Portainer API. - APIVersion = "1.14.0" + APIVersion = "1.14.1" // DBVersion is the version number of the Portainer database. - DBVersion = 3 + DBVersion = 4 // DefaultTemplatesURL represents the default URL for the templates definitions. DefaultTemplatesURL = "https://raw.githubusercontent.com/portainer/templates/master/templates.json" ) @@ -396,4 +399,8 @@ const ( ServiceResourceControl // VolumeResourceControl represents a resource control associated to a Docker volume VolumeResourceControl + // NetworkResourceControl represents a resource control associated to a Docker network + NetworkResourceControl + // SecretResourceControl represents a resource control associated to a Docker secret + SecretResourceControl ) diff --git a/api/swagger.yaml b/api/swagger.yaml index aa7713195..255a62949 100644 --- a/api/swagger.yaml +++ b/api/swagger.yaml @@ -1,27 +1,62 @@ --- swagger: "2.0" info: - description: "Portainer API is an HTTP API served by Portainer. It is used by the\ - \ Portainer UI and everything you can do with the UI can be done using the HTTP\ - \ API.\nYou can find out more about Portainer at [http://portainer.io](http://portainer.io)\ - \ and get some support on [Slack](http://portainer.io/slack/).\n\n# Authentication\n\ - \nMost of the API endpoints require to be authenticated as well as some level\ - \ of authorization to be used.\nPortainer API uses JSON Web Token to manage authentication\ - \ and thus requires you to provide a token in the **Authorization** header of\ - \ each request\nwith the **Bearer** authentication mechanism.\n\nExample:\n```\n\ - Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6MSwidXNlcm5hbWUiOiJhZG1pbiIsInJvbGUiOjEsImV4cCI6MTQ5OTM3NjE1NH0.NJ6vE8FY1WG6jsRQzfMqeatJ4vh2TWAeeYfDhP71YEE\n\ - ```\n\n# Security\n\nEach API endpoint has an associated access policy, it is\ - \ documented in the description of each endpoint.\n\nDifferent access policies\ - \ are available:\n* Public access\n* Authenticated access\n* Restricted access\n\ - * Administrator access\n\n### Public access\n\nNo authentication is required to\ - \ access the endpoints with this access policy.\n\n### Authenticated access\n\n\ - Authentication is required to access the endpoints with this access policy.\n\n\ - ### Restricted access\n\nAuthentication is required to access the endpoints with\ - \ this access policy.\nExtra-checks might be added to ensure access to the resource\ - \ is granted. Returned data might also be filtered.\n\n### Administrator access\n\ - \nAuthentication as well as an administrator role are required to access the endpoints\ - \ with this access policy.\n" - version: "1.14.0" + description: | + Portainer API is an HTTP API served by Portainer. It is used by the Portainer UI and everything you can do with the UI can be done using the HTTP API. + Examples are available at https://gist.github.com/deviantony/77026d402366b4b43fa5918d41bc42f8 + You can find out more about Portainer at [http://portainer.io](http://portainer.io) and get some support on [Slack](http://portainer.io/slack/). + + # Authentication + + Most of the API endpoints require to be authenticated as well as some level of authorization to be used. + Portainer API uses JSON Web Token to manage authentication and thus requires you to provide a token in the **Authorization** header of each request + with the **Bearer** authentication mechanism. + + Example: + ``` + Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6MSwidXNlcm5hbWUiOiJhZG1pbiIsInJvbGUiOjEsImV4cCI6MTQ5OTM3NjE1NH0.NJ6vE8FY1WG6jsRQzfMqeatJ4vh2TWAeeYfDhP71YEE + ``` + + # Security + + Each API endpoint has an associated access policy, it is documented in the description of each endpoint. + + Different access policies are available: + * Public access + * Authenticated access + * Restricted access + * Administrator access + + ### Public access + + No authentication is required to access the endpoints with this access policy. + + ### Authenticated access + + Authentication is required to access the endpoints with this access policy. + + ### Restricted access + + Authentication is required to access the endpoints with this access policy. + Extra-checks might be added to ensure access to the resource is granted. Returned data might also be filtered. + + ### Administrator access + + Authentication as well as an administrator role are required to access the endpoints with this access policy. + + # Execute Docker requests + + Portainer **DO NOT** expose specific endpoints to manage your Docker resources (create a container, remove a volume, etc...). + + Instead, it acts as a reverse-proxy to the Docker HTTP API. This means that you can execute Docker requests **via** the Portainer HTTP API. + + To do so, you can use the `/endpoints/{id}/docker` Portainer API endpoint (which is not documented below due to Swagger limitations). This + endpoint has a restricted access policy so you still need to be authenticated to be able to query this endpoint. Any query on this endpoint will be proxied to the + Docker API of the associated endpoint (requests and responses objects are the same as documented in the Docker API). + + **NOTE**: You can find more information on how to query the Docker API in the [Docker official documentation](https://docs.docker.com/engine/api/v1.30/) as well as in [this Portainer example](https://gist.github.com/deviantony/77026d402366b4b43fa5918d41bc42f8). + + version: "1.14.1" title: "Portainer API" contact: email: "info@portainer.io" @@ -63,8 +98,9 @@ paths: tags: - "auth" summary: "Authenticate a user" - description: "Use this endpoint to authenticate against Portainer using a username\ - \ and password. \n**Access policy**: public\n" + description: | + Use this endpoint to authenticate against Portainer using a username and password. + **Access policy**: public operationId: "AuthenticateUser" consumes: - "application/json" @@ -105,8 +141,9 @@ paths: tags: - "dockerhub" summary: "Retrieve DockerHub information" - description: "Use this endpoint to retrieve the information used to connect\ - \ to the DockerHub \n**Access policy**: authenticated\n" + description: | + Use this endpoint to retrieve the information used to connect to the DockerHub + **Access policy**: authenticated operationId: "DockerHubInspect" produces: - "application/json" @@ -124,8 +161,9 @@ paths: tags: - "dockerhub" summary: "Update DockerHub information" - description: "Use this endpoint to update the information used to connect to\ - \ the DockerHub \n**Access policy**: administrator\n" + description: | + Use this endpoint to update the information used to connect to the DockerHub + **Access policy**: administrator operationId: "DockerHubUpdate" consumes: - "application/json" @@ -157,9 +195,11 @@ paths: tags: - "endpoints" summary: "List endpoints" - description: "List all endpoints based on the current user authorizations. Will\n\ - return all endpoints if using an administrator account otherwise it will\n\ - only return authorized endpoints. \n**Access policy**: restricted \n" + description: | + List all endpoints based on the current user authorizations. Will + return all endpoints if using an administrator account otherwise it will + only return authorized endpoints. + **Access policy**: restricted operationId: "EndpointList" produces: - "application/json" @@ -177,8 +217,9 @@ paths: tags: - "endpoints" summary: "Create a new endpoint" - description: "Create a new endpoint that will be used to manage a Docker environment.\ - \ \n**Access policy**: administrator\n" + description: | + Create a new endpoint that will be used to manage a Docker environment. + **Access policy**: administrator operationId: "EndpointCreate" consumes: - "application/json" @@ -219,8 +260,9 @@ paths: tags: - "endpoints" summary: "Inspect an endpoint" - description: "Retrieve details abount an endpoint. \n**Access policy**: administrator\ - \ \n" + description: | + Retrieve details abount an endpoint. + **Access policy**: administrator operationId: "EndpointInspect" produces: - "application/json" @@ -257,7 +299,9 @@ paths: tags: - "endpoints" summary: "Update an endpoint" - description: "Update an endpoint. \n**Access policy**: administrator\n" + description: | + Update an endpoint. + **Access policy**: administrator operationId: "EndpointUpdate" consumes: - "application/json" @@ -307,7 +351,9 @@ paths: tags: - "endpoints" summary: "Remove an endpoint" - description: "Remove an endpoint. \n**Access policy**: administrator \n" + description: | + Remove an endpoint. + **Access policy**: administrator operationId: "EndpointDelete" parameters: - name: "id" @@ -348,8 +394,9 @@ paths: tags: - "endpoints" summary: "Manage accesses to an endpoint" - description: "Manage user and team accesses to an endpoint. \n**Access policy**:\ - \ administrator \n" + description: | + Manage user and team accesses to an endpoint. + **Access policy**: administrator operationId: "EndpointAccessUpdate" consumes: - "application/json" @@ -388,15 +435,17 @@ paths: description: "Server error" schema: $ref: "#/definitions/GenericError" + /registries: get: tags: - "registries" summary: "List registries" - description: "List all registries based on the current user authorizations.\n\ - Will return all registries if using an administrator account otherwise it\n\ - will only return authorized registries. \n**Access policy**: restricted \ - \ \n" + description: | + List all registries based on the current user authorizations. + Will return all registries if using an administrator account otherwise it + will only return authorized registries. + **Access policy**: restricted operationId: "RegistryList" produces: - "application/json" @@ -414,8 +463,9 @@ paths: tags: - "registries" summary: "Create a new registry" - description: "Create a new registry. \n**Access policy**: administrator \ - \ \n" + description: | + Create a new registry. + **Access policy**: administrator operationId: "RegistryCreate" consumes: - "application/json" @@ -456,8 +506,9 @@ paths: tags: - "registries" summary: "Inspect a registry" - description: "Retrieve details about a registry. \n**Access policy**: administrator\ - \ \n" + description: | + Retrieve details about a registry. + **Access policy**: administrator operationId: "RegistryInspect" produces: - "application/json" @@ -494,7 +545,9 @@ paths: tags: - "registries" summary: "Update a registry" - description: "Update a registry. \n**Access policy**: administrator \n" + description: | + Update a registry. + **Access policy**: administrator operationId: "RegistryUpdate" consumes: - "application/json" @@ -551,8 +604,9 @@ paths: tags: - "registries" summary: "Remove a registry" - description: "Remove a registry. \n**Access policy**: administrator \ - \ \n" + description: | + Remove a registry. + **Access policy**: administrator operationId: "RegistryDelete" parameters: - name: "id" @@ -586,8 +640,9 @@ paths: tags: - "registries" summary: "Manage accesses to a registry" - description: "Manage user and team accesses to a registry. \n**Access policy**:\ - \ administrator \n" + description: | + Manage user and team accesses to a registry. + **Access policy**: administrator operationId: "RegistryAccessUpdate" consumes: - "application/json" @@ -631,8 +686,9 @@ paths: tags: - "resource_controls" summary: "Create a new resource control" - description: "Create a new resource control to restrict access to a Docker resource.\ - \ \n**Access policy**: restricted \n" + description: | + Create a new resource control to restrict access to a Docker resource. + **Access policy**: restricted operationId: "ResourceControlCreate" consumes: - "application/json" @@ -678,8 +734,9 @@ paths: tags: - "resource_controls" summary: "Update a resource control" - description: "Update a resource control. \n**Access policy**: restricted \ - \ \n" + description: | + Update a resource control. + **Access policy**: restricted operationId: "ResourceControlUpdate" consumes: - "application/json" @@ -729,8 +786,9 @@ paths: tags: - "resource_controls" summary: "Remove a resource control" - description: "Remove a resource control. \n**Access policy**: restricted \ - \ \n" + description: | + Remove a resource control. + **Access policy**: restricted operationId: "ResourceControlDelete" parameters: - name: "id" @@ -771,8 +829,9 @@ paths: tags: - "settings" summary: "Retrieve Portainer settings" - description: "Retrieve Portainer settings. \n**Access policy**: administrator\ - \ \n" + description: | + Retrieve Portainer settings. + **Access policy**: administrator operationId: "SettingsInspect" produces: - "application/json" @@ -790,8 +849,9 @@ paths: tags: - "settings" summary: "Update Portainer settings" - description: "Update Portainer settings. \n**Access policy**: administrator\ - \ \n" + description: | + Update Portainer settings. + **Access policy**: administrator operationId: "SettingsUpdate" consumes: - "application/json" @@ -823,9 +883,9 @@ paths: tags: - "settings" summary: "Retrieve Portainer public settings" - description: "Retrieve public settings. Returns a small set of settings that\ - \ are not reserved to administrators only. \n**Access policy**: public \ - \ \n" + description: | + Retrieve public settings. Returns a small set of settings that are not reserved to administrators only. + **Access policy**: public operationId: "PublicSettingsInspect" produces: - "application/json" @@ -844,8 +904,9 @@ paths: tags: - "settings" summary: "Test LDAP connectivity" - description: "Test LDAP connectivity using LDAP details. \n**Access policy**:\ - \ administrator \n" + description: | + Test LDAP connectivity using LDAP details. + **Access policy**: administrator operationId: "SettingsLDAPCheck" consumes: - "application/json" @@ -877,8 +938,9 @@ paths: tags: - "status" summary: "Check Portainer status" - description: "Retrieve Portainer status. \n**Access policy**: public \ - \ \n" + description: | + Retrieve Portainer status. + **Access policy**: public operationId: "StatusInspect" produces: - "application/json" @@ -897,9 +959,9 @@ paths: tags: - "users" summary: "List users" - description: "List Portainer users. Non-administrator users will only be able\ - \ to list other non-administrator user accounts. \n**Access policy**: restricted\ - \ \n" + description: | + List Portainer users. Non-administrator users will only be able to list other non-administrator user accounts. + **Access policy**: restricted operationId: "UserList" produces: - "application/json" @@ -917,9 +979,10 @@ paths: tags: - "users" summary: "Create a new user" - description: "Create a new Portainer user. Only team leaders and administrators\ - \ can create users. Only administrators can\ncreate an administrator user\ - \ account. \n**Access policy**: restricted \n" + description: | + Create a new Portainer user. Only team leaders and administrators can create users. Only administrators can + create an administrator user account. + **Access policy**: restricted operationId: "UserCreate" consumes: - "application/json" @@ -967,8 +1030,9 @@ paths: tags: - "users" summary: "Inspect a user" - description: "Retrieve details about a user. \n**Access policy**: administrator\ - \ \n" + description: | + Retrieve details about a user. + **Access policy**: administrator operationId: "UserInspect" produces: - "application/json" @@ -1005,8 +1069,9 @@ paths: tags: - "users" summary: "Update a user" - description: "Update user details. A regular user account can only update his\ - \ details. \n**Access policy**: authenticated \n" + description: | + Update user details. A regular user account can only update his details. + **Access policy**: authenticated operationId: "UserUpdate" consumes: - "application/json" @@ -1056,7 +1121,9 @@ paths: tags: - "users" summary: "Remove a user" - description: "Remove a user. \n**Access policy**: administrator \n" + description: | + Remove a user. + **Access policy**: administrator operationId: "UserDelete" parameters: - name: "id" @@ -1090,8 +1157,9 @@ paths: tags: - "users" summary: "Inspect a user memberships" - description: "Inspect a user memberships. \n**Access policy**: authenticated\ - \ \n" + description: | + Inspect a user memberships. + **Access policy**: authenticated operationId: "UserMembershipsInspect" produces: - "application/json" @@ -1124,13 +1192,15 @@ paths: description: "Server error" schema: $ref: "#/definitions/GenericError" + /users/{id}/passwd: post: tags: - "users" summary: "Check password validity for a user" - description: "Check if the submitted password is valid for the specified user.\ - \ \n**Access policy**: authenticated \n" + description: | + Check if the submitted password is valid for the specified user. + **Access policy**: authenticated operationId: "UserPasswordCheck" consumes: - "application/json" @@ -1171,13 +1241,15 @@ paths: description: "Server error" schema: $ref: "#/definitions/GenericError" + /users/admin/check: get: tags: - "users" summary: "Check administrator account existence" - description: "Check if an administrator account exists in the database.\n**Access\ - \ policy**: public \n" + description: | + Check if an administrator account exists in the database. + **Access policy**: public operationId: "UserAdminCheck" produces: - "application/json" @@ -1198,13 +1270,15 @@ paths: description: "Server error" schema: $ref: "#/definitions/GenericError" + /users/admin/init: post: tags: - "users" summary: "Initialize administrator account" - description: "Initialize the 'admin' user account.\n**Access policy**: public\ - \ \n" + description: | + Initialize the 'admin' user account. + **Access policy**: public operationId: "UserAdminInit" consumes: - "application/json" @@ -1238,34 +1312,35 @@ paths: description: "Server error" schema: $ref: "#/definitions/GenericError" + /upload/tls/{certificate}: post: tags: - "upload" summary: "Upload TLS files" - description: "Use this endpoint to upload TLS files. \n**Access policy**: administrator\n" + description: | + Use this endpoint to upload TLS files. + **Access policy**: administrator operationId: "UploadTLS" consumes: - - "multipart/form-data" + - multipart/form-data produces: - "application/json" parameters: - - name: "certificate" - in: "path" + - in: "path" + name: "certificate" description: "TLS file type. Valid values are 'ca', 'cert' or 'key'." required: true type: "string" - - name: "folder" - in: "query" - description: "Folder where the TLS file will be stored. Will be created if\ - \ not existing." + - in: "query" + name: "folder" + description: "Folder where the TLS file will be stored. Will be created if not existing." required: true type: "string" - - name: "file" - in: "formData" - description: "The file to upload." - required: false + - in: "formData" + name: "file" type: "file" + description: "The file to upload." responses: 200: description: "Success" @@ -1280,13 +1355,15 @@ paths: description: "Server error" schema: $ref: "#/definitions/GenericError" + /teams: get: tags: - "teams" summary: "List teams" - description: "List teams. For non-administrator users, will only list the teams\ - \ they are member of. \n**Access policy**: restricted \n" + description: | + List teams. For non-administrator users, will only list the teams they are member of. + **Access policy**: restricted operationId: "TeamList" produces: - "application/json" @@ -1304,8 +1381,9 @@ paths: tags: - "teams" summary: "Create a new team" - description: "Create a new team. \n**Access policy**: administrator \ - \ \n" + description: | + Create a new team. + **Access policy**: administrator operationId: "TeamCreate" consumes: - "application/json" @@ -1353,8 +1431,9 @@ paths: tags: - "teams" summary: "Inspect a team" - description: "Retrieve details about a team. Access is only available for administrator\ - \ and leaders of that team. \n**Access policy**: restricted \n" + description: | + Retrieve details about a team. Access is only available for administrator and leaders of that team. + **Access policy**: restricted operationId: "TeamInspect" produces: - "application/json" @@ -1398,8 +1477,9 @@ paths: tags: - "teams" summary: "Update a team" - description: "Update a team. \n**Access policy**: administrator \ - \ \n" + description: | + Update a team. + **Access policy**: administrator operationId: "TeamUpdate" consumes: - "application/json" @@ -1442,7 +1522,9 @@ paths: tags: - "teams" summary: "Remove a team" - description: "Remove a team. \n**Access policy**: administrator \n" + description: | + Remove a team. + **Access policy**: administrator operationId: "TeamDelete" parameters: - name: "id" @@ -1471,13 +1553,15 @@ paths: description: "Server error" schema: $ref: "#/definitions/GenericError" + /teams/{id}/memberships: get: tags: - "teams" summary: "Inspect a team memberships" - description: "Inspect a team memberships. Access is only available for administrator\ - \ and leaders of that team. \n**Access policy**: restricted \n" + description: | + Inspect a team memberships. Access is only available for administrator and leaders of that team. + **Access policy**: restricted operationId: "TeamMembershipsInspect" produces: - "application/json" @@ -1510,13 +1594,15 @@ paths: description: "Server error" schema: $ref: "#/definitions/GenericError" + /team_memberships: get: tags: - "team_memberships" summary: "List team memberships" - description: "List team memberships. Access is only available to administrators\ - \ and team leaders. \n**Access policy**: restricted \n" + description: | + List team memberships. Access is only available to administrators and team leaders. + **Access policy**: restricted operationId: "TeamMembershipList" produces: - "application/json" @@ -1541,8 +1627,9 @@ paths: tags: - "team_memberships" summary: "Create a new team membership" - description: "Create a new team memberships. Access is only available to administrators\ - \ leaders of the associated team. \n**Access policy**: restricted \n" + description: | + Create a new team memberships. Access is only available to administrators leaders of the associated team. + **Access policy**: restricted operationId: "TeamMembershipCreate" consumes: - "application/json" @@ -1590,9 +1677,9 @@ paths: tags: - "team_memberships" summary: "Update a team membership" - description: "Update a team membership. Access is only available to administrators\ - \ leaders of the associated team. \n**Access policy**: restricted \ - \ \n" + description: | + Update a team membership. Access is only available to administrators leaders of the associated team. + **Access policy**: restricted operationId: "TeamMembershipUpdate" consumes: - "application/json" @@ -1642,8 +1729,9 @@ paths: tags: - "team_memberships" summary: "Remove a team membership" - description: "Remove a team membership. Access is only available to administrators\ - \ leaders of the associated team. \n**Access policy**: restricted \n" + description: | + Remove a team membership. Access is only available to administrators leaders of the associated team. + **Access policy**: restricted operationId: "TeamMembershipDelete" parameters: - name: "id" @@ -1684,17 +1772,18 @@ paths: tags: - "templates" summary: "Retrieve App templates" - description: "Retrieve App templates. \nYou can find more information about\ - \ the format at http://portainer.readthedocs.io/en/stable/templates.html \ - \ \n**Access policy**: authenticated \n" + description: | + Retrieve App templates. + You can find more information about the format at http://portainer.readthedocs.io/en/stable/templates.html + **Access policy**: authenticated operationId: "TemplateList" produces: - "application/json" parameters: - name: "key" in: "query" - description: "Templates key. Valid values are 'container' or 'linuxserver.io'." required: true + description: "Templates key. Valid values are 'container' or 'linuxserver.io'." type: "string" responses: 200: @@ -1780,7 +1869,7 @@ definitions: description: "Is analytics enabled" Version: type: "string" - example: "1.14.0" + example: "1.14.1" description: "Portainer API version" PublicSettingsInspectResponse: type: "object" @@ -1799,8 +1888,8 @@ definitions: AuthenticationMethod: type: "integer" example: 1 - description: "Active authentication method for the Portainer instance. Valid\ - \ values are: 1 for managed or 2 for LDAP." + description: "Active authentication method for the Portainer instance. Valid values are: 1 for managed or 2 for LDAP." + TLSConfiguration: type: "object" properties: @@ -1824,14 +1913,14 @@ definitions: type: "string" example: "/data/tls/key.pem" description: "Path to the TLS client key file" + LDAPSearchSettings: type: "object" properties: BaseDN: type: "string" example: "dc=ldap,dc=domain,dc=tld" - description: "The distinguished name of the element from which the LDAP server\ - \ will search for users" + description: "The distinguished name of the element from which the LDAP server will search for users" Filter: type: "string" example: "(objectClass=account)" @@ -1840,6 +1929,7 @@ definitions: type: "string" example: "uid" description: "LDAP attribute which denotes the username" + LDAPSettings: type: "object" properties: @@ -1865,6 +1955,7 @@ definitions: type: "array" items: $ref: "#/definitions/LDAPSearchSettings" + Settings: type: "object" properties: @@ -1893,8 +1984,7 @@ definitions: AuthenticationMethod: type: "integer" example: 1 - description: "Active authentication method for the Portainer instance. Valid\ - \ values are: 1 for managed or 2 for LDAP." + description: "Active authentication method for the Portainer instance. Valid values are: 1 for managed or 2 for LDAP." LDAPSettings: $ref: "#/definitions/LDAPSettings" Settings_BlackListedLabels: @@ -2060,6 +2150,14 @@ definitions: type: "boolean" example: true description: "Require TLS to connect against this endpoint" + TLSSkipVerify: + type: "boolean" + example: false + description: "Skip server verification when using TLS" + TLSSkipClientVerify: + type: "boolean" + example: false + description: "Skip client verification when using TLS" EndpointCreateResponse: type: "object" properties: @@ -2091,6 +2189,14 @@ definitions: type: "boolean" example: true description: "Require TLS to connect against this endpoint" + TLSSkipVerify: + type: "boolean" + example: false + description: "Skip server verification when using TLS" + TLSSkipClientVerify: + type: "boolean" + example: false + description: "Skip client verification when using TLS" EndpointAccessUpdateRequest: type: "object" properties: @@ -2257,8 +2363,8 @@ definitions: SettingsUpdateRequest: type: "object" required: - - "AuthenticationMethod" - "TemplatesURL" + - "AuthenticationMethod" properties: TemplatesURL: type: "string" @@ -2285,8 +2391,7 @@ definitions: AuthenticationMethod: type: "integer" example: 1 - description: "Active authentication method for the Portainer instance. Valid\ - \ values are: 1 for managed or 2 for LDAP." + description: "Active authentication method for the Portainer instance. Valid values are: 1 for managed or 2 for LDAP." LDAPSettings: $ref: "#/definitions/LDAPSettings" UserCreateRequest: @@ -2383,12 +2488,13 @@ definitions: type: "array" items: $ref: "#/definitions/TeamMembership" + TeamMembershipCreateRequest: type: "object" required: - - "Role" - - "TeamID" - "UserID" + - "TeamID" + - "Role" properties: UserID: type: "integer" @@ -2401,8 +2507,7 @@ definitions: Role: type: "integer" example: 1 - description: "Role for the user inside the team (1 for leader and 2 for regular\ - \ member)" + description: "Role for the user inside the team (1 for leader and 2 for regular member)" TeamMembershipCreateResponse: type: "object" properties: @@ -2417,9 +2522,9 @@ definitions: TeamMembershipUpdateRequest: type: "object" required: - - "Role" - - "TeamID" - "UserID" + - "TeamID" + - "Role" properties: UserID: type: "integer" @@ -2432,8 +2537,7 @@ definitions: Role: type: "integer" example: 1 - description: "Role for the user inside the team (1 for leader and 2 for regular\ - \ member)" + description: "Role for the user inside the team (1 for leader and 2 for regular member)" SettingsLDAPCheckRequest: type: "object" properties: diff --git a/app/app.js b/app/app.js index d7774719f..02754f6c8 100644 --- a/app/app.js +++ b/app/app.js @@ -23,6 +23,7 @@ angular.module('portainer', [ 'container', 'containerConsole', 'containerLogs', + 'containerStats', 'serviceLogs', 'containers', 'createContainer', @@ -31,14 +32,15 @@ angular.module('portainer', [ 'createSecret', 'createService', 'createVolume', - 'docker', + 'engine', 'endpoint', 'endpointAccess', - 'endpointInit', 'endpoints', 'events', 'image', 'images', + 'initAdmin', + 'initEndpoint', 'main', 'network', 'networks', @@ -53,8 +55,8 @@ angular.module('portainer', [ 'settings', 'settingsAuthentication', 'sidebar', - 'stats', 'swarm', + 'swarmVisualizer', 'task', 'team', 'teams', @@ -63,7 +65,8 @@ angular.module('portainer', [ 'users', 'userSettings', 'volume', - 'volumes']) + 'volumes', + 'rzModule']) .config(['$stateProvider', '$urlRouterProvider', '$httpProvider', 'localStorageServiceProvider', 'jwtOptionsProvider', 'AnalyticsProvider', '$uibTooltipProvider', '$compileProvider', function ($stateProvider, $urlRouterProvider, $httpProvider, localStorageServiceProvider, jwtOptionsProvider, AnalyticsProvider, $uibTooltipProvider, $compileProvider) { 'use strict'; @@ -157,8 +160,8 @@ angular.module('portainer', [ url: '^/containers/:id/stats', views: { 'content@': { - templateUrl: 'app/components/stats/stats.html', - controller: 'StatsController' + templateUrl: 'app/components/containerStats/containerStats.html', + controller: 'ContainerStatsController' }, 'sidebar@': { templateUrl: 'app/components/sidebar/sidebar.html', @@ -321,12 +324,39 @@ angular.module('portainer', [ } } }) - .state('docker', { - url: '/docker/', + .state('init', { + abstract: true, + url: '/init', views: { 'content@': { - templateUrl: 'app/components/docker/docker.html', - controller: 'DockerController' + template: '
' + } + } + }) + .state('init.endpoint', { + url: '/endpoint', + views: { + 'content@': { + templateUrl: 'app/components/initEndpoint/initEndpoint.html', + controller: 'InitEndpointController' + } + } + }) + .state('init.admin', { + url: '/admin', + views: { + 'content@': { + templateUrl: 'app/components/initAdmin/initAdmin.html', + controller: 'InitAdminController' + } + } + }) + .state('engine', { + url: '/engine/', + views: { + 'content@': { + templateUrl: 'app/components/engine/engine.html', + controller: 'EngineController' }, 'sidebar@': { templateUrl: 'app/components/sidebar/sidebar.html', @@ -373,15 +403,6 @@ angular.module('portainer', [ } } }) - .state('endpointInit', { - url: '/init/endpoint', - views: { - 'content@': { - templateUrl: 'app/components/endpointInit/endpointInit.html', - controller: 'EndpointInitController' - } - } - }) .state('events', { url: '/events/', views: { @@ -716,7 +737,7 @@ angular.module('portainer', [ } }) .state('swarm', { - url: '/swarm/', + url: '/swarm', views: { 'content@': { templateUrl: 'app/components/swarm/swarm.html', @@ -727,7 +748,21 @@ angular.module('portainer', [ controller: 'SidebarController' } } - }); + }) + .state('swarm.visualizer', { + url: '/visualizer', + views: { + 'content@': { + templateUrl: 'app/components/swarmVisualizer/swarmVisualizer.html', + controller: 'SwarmVisualizerController' + }, + 'sidebar@': { + templateUrl: 'app/components/sidebar/sidebar.html', + controller: 'SidebarController' + } + } + }) + ; }]) .run(['$rootScope', '$state', 'Authentication', 'authManager', 'StateManager', 'EndpointProvider', 'Notifications', 'Analytics', function ($rootScope, $state, Authentication, authManager, StateManager, EndpointProvider, Notifications, Analytics) { EndpointProvider.initialize(); diff --git a/app/components/auth/auth.html b/app/components/auth/auth.html index 8668d328a..f58276395 100644 --- a/app/components/auth/auth.html +++ b/app/components/auth/auth.html @@ -1,92 +1,38 @@+ + This feature is not yet available for native Docker Windows containers. +
+
+ Please ensure that you have started the Portainer container with the following Docker flag -v "/var/run/docker.sock:/var/run/docker.sock"
in order to connect to the local Docker environment.
+
CPU limits | -- {{ service.LimitNanoCPUs / 1000000000 }} + | + Memory reservation (MB) | -None | -||
Memory limits | -{{service.LimitMemoryBytes|humansize}} | -None | -|||
CPU reservation | -- {{service.ReservationNanoCPUs / 1000000000}} + | + + | +
+ + Minimum memory available on a node to run a task (set to 0 for unlimited) + |
- None | |
Memory reservation | -{{service.ReservationMemoryBytes|humansize}} | -None | ++ Memory limit (MB) + | ++ + | +
+ + Maximum memory usage per task (set to 0 for unlimited) + + |
+
+
+ CPU reservation
+
+ |
+
+ |
+
+ + Minimum CPU available on a node to run a task + + |
+ |||
+
+ CPU limit
+
+ |
+
+ |
+
+ + Maximum CPU usage per task + + |
- - {{title}} - - - - | -
---|
{{processInfo}} | -
Nodes | +{{ nodes.length }} | +
Services | +{{ services.length }} | +
Tasks | +{{ tasks.length }} | +