Fix all occurances of checking for RemoteClusterServiceLicense (#22453)

This commit is contained in:
Doug Lauder
2023-03-13 12:20:27 -04:00
committed by GitHub
parent 78d2768289
commit 10ae28e320
4 changed files with 18 additions and 3 deletions

View File

@@ -579,7 +579,7 @@ func (s *Server) startInterClusterServices(license *model.License) error {
// Remote Cluster service
// License check (assume enabled if shared channels enabled)
if !*license.Features.RemoteClusterService && !license.HasSharedChannels() {
if !license.HasRemoteClusterService() && !license.HasSharedChannels() {
mlog.Debug("License does not have Remote Cluster services enabled")
return nil
}

View File

@@ -321,6 +321,21 @@ func (l *License) HasEnterpriseMarketplacePlugins() bool {
l.SkuShortName == LicenseShortSkuEnterprise
}
func (l *License) HasRemoteClusterService() bool {
if l == nil {
return false
}
// If SharedChannels is enabled then RemoteClusterService must be enabled.
if l.HasSharedChannels() {
return true
}
return (l.Features != nil && l.Features.RemoteClusterService != nil && *l.Features.RemoteClusterService) ||
l.SkuShortName == LicenseShortSkuProfessional ||
l.SkuShortName == LicenseShortSkuEnterprise
}
func (l *License) HasSharedChannels() bool {
if l == nil {
return false

View File

@@ -145,7 +145,7 @@ func (c *Context) CloudKeyRequired() {
}
func (c *Context) RemoteClusterTokenRequired() {
if license := c.App.Channels().License(); license == nil || !*license.Features.RemoteClusterService || c.AppContext.Session().Props[model.SessionPropType] != model.SessionTypeRemoteclusterToken {
if license := c.App.Channels().License(); license == nil || !license.HasRemoteClusterService() || c.AppContext.Session().Props[model.SessionPropType] != model.SessionTypeRemoteclusterToken {
c.Err = model.NewAppError("", "api.context.session_expired.app_error", nil, "TokenRequired", http.StatusUnauthorized)
return
}

View File

@@ -302,7 +302,7 @@ func (h Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
} else {
c.AppContext.SetSession(session)
}
} else if token != "" && c.App.Channels().License() != nil && *c.App.Channels().License().Features.RemoteClusterService && tokenLocation == app.TokenLocationRemoteClusterHeader {
} else if token != "" && c.App.Channels().License() != nil && c.App.Channels().License().HasRemoteClusterService() && tokenLocation == app.TokenLocationRemoteClusterHeader {
// Get the remote cluster
if remoteId := c.GetRemoteID(r); remoteId == "" {
c.Logger.Warn("Missing remote cluster id") //