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) {
@@ -1,6 +1,7 @@
package defaults
import (
"log"
"strings"
"github.com/owncloud/ocis/extensions/ocs/pkg/config"
@@ -44,7 +45,6 @@ func DefaultConfig() *config.Config {
Address: "127.0.0.1:9142",
},
StorageUsersDriver: "ocis",
MachineAuthAPIKey: "change-me-please",
IdentityManagement: config.IdentityManagement{
Address: "https://localhost:9200",
},
@@ -82,6 +82,12 @@ func EnsureDefaults(cfg *config.Config) {
} else {
cfg.TokenManager = &shared.TokenManager{}
}
if cfg.MachineAuthAPIKey == "" && cfg.Commons != nil && cfg.Commons.MachineAuthAPIKey != "" {
cfg.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) {
@@ -1,6 +1,7 @@
package defaults
import (
"log"
"path"
"strings"
@@ -45,7 +46,6 @@ func DefaultConfig() *config.Config {
AccountBackend: "accounts",
UserOIDCClaim: "email",
UserCS3Claim: "mail",
MachineAuthAPIKey: "change-me-please",
AutoprovisionAccounts: false,
EnableBasicAuth: false,
InsecureBackends: false,
@@ -185,6 +185,12 @@ func EnsureDefaults(cfg *config.Config) {
} else {
cfg.TokenManager = &config.TokenManager{}
}
if cfg.MachineAuthAPIKey == "" && cfg.Commons != nil && cfg.Commons.MachineAuthAPIKey != "" {
cfg.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) {
@@ -1,6 +1,7 @@
package defaults
import (
"log"
"path"
"strings"
@@ -53,11 +54,10 @@ func DefaultConfig() *config.Config {
},
Metadata: config.Metadata{
GatewayAddress: "127.0.0.1:9142",
StorageAddress: "127.0.0.1:9215",
ServiceUserID: "95cb8724-03b2-11eb-a0a6-c33ef8ef53ad",
ServiceUserIDP: "https://localhost:9200",
MachineAuthAPIKey: "change-me-please",
GatewayAddress: "127.0.0.1:9142",
StorageAddress: "127.0.0.1:9215",
ServiceUserID: "95cb8724-03b2-11eb-a0a6-c33ef8ef53ad",
ServiceUserIDP: "https://localhost:9200",
},
}
}
@@ -93,6 +93,12 @@ func EnsureDefaults(cfg *config.Config) {
} else {
cfg.TokenManager = &shared.TokenManager{}
}
if cfg.Metadata.MachineAuthAPIKey == "" && cfg.Commons != nil && cfg.Commons.MachineAuthAPIKey != "" {
cfg.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) {
@@ -328,9 +328,7 @@ func DefaultConfig() *config.Config {
Services: []string{"authprovider"},
Endpoint: "localhost:9166",
},
AuthMachineConfig: config.AuthMachineConfig{
MachineAuthAPIKey: "change-me-please",
},
AuthMachineConfig: config.AuthMachineConfig{},
Sharing: config.Sharing{
Port: config.Port{
Endpoint: "localhost:9150",