diff --git a/server/config/config.go b/server/config/config.go index 366c0ac0d9..0e38a10fc3 100644 --- a/server/config/config.go +++ b/server/config/config.go @@ -622,6 +622,7 @@ type FleetConfig struct { type PartnershipsConfig struct { EnableSecureframe bool `yaml:"enable_secureframe"` + EnablePrimo bool `yaml:"enable_primo"` } type MDMConfig struct { @@ -1169,6 +1170,7 @@ func (man Manager) addConfigs() { // Email man.addConfigString("email.backend", "", "Provide the email backend type, acceptable values are currently \"ses\" and \"default\" or empty string which will default to SMTP") + // SES man.addConfigString("ses.region", "", "AWS Region to use") man.addConfigString("ses.endpoint_url", "", "AWS Service Endpoint to use (leave empty for default service endpoints)") @@ -1412,6 +1414,7 @@ func (man Manager) addConfigs() { // Partnerships man.addConfigBool("partnerships.enable_secureframe", false, "Point transparency URL at Secureframe landing page") + man.addConfigBool("partnerships.enable_primo", false, "Cosmetically disables team capabilities in the UI") } func (man Manager) hideConfig(name string) { @@ -1692,6 +1695,7 @@ func (man Manager) LoadConfig() FleetConfig { }, Partnerships: PartnershipsConfig{ EnableSecureframe: man.getConfigBool("partnerships.enable_secureframe"), + EnablePrimo: man.getConfigBool("partnerships.enable_primo"), }, } diff --git a/server/fleet/app.go b/server/fleet/app.go index 6b659a4f24..d730aed6e4 100644 --- a/server/fleet/app.go +++ b/server/fleet/app.go @@ -1319,6 +1319,11 @@ const ( TierTrial = "trial" ) +// Partnerships contains specialized configuration options for Fleet partners. +type Partnerships struct { + EnablePrimo bool `json:"enable_primo,omitempty"` +} + // LicenseInfo contains information about the Fleet license. type LicenseInfo struct { // Tier is the license tier (currently "free" or "premium") diff --git a/server/fleet/service.go b/server/fleet/service.go index 08a6db8ee2..c049a36322 100644 --- a/server/fleet/service.go +++ b/server/fleet/service.go @@ -473,6 +473,9 @@ type Service interface { // License returns the licensing information. License(ctx context.Context) (*LicenseInfo, error) + // PartnershipsConfig returns Fleet partnership-specific configuration + PartnershipsConfig(ctx context.Context) (*Partnerships, error) + // LoggingConfig parses config.FleetConfig instance and returns a Logging. LoggingConfig(ctx context.Context) (*Logging, error) diff --git a/server/service/appconfig.go b/server/service/appconfig.go index 5ee291819d..e3ba31f396 100644 --- a/server/service/appconfig.go +++ b/server/service/appconfig.go @@ -52,9 +52,10 @@ type appConfigResponseFields struct { // Email is returned when the email backend is something other than SMTP, for example SES Email *fleet.EmailConfig `json:"email,omitempty"` // SandboxEnabled is true if fleet serve was ran with server.sandbox_enabled=true - SandboxEnabled bool `json:"sandbox_enabled,omitempty"` - Err error `json:"error,omitempty"` - AndroidEnabled bool `json:"android_enabled,omitempty"` + SandboxEnabled bool `json:"sandbox_enabled,omitempty"` + Err error `json:"error,omitempty"` + AndroidEnabled bool `json:"android_enabled,omitempty"` + Partnerships *fleet.Partnerships `json:"partnerships,omitempty"` } // UnmarshalJSON implements the json.Unmarshaler interface to make sure we serialize @@ -130,6 +131,10 @@ func getAppConfigEndpoint(ctx context.Context, request interface{}, svc fleet.Se if err != nil { return nil, err } + partnerships, err := svc.PartnershipsConfig(ctx) + if err != nil { + return nil, err + } isGlobalAdmin := vc.User.GlobalRole != nil && *vc.User.GlobalRole == fleet.RoleAdmin isAnyTeamAdmin := false @@ -198,6 +203,7 @@ func getAppConfigEndpoint(ctx context.Context, request interface{}, svc fleet.Se Email: emailConfig, SandboxEnabled: svc.SandboxEnabled(), AndroidEnabled: os.Getenv("FLEET_DEV_ANDROID_ENABLED") == "1", // Temporary feature flag that will be removed. + Partnerships: partnerships, }, } return response, nil diff --git a/server/service/service_appconfig.go b/server/service/service_appconfig.go index 0574320025..d61331f357 100644 --- a/server/service/service_appconfig.go +++ b/server/service/service_appconfig.go @@ -243,3 +243,17 @@ func (svc *Service) EmailConfig(ctx context.Context) (*fleet.EmailConfig, error) return email, nil } + +func (svc *Service) PartnershipsConfig(ctx context.Context) (*fleet.Partnerships, error) { + if err := svc.authz.Authorize(ctx, &fleet.AppConfig{}, fleet.ActionRead); err != nil { + return nil, err + } + enablePrimo := svc.config.Partnerships.EnablePrimo + if !enablePrimo { + // for now, since this is the only partnership of this type, exclude the whole struct if not enabled + return nil, nil + } + return &fleet.Partnerships{ + EnablePrimo: svc.config.Partnerships.EnablePrimo, + }, nil +}