From 17d7bee37d2b54549b96ac540c58cd35ec9bbd1a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Duffeck?= Date: Fri, 1 Jul 2022 09:13:01 +0200 Subject: [PATCH] Enable machine auth in ocdav --- services/ocdav/pkg/command/server.go | 1 + services/ocdav/pkg/config/config.go | 2 ++ services/ocdav/pkg/config/defaults/defaultconfig.go | 1 + services/ocdav/pkg/config/parser/parse.go | 3 +++ 4 files changed, 7 insertions(+) diff --git a/services/ocdav/pkg/command/server.go b/services/ocdav/pkg/command/server.go index 614a22b6c8..d98d9e2f91 100644 --- a/services/ocdav/pkg/command/server.go +++ b/services/ocdav/pkg/command/server.go @@ -64,6 +64,7 @@ func Server(cfg *config.Config) *cli.Command { ocdav.Version(cfg.Status.Version), ocdav.VersionString(cfg.Status.VersionString), ocdav.Edition(cfg.Status.Edition), + ocdav.MachineAuthAPIKey(cfg.MachineAuthAPIKey), // ocdav.FavoriteManager() // FIXME needs a proper persistence implementation https://github.com/owncloud/ocis/issues/1228 // ocdav.LockSystem(), // will default to the CS3 lock system // ocdav.TLSConfig() // tls config for the http server diff --git a/services/ocdav/pkg/config/config.go b/services/ocdav/pkg/config/config.go index cbd33b6ffc..bbb7b11681 100644 --- a/services/ocdav/pkg/config/config.go +++ b/services/ocdav/pkg/config/config.go @@ -32,6 +32,8 @@ type Config struct { Timeout int64 `yaml:"gateway_request_timeout" env:"OCDAV_GATEWAY_REQUEST_TIMEOUT" desc:"Request timeout in seconds for requests from the oCDAV service to the gateway service."` Middleware Middleware `yaml:"middleware"` + MachineAuthAPIKey string `yaml:"machine_auth_api_key" env:"OCIS_MACHINE_AUTH_API_KEY;OCDAV_MACHINE_AUTH_API_KEY" desc:"Machine auth API key used for validating requests from other services when impersonating users."` + Context context.Context `yaml:"-"` Status Status `yaml:"-"` } diff --git a/services/ocdav/pkg/config/defaults/defaultconfig.go b/services/ocdav/pkg/config/defaults/defaultconfig.go index 804e565284..181bd55bc7 100644 --- a/services/ocdav/pkg/config/defaults/defaultconfig.go +++ b/services/ocdav/pkg/config/defaults/defaultconfig.go @@ -43,6 +43,7 @@ func DefaultConfig() *config.Config { CredentialsByUserAgent: map[string]string{}, }, }, + MachineAuthAPIKey: "", Status: config.Status{ Version: version.Legacy, VersionString: version.LegacyString, diff --git a/services/ocdav/pkg/config/parser/parse.go b/services/ocdav/pkg/config/parser/parse.go index 6a1de96b28..545dfe45af 100644 --- a/services/ocdav/pkg/config/parser/parse.go +++ b/services/ocdav/pkg/config/parser/parse.go @@ -37,6 +37,9 @@ func Validate(cfg *config.Config) error { if cfg.TokenManager.JWTSecret == "" { return shared.MissingJWTTokenError(cfg.Service.Name) } + if cfg.MachineAuthAPIKey == "" { + return shared.MissingMachineAuthApiKeyError(cfg.Service.Name) + } return nil }