Move machine-auth-api-key to shared.Commons

Signed-off-by: Christian Richter <crichter@owncloud.com>
This commit is contained in:
Christian Richter
2022-04-26 10:20:15 +02:00
parent acf75afebc
commit a4d7696232
13 changed files with 67 additions and 43 deletions
@@ -86,7 +86,7 @@ func (m Mail) getReceiverAddresses(receivers []string) ([]string, error) {
res, err := m.gatewayClient.Authenticate(context.Background(), &gateway.AuthenticateRequest{
Type: "machine",
ClientId: "userid:" + id,
ClientSecret: m.conf.Notifications.MachineAuthSecret,
ClientSecret: m.conf.Notifications.MachineAuthAPIKey,
})
if err != nil {
return nil, err
+1 -1
View File
@@ -48,7 +48,7 @@ type SutureService struct {
// NewSutureService creates a new notifications.SutureService
func NewSutureService(cfg *ociscfg.Config) suture.Service {
cfg.Settings.Commons = cfg.Commons
cfg.Notifications.Commons = cfg.Commons
return SutureService{
cfg: cfg.Notifications,
}
@@ -22,10 +22,11 @@ type Config struct {
// Notifications definces the config options for the notifications service.
type Notifications struct {
*shared.Commons `yaml:"-"`
SMTP SMTP `yaml:"SMTP,omitempty"`
Events Events `yaml:"events,omitempty"`
RevaGateway string `yaml:"reva_gateway,omitempty" env:"REVA_GATEWAY;NOTIFICATIONS_REVA_GATEWAY"`
MachineAuthSecret string `yaml:"machine_auth_api_key" env:"OCIS_MACHINE_AUTH_API_KEY;NOTIFICATIONS_MACHINE_AUTH_API_KEY"`
MachineAuthAPIKey string `yaml:"machine_auth_api_key" env:"OCIS_MACHINE_AUTH_API_KEY;NOTIFICATIONS_MACHINE_AUTH_API_KEY"`
}
// SMTP combines the smtp configuration options.
@@ -1,6 +1,10 @@
package defaults
import "github.com/owncloud/ocis/extensions/notifications/pkg/config"
import (
"log"
"github.com/owncloud/ocis/extensions/notifications/pkg/config"
)
func FullDefaultConfig() *config.Config {
cfg := DefaultConfig()
@@ -31,8 +35,7 @@ func DefaultConfig() *config.Config {
Cluster: "ocis-cluster",
ConsumerGroup: "notifications",
},
RevaGateway: "127.0.0.1:9142",
MachineAuthSecret: "change-me-please",
RevaGateway: "127.0.0.1:9142",
},
}
}
@@ -49,6 +52,12 @@ func EnsureDefaults(cfg *config.Config) {
} else if cfg.Log == nil {
cfg.Log = &config.Log{}
}
if cfg.Notifications.MachineAuthAPIKey == "" && cfg.Commons != nil && cfg.Commons.MachineAuthAPIKey != "" {
cfg.Notifications.MachineAuthAPIKey = cfg.Commons.MachineAuthAPIKey
} else {
log.Fatalf("machine auth api key is not set up properly, bailing out (%s)", cfg.Service.Name)
}
}
func Sanitize(cfg *config.Config) {