diff --git a/api4/api.go b/api4/api.go index 961f5fb3e3..8a225b3f4f 100644 --- a/api4/api.go +++ b/api4/api.go @@ -119,8 +119,6 @@ type Routes struct { TermsOfService *mux.Router // 'api/v4/terms_of_service' Groups *mux.Router // 'api/v4/groups' - - Cloud *mux.Router // 'api/v4/cloud' } type API struct { @@ -229,8 +227,6 @@ func Init(configservice configservice.ConfigService, globalOptionsFunc app.AppOp api.BaseRoutes.TermsOfService = api.BaseRoutes.ApiRoot.PathPrefix("/terms_of_service").Subrouter() api.BaseRoutes.Groups = api.BaseRoutes.ApiRoot.PathPrefix("/groups").Subrouter() - api.BaseRoutes.Cloud = api.BaseRoutes.ApiRoot.PathPrefix("/cloud").Subrouter() - api.InitUser() api.InitBot() api.InitTeam() @@ -266,7 +262,6 @@ func Init(configservice configservice.ConfigService, globalOptionsFunc app.AppOp api.InitTermsOfService() api.InitGroup() api.InitAction() - api.InitCloud() root.Handle("/api/v4/{anything:.*}", http.HandlerFunc(api.Handle404)) diff --git a/api4/cloud.go b/api4/cloud.go deleted file mode 100644 index dba507bd44..0000000000 --- a/api4/cloud.go +++ /dev/null @@ -1,117 +0,0 @@ -// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. -// See LICENSE.txt for license information. - -package api4 - -import ( - "encoding/json" - "io/ioutil" - "net/http" - - "github.com/mattermost/mattermost-server/v5/audit" - "github.com/mattermost/mattermost-server/v5/model" -) - -func (api *API) InitCloud() { - // GET /api/v4/cloud/products - api.BaseRoutes.Cloud.Handle("/products", api.ApiSessionRequired(getCloudProducts)).Methods("GET") - - // POST /api/v4/cloud/payment - // POST /api/v4/cloud/payment/confirm - api.BaseRoutes.Cloud.Handle("/payment", api.ApiSessionRequired(createCustomerPayment)).Methods("POST") - api.BaseRoutes.Cloud.Handle("/payment/confirm", api.ApiSessionRequired(confirmCustomerPayment)).Methods("POST") -} - -func getCloudProducts(c *Context, w http.ResponseWriter, r *http.Request) { - if c.App.Srv().License() == nil || !*c.App.Srv().License().Features.Cloud { - c.Err = model.NewAppError("Api4.getCloudProducts", "api.cloud.license_error", nil, "", http.StatusNotImplemented) - return - } - - if !c.App.SessionHasPermissionTo(*c.App.Session(), model.PERMISSION_MANAGE_SYSTEM) { - c.SetPermissionError(model.PERMISSION_MANAGE_SYSTEM) - return - } - - products, appErr := c.App.Cloud().GetCloudProducts() - if appErr != nil { - c.Err = model.NewAppError("Api4.getCloudProducts", "api.cloud.request_error", nil, appErr.Error(), http.StatusInternalServerError) - return - } - - json, err := json.Marshal(products) - if err != nil { - c.Err = model.NewAppError("Api4.getCloudProducts", "api.cloud.app_error", nil, err.Error(), http.StatusInternalServerError) - return - } - - w.Write(json) -} - -func createCustomerPayment(c *Context, w http.ResponseWriter, r *http.Request) { - if c.App.Srv().License() == nil || !*c.App.Srv().License().Features.Cloud { - c.Err = model.NewAppError("Api4.createCustomerPayment", "api.cloud.license_error", nil, "", http.StatusNotImplemented) - return - } - - if !c.App.SessionHasPermissionTo(*c.App.Session(), model.PERMISSION_MANAGE_SYSTEM) { - c.SetPermissionError(model.PERMISSION_MANAGE_SYSTEM) - return - } - - auditRec := c.MakeAuditRecord("createCustomerPayment", audit.Fail) - defer c.LogAuditRec(auditRec) - - intent, appErr := c.App.Cloud().CreateCustomerPayment() - if appErr != nil { - c.Err = model.NewAppError("Api4.createCustomerPayment", "api.cloud.request_error", nil, appErr.Error(), http.StatusInternalServerError) - return - } - - json, err := json.Marshal(intent) - if err != nil { - c.Err = model.NewAppError("Api4.createCustomerPayment", "api.cloud.app_error", nil, err.Error(), http.StatusInternalServerError) - return - } - - auditRec.Success() - - w.Write(json) -} - -func confirmCustomerPayment(c *Context, w http.ResponseWriter, r *http.Request) { - if c.App.Srv().License() == nil || !*c.App.Srv().License().Features.Cloud { - c.Err = model.NewAppError("Api4.confirmCustomerPayment", "api.cloud.license_error", nil, "", http.StatusNotImplemented) - return - } - - if !c.App.SessionHasPermissionTo(*c.App.Session(), model.PERMISSION_MANAGE_SYSTEM) { - c.SetPermissionError(model.PERMISSION_MANAGE_SYSTEM) - return - } - - auditRec := c.MakeAuditRecord("confirmCustomerPayment", audit.Fail) - defer c.LogAuditRec(auditRec) - - bodyBytes, err := ioutil.ReadAll(r.Body) - if err != nil { - c.Err = model.NewAppError("Api4.confirmCustomerPayment", "api.cloud.app_error", nil, err.Error(), http.StatusInternalServerError) - return - } - - var confirmRequest *model.ConfirmPaymentMethodRequest - if err = json.Unmarshal(bodyBytes, &confirmRequest); err != nil { - c.Err = model.NewAppError("Api4.confirmCustomerPayment", "api.cloud.app_error", nil, err.Error(), http.StatusInternalServerError) - return - } - - appErr := c.App.Cloud().ConfirmCustomerPayment(confirmRequest) - if appErr != nil { - c.Err = model.NewAppError("Api4.createCustomerPayment", "api.cloud.request_error", nil, appErr.Error(), http.StatusInternalServerError) - return - } - - auditRec.Success() - - ReturnStatusOK(w) -} diff --git a/app/app.go b/app/app.go index 90602570dd..68643dce36 100644 --- a/app/app.go +++ b/app/app.go @@ -630,9 +630,6 @@ func (a *App) Notification() einterfaces.NotificationInterface { func (a *App) Saml() einterfaces.SamlInterface { return a.srv.Saml } -func (a *App) Cloud() einterfaces.CloudInterface { - return a.srv.Cloud -} func (a *App) HTTPService() httpservice.HTTPService { return a.srv.HTTPService } diff --git a/app/app_iface.go b/app/app_iface.go index 97ae79e4b9..c825f3f8a5 100644 --- a/app/app_iface.go +++ b/app/app_iface.go @@ -397,7 +397,6 @@ type AppIface interface { ClearTeamMembersCache(teamID string) ClientConfig() map[string]string ClientConfigHash() string - Cloud() einterfaces.CloudInterface Cluster() einterfaces.ClusterInterface CompareAndDeletePluginKey(pluginId string, key string, oldValue []byte) (bool, *model.AppError) CompareAndSetPluginKey(pluginId string, key string, oldValue, newValue []byte) (bool, *model.AppError) diff --git a/app/enterprise.go b/app/enterprise.go index f43a7b4cf1..4f77c2cc2b 100644 --- a/app/enterprise.go +++ b/app/enterprise.go @@ -120,12 +120,6 @@ func RegisterMessageExportInterface(f func(*Server) einterfaces.MessageExportInt messageExportInterface = f } -var cloudInterface func(*App) einterfaces.CloudInterface - -func RegisterCloudInterface(f func(*App) einterfaces.CloudInterface) { - cloudInterface = f -} - var metricsInterface func(*Server) einterfaces.MetricsInterface func RegisterMetricsInterface(f func(*Server) einterfaces.MetricsInterface) { @@ -201,7 +195,4 @@ func (a *App) initEnterprise() { } }) } - if cloudInterface != nil { - a.srv.Cloud = cloudInterface(a) - } } diff --git a/app/opentracing/opentracing_layer.go b/app/opentracing/opentracing_layer.go index 0ccde03b14..a455f7c9aa 100644 --- a/app/opentracing/opentracing_layer.go +++ b/app/opentracing/opentracing_layer.go @@ -1322,23 +1322,6 @@ func (a *OpenTracingAppLayer) ClientConfigWithComputed() map[string]string { return resultVar0 } -func (a *OpenTracingAppLayer) Cloud() einterfaces.CloudInterface { - origCtx := a.ctx - span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.Cloud") - - a.ctx = newCtx - a.app.Srv().Store.SetContext(newCtx) - defer func() { - a.app.Srv().Store.SetContext(origCtx) - a.ctx = origCtx - }() - - defer span.Finish() - resultVar0 := a.app.Cloud() - - return resultVar0 -} - func (a *OpenTracingAppLayer) CompareAndDeletePluginKey(pluginId string, key string, oldValue []byte) (bool, *model.AppError) { origCtx := a.ctx span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.CompareAndDeletePluginKey") diff --git a/app/server.go b/app/server.go index 6d1b4277f7..b472b92bcd 100644 --- a/app/server.go +++ b/app/server.go @@ -163,7 +163,6 @@ type Server struct { DataRetention einterfaces.DataRetentionInterface Ldap einterfaces.LdapInterface MessageExport einterfaces.MessageExportInterface - Cloud einterfaces.CloudInterface Metrics einterfaces.MetricsInterface Notification einterfaces.NotificationInterface Saml einterfaces.SamlInterface diff --git a/einterfaces/cloud.go b/einterfaces/cloud.go deleted file mode 100644 index 33f720e14b..0000000000 --- a/einterfaces/cloud.go +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. -// See LICENSE.txt for license information. - -package einterfaces - -import ( - "github.com/mattermost/mattermost-server/v5/model" -) - -type CloudInterface interface { - GetCloudProducts() ([]*model.Product, *model.AppError) - - CreateCustomerPayment() (*model.StripeSetupIntent, *model.AppError) - ConfirmCustomerPayment(*model.ConfirmPaymentMethodRequest) *model.AppError -} diff --git a/i18n/en.json b/i18n/en.json index b475c409b0..f5e9ce52b5 100644 --- a/i18n/en.json +++ b/i18n/en.json @@ -471,18 +471,6 @@ "id": "api.channel.update_team_member_roles.scheme_role.app_error", "translation": "The provided role is managed by a Scheme and therefore cannot be applied directly to a Team Member." }, - { - "id": "api.cloud.app_error", - "translation": "Internal error during cloud api request." - }, - { - "id": "api.cloud.license_error", - "translation": "Your license does not support cloud requests." - }, - { - "id": "api.cloud.request_error", - "translation": "Error processing request to CWS." - }, { "id": "api.command.admin_only.app_error", "translation": "Integrations have been limited to admins only." @@ -5582,18 +5570,6 @@ "id": "ent.api.post.send_notifications_and_forget.push_image_only", "translation": " attached a file." }, - { - "id": "ent.cloud.authentication_failed", - "translation": "Unable to authenticate to CWS" - }, - { - "id": "ent.cloud.json_encode.error", - "translation": "Internal error marshaling request to CWS" - }, - { - "id": "ent.cloud.request_error", - "translation": "Error processing request to CWS" - }, { "id": "ent.cluster.404.app_error", "translation": "Cluster API endpoint not found." diff --git a/model/client4.go b/model/client4.go index 71a5e49082..832f12d9af 100644 --- a/model/client4.go +++ b/model/client4.go @@ -334,10 +334,6 @@ func (c *Client4) GetSystemRoute() string { return "/system" } -func (c *Client4) GetCloudRoute() string { - return "/cloud" -} - func (c *Client4) GetTestEmailRoute() string { return "/email/test" } @@ -5610,43 +5606,3 @@ func (c *Client4) UploadData(uploadId string, data io.Reader) (*FileInfo, *Respo defer closeBody(r) return FileInfoFromJson(r.Body), BuildResponse(r) } - -// Cloud Section - -func (c *Client4) GetCloudProducts() ([]*Product, *Response) { - r, appErr := c.DoApiGet(c.GetCloudRoute()+"/products", "") - if appErr != nil { - return nil, BuildErrorResponse(r, appErr) - } - defer closeBody(r) - - var cloudProducts []*Product - json.NewDecoder(r.Body).Decode(&cloudProducts) - - return cloudProducts, BuildResponse(r) -} - -func (c *Client4) CreateCustomerPayment() (*StripeSetupIntent, *Response) { - r, appErr := c.DoApiPost(c.GetCloudRoute()+"/payment", "") - if appErr != nil { - return nil, BuildErrorResponse(r, appErr) - } - defer closeBody(r) - - var setupIntent *StripeSetupIntent - json.NewDecoder(r.Body).Decode(&setupIntent) - - return setupIntent, BuildResponse(r) -} - -func (c *Client4) ConfirmCustomerPayment(confirmRequest *ConfirmPaymentMethodRequest) *Response { - json, _ := json.Marshal(confirmRequest) - - r, appErr := c.doApiPostBytes(c.GetCloudRoute()+"/payment/confirm", json) - if appErr != nil { - return BuildErrorResponse(r, appErr) - } - defer closeBody(r) - - return BuildResponse(r) -} diff --git a/model/cloud.go b/model/cloud.go deleted file mode 100644 index 93cd73b4f1..0000000000 --- a/model/cloud.go +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. -// See LICENSE.txt for license information. - -package model - -// Product model represents a product on the cloud system. -type Product struct { - ID string `json:"id"` - Name string `json:"name"` - Description string `json:"description"` - PricePerSeat float64 `json:"price_per_seat"` - AddOns []*AddOn `json:"add_ons"` -} - -// AddOn represents an addon to a product. -type AddOn struct { - ID string `json:"id"` - Name string `json:"name"` - DisplayName string `json:"display_name"` - PricePerSeat float64 `json:"price_per_seat"` -} - -// StripeSetupIntent represents the SetupIntent model from Stripe for updating payment methods. -type StripeSetupIntent struct { - ID string `json:"id"` - ClientSecret string `json:"client_secret"` -} - -// ConfirmPaymentMethodRequest contains the fields for the customer payment update API. -type ConfirmPaymentMethodRequest struct { - StripeSetupIntentID string `json:"stripe_setup_intent_id"` -} diff --git a/model/config.go b/model/config.go index b18f650b1f..50f9b0cf23 100644 --- a/model/config.go +++ b/model/config.go @@ -218,8 +218,6 @@ const ( OFFICE365_SETTINGS_DEFAULT_TOKEN_ENDPOINT = "https://login.microsoftonline.com/common/oauth2/v2.0/token" OFFICE365_SETTINGS_DEFAULT_USER_API_ENDPOINT = "https://graph.microsoft.com/v1.0/me" - CLOUD_SETTINGS_DEFAULT_CWS_URL = "https://customers.mattermost.com" - LOCAL_MODE_SOCKET_PATH = "/var/tmp/mattermost_local.socket" ) @@ -2543,16 +2541,6 @@ func (s *JobSettings) SetDefaults() { } } -type CloudSettings struct { - CWSUrl *string `access:"environment,write_restrictable"` -} - -func (s *CloudSettings) SetDefaults() { - if s.CWSUrl == nil { - s.CWSUrl = NewString(CLOUD_SETTINGS_DEFAULT_CWS_URL) - } -} - type PluginState struct { Enable bool } @@ -2861,7 +2849,6 @@ type Config struct { DisplaySettings DisplaySettings GuestAccountsSettings GuestAccountsSettings ImageProxySettings ImageProxySettings - CloudSettings CloudSettings } func (o *Config) Clone() *Config { @@ -2948,7 +2935,6 @@ func (o *Config) SetDefaults() { o.DisplaySettings.SetDefaults() o.GuestAccountsSettings.SetDefaults() o.ImageProxySettings.SetDefaults(o.ServiceSettings) - o.CloudSettings.SetDefaults() } func (o *Config) IsValid() *AppError { diff --git a/utils/subpath.go b/utils/subpath.go index aa30c0816d..d294de2da5 100644 --- a/utils/subpath.go +++ b/utils/subpath.go @@ -85,13 +85,13 @@ func UpdateAssetsSubpathInDir(subpath, directory string) error { newRootHtml := string(oldRootHtml) - reCSP := regexp.MustCompile(``) + reCSP := regexp.MustCompile(``) if results := reCSP.FindAllString(newRootHtml, -1); len(results) == 0 { return fmt.Errorf("failed to find 'Content-Security-Policy' meta tag to rewrite") } newRootHtml = reCSP.ReplaceAllLiteralString(newRootHtml, fmt.Sprintf( - ``, + ``, GetSubpathScriptHash(subpath), )) diff --git a/utils/subpath_test.go b/utils/subpath_test.go index e05b6d8a9b..bb5e1082cb 100644 --- a/utils/subpath_test.go +++ b/utils/subpath_test.go @@ -268,19 +268,19 @@ func sToP(s string) *string { return &s } -const contentSecurityPolicyNotFoundHtml = `
We're having trouble connecting to Mattermost. If refreshing this page (Ctrl+R or Command+R) does not work, please verify that your computer is connected to the internet.
We're having trouble connecting to Mattermost. If refreshing this page (Ctrl+R or Command+R) does not work, please verify that your computer is connected to the internet.
We're having trouble connecting to Mattermost. If refreshing this page (Ctrl+R or Command+R) does not work, please verify that your computer is connected to the internet.
We're having trouble connecting to Mattermost. If refreshing this page (Ctrl+R or Command+R) does not work, please verify that your computer is connected to the internet.
We're having trouble connecting to Mattermost. If refreshing this page (Ctrl+R or Command+R) does not work, please verify that your computer is connected to the internet.
We're having trouble connecting to Mattermost. If refreshing this page (Ctrl+R or Command+R) does not work, please verify that your computer is connected to the internet.
We're having trouble connecting to Mattermost. If refreshing this page (Ctrl+R or Command+R) does not work, please verify that your computer is connected to the internet.
We're having trouble connecting to Mattermost. If refreshing this page (Ctrl+R or Command+R) does not work, please verify that your computer is connected to the internet.
We're having trouble connecting to Mattermost. If refreshing this page (Ctrl+R or Command+R) does not work, please verify that your computer is connected to the internet.
We're having trouble connecting to Mattermost. If refreshing this page (Ctrl+R or Command+R) does not work, please verify that your computer is connected to the internet.