Skip to content

Commit

Permalink
Enable machine auth in ocdav
Browse files Browse the repository at this point in the history
  • Loading branch information
aduffeck committed Jul 5, 2022
1 parent d75b4ad commit 17d7bee
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions services/ocdav/pkg/command/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions services/ocdav/pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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:"-"`
}
Expand Down
1 change: 1 addition & 0 deletions services/ocdav/pkg/config/defaults/defaultconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ func DefaultConfig() *config.Config {
CredentialsByUserAgent: map[string]string{},
},
},
MachineAuthAPIKey: "",
Status: config.Status{
Version: version.Legacy,
VersionString: version.LegacyString,
Expand Down
3 changes: 3 additions & 0 deletions services/ocdav/pkg/config/parser/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

0 comments on commit 17d7bee

Please sign in to comment.