diff --git a/docs/services/general-info/port-ranges.md b/docs/services/general-info/port-ranges.md index fd6072e7c..317fa8b87 100644 --- a/docs/services/general-info/port-ranges.md +++ b/docs/services/general-info/port-ranges.md @@ -67,7 +67,7 @@ We also suggest to use the last port in your extensions' range as a debug/metric | 9265-9269 | FREE | | 9270-9274 | [eventhistory]({{< ref "../eventhistory/_index.md" >}}) | | 9275-9279 | FREE | -| 9280-9284 | FREE | +| 9280-9284 | [ocm]({{< ref "../ocm/_index.md" >}}) | | 9285-9289 | FREE | | 9290-9294 | FREE | | 9295-9299 | FREE | diff --git a/go.mod b/go.mod index 8df28652a..d451b2685 100644 --- a/go.mod +++ b/go.mod @@ -12,8 +12,8 @@ require ( github.com/blevesearch/bleve/v2 v2.3.10 github.com/coreos/go-oidc v2.2.1+incompatible github.com/coreos/go-oidc/v3 v3.7.0 - github.com/cs3org/go-cs3apis v0.0.0-20230727093620-0f4399be4543 - github.com/cs3org/reva/v2 v2.16.1-0.20231023124625-f9a66375fd79 + github.com/cs3org/go-cs3apis v0.0.0-20231023073225-7748710e0781 + github.com/cs3org/reva/v2 v2.16.1-0.20231024092538-194fbe4a2c31 github.com/disintegration/imaging v1.6.2 github.com/dutchcoders/go-clamd v0.0.0-20170520113014-b970184f4d9e github.com/egirna/icap-client v0.1.1 @@ -340,6 +340,3 @@ require ( gopkg.in/yaml.v3 v3.0.1 // indirect sigs.k8s.io/yaml v1.3.0 // indirect ) - -// the replacement build is based on https://github.com/aduffeck/cs3apis/tree/master -replace github.com/cs3org/go-cs3apis => github.com/aduffeck/go-cs3apis v0.0.0-20231009082215-ad45e19edac0 diff --git a/go.sum b/go.sum index 4a52d77e2..3244f77a9 100644 --- a/go.sum +++ b/go.sum @@ -825,8 +825,6 @@ github.com/Shopify/sarama v1.19.0/go.mod h1:FVkBWblsNy7DGZRfXLU0O9RCGt5g3g3yEuWX github.com/Shopify/toxiproxy v2.1.4+incompatible/go.mod h1:OXgGpZ6Cli1/URJOF1DMxUHB2q5Ap20/P/eIdh4G0pI= github.com/acomagu/bufpipe v1.0.3 h1:fxAGrHZTgQ9w5QqVItgzwj235/uYZYgbXitB+dLupOk= github.com/acomagu/bufpipe v1.0.3/go.mod h1:mxdxdup/WdsKVreO5GpW4+M/1CE2sMG4jeGJ2sYmHc4= -github.com/aduffeck/go-cs3apis v0.0.0-20231009082215-ad45e19edac0 h1:y9gvblZJHMENTzgolQ9sChKONSILkJ4U/j7OqMIF4QM= -github.com/aduffeck/go-cs3apis v0.0.0-20231009082215-ad45e19edac0/go.mod h1:UXha4TguuB52H14EMoSsCqDj7k8a/t7g4gVP+bgY5LY= github.com/agnivade/levenshtein v1.1.1 h1:QY8M92nrzkmr798gCo3kmMyqXFzdQVpxLlGPRBij0P8= github.com/agnivade/levenshtein v1.1.1/go.mod h1:veldBMzWxcCG2ZvUTKD2kJNRdCk5hVbJomOvKkmgYbo= github.com/ajg/form v1.5.1 h1:t9c7v8JUKu/XxOGBU0yjNpaMloxGEJhUkqFRq0ibGeU= @@ -1013,8 +1011,10 @@ github.com/crewjam/httperr v0.2.0 h1:b2BfXR8U3AlIHwNeFFvZ+BV1LFvKLlzMjzaTnZMybNo github.com/crewjam/httperr v0.2.0/go.mod h1:Jlz+Sg/XqBQhyMjdDiC+GNNRzZTD7x39Gu3pglZ5oH4= github.com/crewjam/saml v0.4.14 h1:g9FBNx62osKusnFzs3QTN5L9CVA/Egfgm+stJShzw/c= github.com/crewjam/saml v0.4.14/go.mod h1:UVSZCf18jJkk6GpWNVqcyQJMD5HsRugBPf4I1nl2mME= -github.com/cs3org/reva/v2 v2.16.1-0.20231023124625-f9a66375fd79 h1:c6rk7hzCq+9lvOtWKPH6DbGnCHvNQosW2H8YQaslneU= -github.com/cs3org/reva/v2 v2.16.1-0.20231023124625-f9a66375fd79/go.mod h1:rY/itYaRBW7NjLpLIrWHSUirqEeBz5kdKbF5Dh96yMA= +github.com/cs3org/go-cs3apis v0.0.0-20231023073225-7748710e0781 h1:BUdwkIlf8IS2FasrrPg8gGPHQPOrQ18MS1Oew2tmGtY= +github.com/cs3org/go-cs3apis v0.0.0-20231023073225-7748710e0781/go.mod h1:UXha4TguuB52H14EMoSsCqDj7k8a/t7g4gVP+bgY5LY= +github.com/cs3org/reva/v2 v2.16.1-0.20231024092538-194fbe4a2c31 h1:FUCdIAKFYXcr+J6xYS/enrdLD0Hy+yVhS9WXBXtuJ4s= +github.com/cs3org/reva/v2 v2.16.1-0.20231024092538-194fbe4a2c31/go.mod h1:utPCNSrWDdAwz2biLrKvzO6nDH9L7vRVGNzof13r8Kw= github.com/cyberdelia/templates v0.0.0-20141128023046-ca7fffd4298c/go.mod h1:GyV+0YP4qX0UQ7r2MoYZ+AvYDp12OF5yg4q8rGnyNh4= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= diff --git a/ocis-pkg/config/config.go b/ocis-pkg/config/config.go index 8473d3877..1e943abdb 100644 --- a/ocis-pkg/config/config.go +++ b/ocis-pkg/config/config.go @@ -22,6 +22,7 @@ import ( nats "github.com/owncloud/ocis/v2/services/nats/pkg/config" notifications "github.com/owncloud/ocis/v2/services/notifications/pkg/config" ocdav "github.com/owncloud/ocis/v2/services/ocdav/pkg/config" + ocm "github.com/owncloud/ocis/v2/services/ocm/pkg/config" ocs "github.com/owncloud/ocis/v2/services/ocs/pkg/config" policies "github.com/owncloud/ocis/v2/services/policies/pkg/config" postprocessing "github.com/owncloud/ocis/v2/services/postprocessing/pkg/config" @@ -71,7 +72,7 @@ type Config struct { Registry string `yaml:"registry"` TokenManager *shared.TokenManager `yaml:"token_manager"` - MachineAuthAPIKey string `yaml:"machine_auth_api_key"env:"OCIS_MACHINE_AUTH_API_KEY" desc:"Machine auth API key used to validate internal requests necessary for the access to resources from other services."` + MachineAuthAPIKey string `yaml:"machine_auth_api_key" env:"OCIS_MACHINE_AUTH_API_KEY" desc:"Machine auth API key used to validate internal requests necessary for the access to resources from other services."` TransferSecret string `yaml:"transfer_secret" env:"OCIS_TRANSFER_SECRET" desc:"Transfer secret for signing file up- and download requests."` SystemUserID string `yaml:"system_user_id" env:"OCIS_SYSTEM_USER_ID" desc:"ID of the oCIS storage-system system user. Admins need to set the ID for the storage-system system user in this config option which is then used to reference the user. Any reasonable long string is possible, preferably this would be an UUIDv4 format."` SystemUserAPIKey string `yaml:"system_user_api_key" env:"OCIS_SYSTEM_USER_API_KEY" desc:"API key for the storage-system system user."` @@ -98,6 +99,7 @@ type Config struct { Nats *nats.Config `yaml:"nats"` Notifications *notifications.Config `yaml:"notifications"` OCDav *ocdav.Config `yaml:"ocdav"` + OCM *ocm.Config `yaml:"ocm"` OCS *ocs.Config `yaml:"ocs"` Postprocessing *postprocessing.Config `yaml:"postprocessing"` Policies *policies.Config `yaml:"policies"` diff --git a/ocis-pkg/config/defaultconfig.go b/ocis-pkg/config/defaultconfig.go index 3d068b09b..9483bb8e0 100644 --- a/ocis-pkg/config/defaultconfig.go +++ b/ocis-pkg/config/defaultconfig.go @@ -21,6 +21,7 @@ import ( nats "github.com/owncloud/ocis/v2/services/nats/pkg/config/defaults" notifications "github.com/owncloud/ocis/v2/services/notifications/pkg/config/defaults" ocdav "github.com/owncloud/ocis/v2/services/ocdav/pkg/config/defaults" + ocm "github.com/owncloud/ocis/v2/services/ocm/pkg/config/defaults" ocs "github.com/owncloud/ocis/v2/services/ocs/pkg/config/defaults" policies "github.com/owncloud/ocis/v2/services/policies/pkg/config/defaults" postprocessing "github.com/owncloud/ocis/v2/services/postprocessing/pkg/config/defaults" @@ -70,6 +71,7 @@ func DefaultConfig() *Config { Nats: nats.DefaultConfig(), Notifications: notifications.DefaultConfig(), OCDav: ocdav.DefaultConfig(), + OCM: ocm.DefaultConfig(), OCS: ocs.DefaultConfig(), Postprocessing: postprocessing.DefaultConfig(), Policies: policies.DefaultConfig(), diff --git a/ocis/pkg/runtime/service/service.go b/ocis/pkg/runtime/service/service.go index 9687867fd..ed5918584 100644 --- a/ocis/pkg/runtime/service/service.go +++ b/ocis/pkg/runtime/service/service.go @@ -39,6 +39,7 @@ import ( nats "github.com/owncloud/ocis/v2/services/nats/pkg/command" notifications "github.com/owncloud/ocis/v2/services/notifications/pkg/command" ocdav "github.com/owncloud/ocis/v2/services/ocdav/pkg/command" + ocm "github.com/owncloud/ocis/v2/services/ocm/pkg/command" ocs "github.com/owncloud/ocis/v2/services/ocs/pkg/command" policies "github.com/owncloud/ocis/v2/services/policies/pkg/command" postprocessing "github.com/owncloud/ocis/v2/services/postprocessing/pkg/command" @@ -317,6 +318,11 @@ func NewService(options ...Option) (*Service, error) { cfg.SSE.Commons = cfg.Commons return sse.Execute(cfg.SSE) }) + dreg(opts.Config.OCM.Service.Name, func(ctx context.Context, cfg *ociscfg.Config) error { + cfg.OCM.Context = ctx + cfg.OCM.Commons = cfg.Commons + return ocm.Execute(cfg.OCM) + }) return s, nil } diff --git a/services/gateway/pkg/config/config.go b/services/gateway/pkg/config/config.go index 77ddcb303..89993fce2 100644 --- a/services/gateway/pkg/config/config.go +++ b/services/gateway/pkg/config/config.go @@ -43,6 +43,7 @@ type Config struct { StorageUsersEndpoint string `yaml:"-"` StorageSharesEndpoint string `yaml:"-"` AppRegistryEndpoint string `yaml:"-"` + OCMEndpoint string `yaml:"-"` StorageRegistry StorageRegistry `yaml:"storage_registry"` // TODO: should we even support switching this? diff --git a/services/gateway/pkg/config/defaults/defaultconfig.go b/services/gateway/pkg/config/defaults/defaultconfig.go index f66332a67..736638cb2 100644 --- a/services/gateway/pkg/config/defaults/defaultconfig.go +++ b/services/gateway/pkg/config/defaults/defaultconfig.go @@ -63,6 +63,7 @@ func DefaultConfig() *config.Config { StorageSharesEndpoint: "com.owncloud.api.storage-shares", StorageUsersEndpoint: "com.owncloud.api.storage-users", UsersEndpoint: "com.owncloud.api.users", + OCMEndpoint: "com.owncloud.api.ocm", StorageRegistry: config.StorageRegistry{ Driver: "spaces", diff --git a/services/gateway/pkg/revaconfig/config.go b/services/gateway/pkg/revaconfig/config.go index 97ef2b44d..858b369e8 100644 --- a/services/gateway/pkg/revaconfig/config.go +++ b/services/gateway/pkg/revaconfig/config.go @@ -50,7 +50,10 @@ func GatewayConfigFromStruct(cfg *config.Config, logger log.Logger) map[string]i // sharing is located on the sharing service "usershareprovidersvc": cfg.SharingEndpoint, "publicshareprovidersvc": cfg.SharingEndpoint, - "ocmshareprovidersvc": cfg.SharingEndpoint, + "ocmshareprovidersvc": cfg.OCMEndpoint, + "ocminvitemanagersvc": cfg.OCMEndpoint, + "ocmproviderauthorizersvc": cfg.OCMEndpoint, + "ocmcoresvc": cfg.OCMEndpoint, "commit_share_to_storage_grant": cfg.CommitShareToStorageGrant, "share_folder": cfg.ShareFolder, // ShareFolder is the location where to create shares in the recipient's storage provider. // other @@ -84,6 +87,7 @@ func GatewayConfigFromStruct(cfg *config.Config, logger log.Logger) map[string]i "machine": cfg.AuthMachineEndpoint, "publicshares": cfg.StoragePublicLinkEndpoint, "serviceaccounts": cfg.AuthServiceEndpoint, + "ocmshares": cfg.OCMEndpoint, }, }, }, diff --git a/services/ocdav/pkg/command/server.go b/services/ocdav/pkg/command/server.go index 881aabf03..10f703345 100644 --- a/services/ocdav/pkg/command/server.go +++ b/services/ocdav/pkg/command/server.go @@ -63,6 +63,7 @@ func Server(cfg *config.Config) *cli.Command { ocdav.AllowedOrigins(cfg.HTTP.CORS.AllowedOrigins), ocdav.FilesNamespace(cfg.FilesNamespace), ocdav.WebdavNamespace(cfg.WebdavNamespace), + ocdav.OCMNamespace(cfg.OCMNamespace), ocdav.AllowDepthInfinity(cfg.AllowPropfindDepthInfinity), ocdav.SharesNamespace(cfg.SharesNamespace), ocdav.Timeout(cfg.Timeout), diff --git a/services/ocdav/pkg/config/config.go b/services/ocdav/pkg/config/config.go index a89acd388..b97086c5e 100644 --- a/services/ocdav/pkg/config/config.go +++ b/services/ocdav/pkg/config/config.go @@ -23,6 +23,7 @@ type Config struct { WebdavNamespace string `yaml:"webdav_namespace" env:"OCDAV_WEBDAV_NAMESPACE" desc:"Jail requests to /dav/webdav into this CS3 namespace. Supports template layouting with CS3 User properties."` FilesNamespace string `yaml:"files_namespace" env:"OCDAV_FILES_NAMESPACE" desc:"Jail requests to /dav/files/{username} into this CS3 namespace. Supports template layouting with CS3 User properties."` SharesNamespace string `yaml:"shares_namespace" env:"OCDAV_SHARES_NAMESPACE" desc:"The human readable path for the share jail. Relative to a users personal space root. Upcased intentionally."` + OCMNamespace string `yaml:"ocm_namespace" env:"OCDAV_OCM_NAMESPACE" desc:"The human readable path prefix for the ocm shares."` // PublicURL used to redirect /s/{token} URLs to PublicURL string `yaml:"public_url" env:"OCIS_URL;OCDAV_PUBLIC_URL" desc:"URL where oCIS is reachable for users."` diff --git a/services/ocdav/pkg/config/defaults/defaultconfig.go b/services/ocdav/pkg/config/defaults/defaultconfig.go index 07d11f6bd..cfb1a6b6b 100644 --- a/services/ocdav/pkg/config/defaults/defaultconfig.go +++ b/services/ocdav/pkg/config/defaults/defaultconfig.go @@ -81,6 +81,7 @@ func DefaultConfig() *config.Config { WebdavNamespace: "/users/{{.Id.OpaqueId}}", FilesNamespace: "/users/{{.Id.OpaqueId}}", SharesNamespace: "/Shares", + OCMNamespace: "/public", PublicURL: "https://localhost:9200", Insecure: false, Timeout: 84300, diff --git a/services/ocm/Makefile b/services/ocm/Makefile new file mode 100644 index 000000000..c53bbee76 --- /dev/null +++ b/services/ocm/Makefile @@ -0,0 +1,37 @@ +SHELL := bash +NAME := ocm + +include ../../.make/recursion.mk + +############ tooling ############ +ifneq (, $(shell command -v go 2> /dev/null)) # suppress `command not found warnings` for non go targets in CI +include ../../.bingo/Variables.mk +endif + +############ go tooling ############ +include ../../.make/go.mk + +############ release ############ +include ../../.make/release.mk + +############ docs generate ############ +include ../../.make/docs.mk + +.PHONY: docs-generate +docs-generate: config-docs-generate + +############ generate ############ +include ../../.make/generate.mk + +.PHONY: ci-go-generate +ci-go-generate: # CI runs ci-node-generate automatically before this target + +.PHONY: ci-node-generate +ci-node-generate: + +############ licenses ############ +.PHONY: ci-node-check-licenses +ci-node-check-licenses: + +.PHONY: ci-node-save-licenses +ci-node-save-licenses: diff --git a/services/ocm/README.md b/services/ocm/README.md new file mode 100644 index 000000000..434070361 --- /dev/null +++ b/services/ocm/README.md @@ -0,0 +1,3 @@ +# OCM + +The `ocm` service provides federated sharing functionality based on [sciencemesh](https://sciencemesh.io/) and [ocm](https://github.com/cs3org/OCM-API). \ No newline at end of file diff --git a/services/ocm/cmd/ocm/main.go b/services/ocm/cmd/ocm/main.go new file mode 100644 index 000000000..6ac3d5a57 --- /dev/null +++ b/services/ocm/cmd/ocm/main.go @@ -0,0 +1,14 @@ +package main + +import ( + "os" + + "github.com/owncloud/ocis/v2/services/ocm/pkg/command" + "github.com/owncloud/ocis/v2/services/ocm/pkg/config/defaults" +) + +func main() { + if err := command.Execute(defaults.DefaultConfig()); err != nil { + os.Exit(1) + } +} diff --git a/services/ocm/pkg/command/health.go b/services/ocm/pkg/command/health.go new file mode 100644 index 000000000..7f41a24b1 --- /dev/null +++ b/services/ocm/pkg/command/health.go @@ -0,0 +1,18 @@ +package command + +import ( + "github.com/owncloud/ocis/v2/services/ocm/pkg/config" + "github.com/urfave/cli/v2" +) + +// Health is the entrypoint for the health command. +func Health(cfg *config.Config) *cli.Command { + return &cli.Command{ + Name: "health", + Usage: "Check health status", + Action: func(c *cli.Context) error { + // Not implemented + return nil + }, + } +} diff --git a/services/ocm/pkg/command/root.go b/services/ocm/pkg/command/root.go new file mode 100644 index 000000000..7187fe527 --- /dev/null +++ b/services/ocm/pkg/command/root.go @@ -0,0 +1,34 @@ +package command + +import ( + "os" + + "github.com/owncloud/ocis/v2/ocis-pkg/clihelper" + "github.com/owncloud/ocis/v2/services/ocm/pkg/config" + "github.com/urfave/cli/v2" +) + +// GetCommands provides all commands for this service +func GetCommands(cfg *config.Config) cli.Commands { + return []*cli.Command{ + // start this service + Server(cfg), + + // interaction with this service + + // infos about this service + Health(cfg), + Version(cfg), + } +} + +// Execute is the entry point for the ocm command. +func Execute(cfg *config.Config) error { + app := clihelper.DefaultApp(&cli.App{ + Name: "ocm", + Usage: "starts ocm service", + Commands: GetCommands(cfg), + }) + + return app.Run(os.Args) +} diff --git a/services/ocm/pkg/command/server.go b/services/ocm/pkg/command/server.go new file mode 100644 index 000000000..1025d1ce7 --- /dev/null +++ b/services/ocm/pkg/command/server.go @@ -0,0 +1,110 @@ +package command + +import ( + "context" + "fmt" + "os" + "path" + + "github.com/cs3org/reva/v2/cmd/revad/runtime" + "github.com/gofrs/uuid" + "github.com/oklog/run" + "github.com/owncloud/ocis/v2/ocis-pkg/config/configlog" + "github.com/owncloud/ocis/v2/ocis-pkg/registry" + "github.com/owncloud/ocis/v2/ocis-pkg/sync" + "github.com/owncloud/ocis/v2/ocis-pkg/tracing" + "github.com/owncloud/ocis/v2/ocis-pkg/version" + "github.com/owncloud/ocis/v2/services/ocm/pkg/config" + "github.com/owncloud/ocis/v2/services/ocm/pkg/config/parser" + "github.com/owncloud/ocis/v2/services/ocm/pkg/logging" + "github.com/owncloud/ocis/v2/services/ocm/pkg/revaconfig" + "github.com/owncloud/ocis/v2/services/ocm/pkg/server/debug" + "github.com/urfave/cli/v2" +) + +// Server is the entrypoint for the server command. +func Server(cfg *config.Config) *cli.Command { + return &cli.Command{ + Name: "server", + Usage: fmt.Sprintf("start the %s service without runtime (unsupervised mode)", cfg.Service.Name), + Category: "server", + Before: func(c *cli.Context) error { + return configlog.ReturnFatal(parser.ParseConfig(cfg)) + }, + Action: func(c *cli.Context) error { + logger := logging.Configure(cfg.Service.Name, cfg.Log) + traceProvider, err := tracing.GetServiceTraceProvider(cfg.Tracing, cfg.Service.Name) + if err != nil { + return err + } + gr := run.Group{} + ctx, cancel := defineContext(cfg) + + defer cancel() + + rCfg := revaconfig.OCMConfigFromStruct(cfg, logger) + + gr.Add(func() error { + pidFile := path.Join(os.TempDir(), "revad-"+cfg.Service.Name+"-"+uuid.Must(uuid.NewV4()).String()+".pid") + reg := registry.GetRegistry() + + runtime.RunWithOptions(rCfg, pidFile, + runtime.WithLogger(&logger.Logger), + runtime.WithRegistry(reg), + runtime.WithTraceProvider(traceProvider), + ) + + return nil + }, func(err error) { + logger.Error(). + Err(err). + Str("server", cfg.Service.Name). + Msg("Shutting down server") + + cancel() + os.Exit(1) + }) + + debugServer, err := debug.Server( + debug.Logger(logger), + debug.Context(ctx), + debug.Config(cfg), + ) + if err != nil { + logger.Info().Err(err).Str("server", "debug").Msg("Failed to initialize server") + return err + } + + gr.Add(debugServer.ListenAndServe, func(_ error) { + cancel() + }) + + if !cfg.Supervised { + sync.Trap(&gr, cancel) + } + + grpcSvc := registry.BuildGRPCService(cfg.GRPC.Namespace+"."+cfg.Service.Name, uuid.Must(uuid.NewV4()).String(), cfg.GRPC.Addr, version.GetString()) + if err := registry.RegisterService(ctx, grpcSvc, logger); err != nil { + logger.Fatal().Err(err).Msg("failed to register the grpc service") + } + + httpSvc := registry.BuildHTTPService(cfg.HTTP.Namespace+"."+cfg.Service.Name, uuid.Must(uuid.NewV4()).String(), cfg.HTTP.Addr, version.GetString()) + if err := registry.RegisterService(ctx, httpSvc, logger); err != nil { + logger.Fatal().Err(err).Msg("failed to register the http service") + } + + return gr.Run() + }, + } +} + +// defineContext sets the context for the service. If there is a context configured it will create a new child from it, +// if not, it will create a root context that can be cancelled. +func defineContext(cfg *config.Config) (context.Context, context.CancelFunc) { + return func() (context.Context, context.CancelFunc) { + if cfg.Context == nil { + return context.WithCancel(context.Background()) + } + return context.WithCancel(cfg.Context) + }() +} diff --git a/services/ocm/pkg/command/version.go b/services/ocm/pkg/command/version.go new file mode 100644 index 000000000..13639cff0 --- /dev/null +++ b/services/ocm/pkg/command/version.go @@ -0,0 +1,19 @@ +package command + +import ( + "github.com/owncloud/ocis/v2/services/ocm/pkg/config" + "github.com/urfave/cli/v2" +) + +// Version prints the service versions of all running instances. +func Version(cfg *config.Config) *cli.Command { + return &cli.Command{ + Name: "version", + Usage: "print the version of this binary and the running service instances", + Category: "info", + Action: func(c *cli.Context) error { + // not implemented + return nil + }, + } +} diff --git a/services/ocm/pkg/config/config.go b/services/ocm/pkg/config/config.go new file mode 100644 index 000000000..6f9475362 --- /dev/null +++ b/services/ocm/pkg/config/config.go @@ -0,0 +1,131 @@ +package config + +import ( + "context" + + "github.com/owncloud/ocis/v2/ocis-pkg/shared" + "go-micro.dev/v4/client" +) + +// Config combines all available configuration parts. +type Config struct { + Commons *shared.Commons `yaml:"-"` // don't use this directly as configuration for a service + + Service Service `yaml:"-"` + + Tracing *Tracing `yaml:"tracing"` + Log *Log `yaml:"log"` + Debug Debug `yaml:"debug"` + + HTTP HTTPConfig `yaml:"http"` + Middleware Middleware `yaml:"middleware"` + GRPC GRPCConfig `yaml:"grpc"` + GRPCClientTLS *shared.GRPCClientTLS `yaml:"grpc_client_tls"` + GrpcClient client.Client `yaml:"-"` + + Reva *shared.Reva `yaml:"reva"` + OCMD OCMD `yaml:"ocmd"` + ScienceMesh ScienceMesh `yaml:"sciencemesh"` + OCMInviteManager OCMInviteManager `yaml:"ocm_invite_manager"` + OCMProviderAuthorizerDriver string `yaml:"ocm_provider_authorizer_driver" env:"SHARING_OCM_PROVIDER_AUTHORIZER_DRIVER" desc:"Driver to be used to persist ocm invites. Supported values 'json'."` + OCMProviderAuthorizerDrivers OCMProviderAuthorizerDrivers `yaml:"ocm_provider_authorizer_drivers"` + OCMShareProvider OCMShareProvider `yaml:"ocm_share_provider"` + OCMCore OCMCore `yaml:"ocm_core"` + + Supervised bool `yaml:"-"` + Context context.Context `yaml:"-"` +} + +// HTTPConfig defines the available http configuration. +type HTTPConfig struct { + Addr string `yaml:"addr" env:"OCM_HTTP_ADDR" desc:"The bind address of the HTTP service."` + Namespace string `yaml:"-"` + Protocol string `yaml:"protocol" env:"OCM_HTTP_PROTOCOL" desc:"The transport protocol of the HTTP service."` + Prefix string `yaml:"prefix" env:"OCM_HTTP_PREFIX" desc:"The Path prefix where the OCM can be accessed (defaults to /)."` + CORS CORS `yaml:"cors"` +} + +// Middleware configures reva middlewares. +type Middleware struct { + Auth Auth `yaml:"auth"` +} + +// Auth configures reva http auth middleware. +type Auth struct { + CredentialsByUserAgent map[string]string `yaml:"credentials_by_user_agent"` +} + +// CORS defines the available cors configuration. +type CORS struct { + AllowedOrigins []string `yaml:"allow_origins" env:"OCIS_CORS_ALLOW_ORIGINS;OCM_CORS_ALLOW_ORIGINS" desc:"A comma-separated list of allowed CORS origins. See following chapter for more details: *Access-Control-Allow-Origin* at https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Allow-Origin"` + AllowedMethods []string `yaml:"allow_methods" env:"OCIS_CORS_ALLOW_METHODS;OCM_CORS_ALLOW_METHODS" desc:"A comma-separated list of allowed CORS methods. See following chapter for more details: *Access-Control-Request-Method* at https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Request-Method"` + AllowedHeaders []string `yaml:"allow_headers" env:"OCIS_CORS_ALLOW_HEADERS;OCM_CORS_ALLOW_HEADERS" desc:"A blank or comma-separated list of allowed CORS headers. See following chapter for more details: *Access-Control-Request-Headers* at https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Request-Headers."` + AllowCredentials bool `yaml:"allow_credentials" env:"OCIS_CORS_ALLOW_CREDENTIALS;OCM_CORS_ALLOW_CREDENTIALS" desc:"Allow credentials for CORS.See following chapter for more details: *Access-Control-Allow-Credentials* at https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Allow-Credentials."` +} + +// GRPCConfig defines the available grpc configuration. +type GRPCConfig struct { + Addr string `ocisConfig:"addr" env:"OCM_GRPC_ADDR" desc:"The bind address of the GRPC service."` + Namespace string `ocisConfig:"-" yaml:"-"` + TLS *shared.GRPCServiceTLS `yaml:"tls"` + Protocol string `yaml:"protocol" env:"OCM_GRPC_PROTOCOL" desc:"The transport protocol of the GRPC service."` +} + +type ScienceMesh struct { + Prefix string `yaml:"prefix" env:"OCM_SCIENCEMESH_PREFIX" desc:"URL path prefix for the ScienceMesh service. Note that the string must not start with '/'."` +} + +type OCMD struct { + Prefix string `yaml:"prefix" env:"OCM_OCMD_PREFIX" desc:"URL path prefix for the OCMD service. Note that the string must not start with '/'."` + ExposeRecipientDisplayName bool `yaml:"expose_recipient_display_name" env:"OCM_OCMD_EXPOSE_RECIPIENT_DISPLAY_NAME" desc:"Expose the display name of OCM share recipients."` +} + +type OCMInviteManager struct { + Driver string `yaml:"driver" env:"SHARING_OCM_INVITE_MANAGER_DRIVER" desc:"Driver to be used to persist ocm invites. Supported values 'json'."` + Drivers OCMInviteManagerDrivers `yaml:"drivers"` + Insecure bool `yaml:"insecure" env:"SHARING_OCM_INVITE_MANAGER_INSECURE" desc:"Disable TLS certificate validation for the OCM connections. Do not set this in production environments."` +} + +type OCMInviteManagerDrivers struct { + JSON OCMInviteManagerJSONDriver `yaml:"json"` +} + +type OCMInviteManagerJSONDriver struct { + File string `yaml:"file" env:"SHARING_OCM_INVITE_MANAGER_JSON_FILE" desc:"Path to the JSON file where ocm invites data will be stored. If not defined, the root directory derives from $OCIS_BASE_DATA_PATH:/storage."` +} + +type OCMProviderAuthorizerDrivers struct { + JSON OCMProviderAuthorizerJSONDriver `yaml:"json"` +} + +type OCMProviderAuthorizerJSONDriver struct { + Providers string `yaml:"providers" env:"SHARING_OCM_PROVIDER_AUTHORIZER_PROVIDERS_FILE" desc:"Path to the JSON file where ocm invites data will be stored. If not defined, the root directory derives from $OCIS_BASE_DATA_PATH:/storage."` + VerifyRequestHostname bool `yaml:"verify_request_hostname" env:"SHARING_OCM_PROVIDER_AUTHORIZER_PROVIDERS_FILE"` +} + +type OCMCore struct { + Driver string `yaml:"driver" env:"SHARING_OCM_CORE_DRIVER" desc:"Driver to be used for the ocm core. Supported values 'json'."` + Drivers OCMCoreDrivers `yaml:"drivers"` +} + +type OCMCoreDrivers struct { + JSON OCMCoreJSONDriver `yaml:"json"` +} + +type OCMCoreJSONDriver struct { + File string `yaml:"file" env:"SHARING_OCM_CORE_JSON_FILE" desc:"Path to the JSON file where ocm share data will be stored. If not defined, the root directory derives from $OCIS_BASE_DATA_PATH:/storage."` +} + +type OCMShareProvider struct { + Driver string `yaml:"driver" env:"SHARING_OCM_SHARE_PROVIDER_DRIVER" desc:"Driver to be used for the ocm share provider. Supported values 'json'."` + Drivers OCMShareProviderDrivers `yaml:"drivers"` + Insecure bool `yaml:"insecure" env:"SHARING_OCM_SHARE_PROVIDER_INSECURE" desc:"Disable TLS certificate validation for the OCM connections. Do not set this in production environments."` +} + +type OCMShareProviderDrivers struct { + JSON OCMShareProviderJSONDriver `yaml:"json"` +} + +type OCMShareProviderJSONDriver struct { + File string `yaml:"file" env:"SHARING_OCM_SHAREPROVIDER_JSON_FILE" desc:"Path to the JSON file where ocm share data will be stored. If not defined, the root directory derives from $OCIS_BASE_DATA_PATH:/storage."` +} diff --git a/services/ocm/pkg/config/debug.go b/services/ocm/pkg/config/debug.go new file mode 100644 index 000000000..ab96107f4 --- /dev/null +++ b/services/ocm/pkg/config/debug.go @@ -0,0 +1,9 @@ +package config + +// Debug defines the available debug configuration. +type Debug struct { + Addr string `yaml:"addr" env:"OCM_DEBUG_ADDR" desc:"Bind address of the debug server, where metrics, health, config and debug endpoints will be exposed."` + Token string `yaml:"token" env:"OCM_DEBUG_TOKEN" desc:"Token to secure the metrics endpoint."` + Pprof bool `yaml:"pprof" env:"OCM_DEBUG_PPROF" desc:"Enables pprof, which can be used for profiling."` + Zpages bool `yaml:"zpages" env:"OCM_DEBUG_ZPAGES" desc:"Enables zpages, which can be used for collecting and viewing in-memory traces."` +} diff --git a/services/ocm/pkg/config/defaults/defaultconfig.go b/services/ocm/pkg/config/defaults/defaultconfig.go new file mode 100644 index 000000000..df1102631 --- /dev/null +++ b/services/ocm/pkg/config/defaults/defaultconfig.go @@ -0,0 +1,169 @@ +package defaults + +import ( + "path/filepath" + + "github.com/owncloud/ocis/v2/ocis-pkg/config/defaults" + "github.com/owncloud/ocis/v2/ocis-pkg/shared" + "github.com/owncloud/ocis/v2/ocis-pkg/structs" + "github.com/owncloud/ocis/v2/services/ocm/pkg/config" +) + +// FullDefaultConfig returns the full default config +func FullDefaultConfig() *config.Config { + cfg := DefaultConfig() + EnsureDefaults(cfg) + Sanitize(cfg) + return cfg +} + +// DefaultConfig return the default configuration +func DefaultConfig() *config.Config { + return &config.Config{ + Debug: config.Debug{ + Addr: "127.0.0.1:9281", + Token: "", + Pprof: false, + Zpages: false, + }, + HTTP: config.HTTPConfig{ + Addr: "127.0.0.1:9280", + Namespace: "com.owncloud.web", + Protocol: "tcp", + Prefix: "", + CORS: config.CORS{ + AllowedOrigins: []string{"*"}, + AllowedMethods: []string{ + "OPTIONS", + "HEAD", + "GET", + "PUT", + "POST", + "DELETE", + "MKCOL", + "PROPFIND", + "PROPPATCH", + "MOVE", + "COPY", + "REPORT", + "SEARCH", + }, + AllowedHeaders: []string{ + "Origin", + "Accept", + "Content-Type", + "Depth", + "Authorization", + "Ocs-Apirequest", + "If-None-Match", + "If-Match", + "Destination", + "Overwrite", + "X-Request-Id", + "X-Requested-With", + "Tus-Resumable", + "Tus-Checksum-Algorithm", + "Upload-Concat", + "Upload-Length", + "Upload-Metadata", + "Upload-Defer-Length", + "Upload-Expires", + "Upload-Checksum", + "Upload-Offset", + "X-HTTP-Method-Override", + "Cache-Control", + }, + AllowCredentials: true, + }, + }, + GRPC: config.GRPCConfig{ + Addr: "127.0.0.1:9282", + Namespace: "com.owncloud.api", + }, + Reva: shared.DefaultRevaConfig(), + Service: config.Service{ + Name: "ocm", + }, + ScienceMesh: config.ScienceMesh{ + Prefix: "sciencemesh", + }, + OCMD: config.OCMD{ + Prefix: "ocm", + }, + OCMInviteManager: config.OCMInviteManager{ + Driver: "json", + Drivers: config.OCMInviteManagerDrivers{ + JSON: config.OCMInviteManagerJSONDriver{ + File: filepath.Join(defaults.BaseDataPath(), "storage", "ocminvites.json"), + }, + }, + Insecure: false, + }, + OCMProviderAuthorizerDriver: "json", + OCMProviderAuthorizerDrivers: config.OCMProviderAuthorizerDrivers{ + JSON: config.OCMProviderAuthorizerJSONDriver{ + Providers: filepath.Join(defaults.BaseDataPath(), "storage", "ocmproviders.json"), + }, + }, + OCMShareProvider: config.OCMShareProvider{ + Driver: "json", + Drivers: config.OCMShareProviderDrivers{ + JSON: config.OCMShareProviderJSONDriver{ + File: filepath.Join(defaults.BaseDataPath(), "storage", "ocmshares.json"), + }, + }, + Insecure: false, + }, + OCMCore: config.OCMCore{ + Driver: "json", + Drivers: config.OCMCoreDrivers{ + JSON: config.OCMCoreJSONDriver{ + File: filepath.Join(defaults.BaseDataPath(), "storage", "ocmshares.json"), + }, + }, + }, + } +} + +// EnsureDefaults ensures the config contains default values +func EnsureDefaults(cfg *config.Config) { + // provide with defaults for shared logging, since we need a valid destination address for "envdecode". + if cfg.Log == nil && cfg.Commons != nil && cfg.Commons.Log != nil { + cfg.Log = &config.Log{ + Level: cfg.Commons.Log.Level, + Pretty: cfg.Commons.Log.Pretty, + Color: cfg.Commons.Log.Color, + File: cfg.Commons.Log.File, + } + } else if cfg.Log == nil { + cfg.Log = &config.Log{} + } + + if cfg.Tracing == nil && cfg.Commons != nil && cfg.Commons.Tracing != nil { + cfg.Tracing = &config.Tracing{ + Enabled: cfg.Commons.Tracing.Enabled, + Type: cfg.Commons.Tracing.Type, + Endpoint: cfg.Commons.Tracing.Endpoint, + Collector: cfg.Commons.Tracing.Collector, + } + } else if cfg.Tracing == nil { + cfg.Tracing = &config.Tracing{} + } + + if cfg.Reva == nil && cfg.Commons != nil { + cfg.Reva = structs.CopyOrZeroValue(cfg.Commons.Reva) + } + + if cfg.GRPCClientTLS == nil && cfg.Commons != nil { + cfg.GRPCClientTLS = structs.CopyOrZeroValue(cfg.Commons.GRPCClientTLS) + } + + if cfg.GRPC.TLS == nil && cfg.Commons != nil { + cfg.GRPC.TLS = structs.CopyOrZeroValue(cfg.Commons.GRPCServiceTLS) + } +} + +// Sanitize sanitizes the config +func Sanitize(cfg *config.Config) { + // nothing to sanitize here atm +} diff --git a/services/ocm/pkg/config/log.go b/services/ocm/pkg/config/log.go new file mode 100644 index 000000000..5be7a2bce --- /dev/null +++ b/services/ocm/pkg/config/log.go @@ -0,0 +1,9 @@ +package config + +// Log defines the available log configuration. +type Log struct { + Level string `mapstructure:"level" env:"OCIS_LOG_LEVEL;OCM_LOG_LEVEL" desc:"The log level. Valid values are: 'panic', 'fatal', 'error', 'warn', 'info', 'debug', 'trace'."` + Pretty bool `mapstructure:"pretty" env:"OCIS_LOG_PRETTY;OCM_LOG_PRETTY" desc:"Activates pretty log output."` + Color bool `mapstructure:"color" env:"OCIS_LOG_COLOR;OCM_LOG_COLOR" desc:"Activates colorized log output."` + File string `mapstructure:"file" env:"OCIS_LOG_FILE;OCM_LOG_FILE" desc:"The path to the log file. Activates logging to this file if set."` +} diff --git a/services/ocm/pkg/config/parser/parse.go b/services/ocm/pkg/config/parser/parse.go new file mode 100644 index 000000000..223df488b --- /dev/null +++ b/services/ocm/pkg/config/parser/parse.go @@ -0,0 +1,43 @@ +package parser + +import ( + "errors" + + ociscfg "github.com/owncloud/ocis/v2/ocis-pkg/config" + "github.com/owncloud/ocis/v2/ocis-pkg/structs" + "github.com/owncloud/ocis/v2/services/ocm/pkg/config" + "github.com/owncloud/ocis/v2/services/ocm/pkg/config/defaults" + + "github.com/owncloud/ocis/v2/ocis-pkg/config/envdecode" +) + +// ParseConfig loads configuration from known paths. +func ParseConfig(cfg *config.Config) error { + _, err := ociscfg.BindSourcesToStructs(cfg.Service.Name, cfg) + if err != nil { + return err + } + + defaults.EnsureDefaults(cfg) + + // load all env variables relevant to the config in the current context. + if err := envdecode.Decode(cfg); err != nil { + // no environment variable set for this config is an expected "error" + if !errors.Is(err, envdecode.ErrNoTargetFieldsAreSet) { + return err + } + } + + defaults.Sanitize(cfg) + + return Validate(cfg) +} + +// Validate validates the config +func Validate(cfg *config.Config) error { + if cfg.GRPCClientTLS == nil && cfg.Commons != nil { + cfg.GRPCClientTLS = structs.CopyOrZeroValue(cfg.Commons.GRPCClientTLS) + } + + return nil +} diff --git a/services/ocm/pkg/config/service.go b/services/ocm/pkg/config/service.go new file mode 100644 index 000000000..d1eac383f --- /dev/null +++ b/services/ocm/pkg/config/service.go @@ -0,0 +1,6 @@ +package config + +// Service defines the available service configuration. +type Service struct { + Name string `yaml:"-"` +} diff --git a/services/ocm/pkg/config/tracing.go b/services/ocm/pkg/config/tracing.go new file mode 100644 index 000000000..0ba9ed35a --- /dev/null +++ b/services/ocm/pkg/config/tracing.go @@ -0,0 +1,21 @@ +package config + +import "github.com/owncloud/ocis/v2/ocis-pkg/tracing" + +// Tracing defines the available tracing configuration. +type Tracing struct { + Enabled bool `yaml:"enabled" env:"OCIS_TRACING_ENABLED;OCM_TRACING_ENABLED" desc:"Activates tracing."` + Type string `yaml:"type" env:"OCIS_TRACING_TYPE;OCM_TRACING_TYPE" desc:"The type of tracing. Defaults to '', which is the same as 'jaeger'. Allowed tracing types are 'jaeger' and '' as of now."` + Endpoint string `yaml:"endpoint" env:"OCIS_TRACING_ENDPOINT;OCM_TRACING_ENDPOINT" desc:"The endpoint of the tracing agent."` + Collector string `yaml:"collector" env:"OCIS_TRACING_COLLECTOR;OCM_TRACING_COLLECTOR" desc:"The HTTP endpoint for sending spans directly to a collector, i.e. http://jaeger-collector:14268/api/traces. Only used if the tracing endpoint is unset."` +} + +// Convert Tracing to the tracing package's Config struct. +func (t Tracing) Convert() tracing.Config { + return tracing.Config{ + Enabled: t.Enabled, + Type: t.Type, + Endpoint: t.Endpoint, + Collector: t.Collector, + } +} diff --git a/services/ocm/pkg/logging/logging.go b/services/ocm/pkg/logging/logging.go new file mode 100644 index 000000000..64747b5a8 --- /dev/null +++ b/services/ocm/pkg/logging/logging.go @@ -0,0 +1,17 @@ +package logging + +import ( + "github.com/owncloud/ocis/v2/ocis-pkg/log" + "github.com/owncloud/ocis/v2/services/ocm/pkg/config" +) + +// LoggerFromConfig initializes a service-specific logger instance. +func Configure(name string, cfg *config.Log) log.Logger { + return log.NewLogger( + log.Name(name), + log.Level(cfg.Level), + log.Pretty(cfg.Pretty), + log.Color(cfg.Color), + log.File(cfg.File), + ) +} diff --git a/services/ocm/pkg/metrics/metrics.go b/services/ocm/pkg/metrics/metrics.go new file mode 100644 index 000000000..89eeed6da --- /dev/null +++ b/services/ocm/pkg/metrics/metrics.go @@ -0,0 +1,35 @@ +package metrics + +import "github.com/prometheus/client_golang/prometheus" + +var ( + // Namespace defines the namespace for the defines metrics. + Namespace = "ocis" + + // Subsystem defines the subsystem for the defines metrics. + Subsystem = "ocm" +) + +// Metrics defines the available metrics of this service. +type Metrics struct { + BuildInfo *prometheus.GaugeVec +} + +// New initializes the available metrics. +func New() *Metrics { + m := &Metrics{ + BuildInfo: prometheus.NewGaugeVec(prometheus.GaugeOpts{ + Namespace: Namespace, + Subsystem: Subsystem, + Name: "build_info", + Help: "Build information", + }, []string{"version"}), + } + + _ = prometheus.Register( + m.BuildInfo, + ) + + // TODO: implement metrics + return m +} diff --git a/services/ocm/pkg/revaconfig/config.go b/services/ocm/pkg/revaconfig/config.go new file mode 100644 index 000000000..40a10768e --- /dev/null +++ b/services/ocm/pkg/revaconfig/config.go @@ -0,0 +1,115 @@ +package revaconfig + +import ( + "github.com/owncloud/ocis/v2/ocis-pkg/log" + "github.com/owncloud/ocis/v2/services/ocm/pkg/config" +) + +// OCMConfigFromStruct will adapt an oCIS config struct into a reva mapstructure to start a reva service. +func OCMConfigFromStruct(cfg *config.Config, logger log.Logger) map[string]interface{} { + return map[string]interface{}{ + "shared": map[string]interface{}{ + "gatewaysvc": cfg.Reva.Address, // Todo or address? + "grpc_client_options": cfg.Reva.GetGRPCClientConfig(), + }, + "http": map[string]interface{}{ + "network": cfg.HTTP.Protocol, + "address": cfg.HTTP.Addr, + "middlewares": map[string]interface{}{ + "cors": map[string]interface{}{ + "allowed_origins": cfg.HTTP.CORS.AllowedOrigins, + "allowed_methods": cfg.HTTP.CORS.AllowedMethods, + "allowed_headers": cfg.HTTP.CORS.AllowedHeaders, + "allow_credentials": cfg.HTTP.CORS.AllowCredentials, + // currently unused + //"options_passthrough": , + //"debug": , + //"max_age": , + //"priority": , + //"exposed_headers": , + }, + "auth": map[string]interface{}{ + "credentials_by_user_agent": cfg.Middleware.Auth.CredentialsByUserAgent, + }, + "prometheus": map[string]interface{}{ + "namespace": "ocis", + "subsystem": "ocm", + }, + "requestid": map[string]interface{}{}, + }, + // TODO build services dynamically + "services": map[string]interface{}{ + "sciencemesh": map[string]interface{}{ + "prefix": cfg.ScienceMesh.Prefix, + "smtp_credentials": map[string]string{}, + "gatewaysvc": cfg.Reva.Address, + "mesh_directory_url": cfg.Commons.OcisURL, + "provider_domain": cfg.Commons.OcisURL, + }, + "ocmd": map[string]interface{}{ + "prefix": cfg.OCMD.Prefix, + "gatewaysvc": cfg.Reva.Address, + "expose_recipient_display_name": cfg.OCMD.ExposeRecipientDisplayName, + }, + }, + }, + "grpc": map[string]interface{}{ + "network": cfg.GRPC.Protocol, + "address": cfg.GRPC.Addr, + "tls_settings": map[string]interface{}{ + "enabled": cfg.GRPC.TLS.Enabled, + "certificate": cfg.GRPC.TLS.Cert, + "key": cfg.GRPC.TLS.Key, + }, + "services": map[string]interface{}{ + "ocminvitemanager": map[string]interface{}{ + "driver": cfg.OCMInviteManager.Driver, + "drivers": map[string]interface{}{ + "json": map[string]interface{}{ + "file": cfg.OCMInviteManager.Drivers.JSON.File, + }, + }, + "provider_domain": cfg.Commons.OcisURL, + "ocm_insecure": cfg.OCMInviteManager.Insecure, + }, + "ocmproviderauthorizer": map[string]interface{}{ + "driver": cfg.OCMProviderAuthorizerDriver, + "drivers": map[string]interface{}{ + "json": map[string]interface{}{ + "providers": cfg.OCMProviderAuthorizerDrivers.JSON.Providers, + "verify_request_hostname": cfg.OCMProviderAuthorizerDrivers.JSON.VerifyRequestHostname, + }, + }, + }, + "ocmshareprovider": map[string]interface{}{ + "driver": cfg.OCMShareProvider.Driver, + "drivers": map[string]interface{}{ + "json": map[string]interface{}{ + "file": cfg.OCMShareProvider.Drivers.JSON.File, + }, + }, + "gatewaysvc": cfg.Reva.Address, + "provider_domain": cfg.Commons.OcisURL, + "webdav_endpoint": cfg.Commons.OcisURL, + "client_insecure": cfg.OCMShareProvider.Insecure, + }, + "ocmcore": map[string]interface{}{ + "driver": cfg.OCMCore.Driver, + "drivers": map[string]interface{}{ + "json": map[string]interface{}{ + "file": cfg.OCMCore.Drivers.JSON.File, + }, + }, + }, + "authprovider": map[string]interface{}{ + "auth_manager": "ocmshares", + "auth_managers": map[string]interface{}{ + "ocmshares": map[string]interface{}{ + "gatewaysvc": cfg.Reva.Address, + }, + }, + }, + }, + }, + } +} diff --git a/services/ocm/pkg/server/debug/option.go b/services/ocm/pkg/server/debug/option.go new file mode 100644 index 000000000..b671376be --- /dev/null +++ b/services/ocm/pkg/server/debug/option.go @@ -0,0 +1,50 @@ +package debug + +import ( + "context" + + "github.com/owncloud/ocis/v2/ocis-pkg/log" + "github.com/owncloud/ocis/v2/services/ocm/pkg/config" +) + +// Option defines a single option function. +type Option func(o *Options) + +// Options defines the available options for this package. +type Options struct { + Logger log.Logger + Context context.Context + Config *config.Config +} + +// newOptions initializes the available default options. +func newOptions(opts ...Option) Options { + opt := Options{} + + for _, o := range opts { + o(&opt) + } + + return opt +} + +// Logger provides a function to set the logger option. +func Logger(val log.Logger) Option { + return func(o *Options) { + o.Logger = val + } +} + +// Context provides a function to set the context option. +func Context(val context.Context) Option { + return func(o *Options) { + o.Context = val + } +} + +// Config provides a function to set the config option. +func Config(val *config.Config) Option { + return func(o *Options) { + o.Config = val + } +} diff --git a/services/ocm/pkg/server/debug/server.go b/services/ocm/pkg/server/debug/server.go new file mode 100644 index 000000000..b2275b585 --- /dev/null +++ b/services/ocm/pkg/server/debug/server.go @@ -0,0 +1,63 @@ +package debug + +import ( + "io" + "net/http" + + "github.com/owncloud/ocis/v2/ocis-pkg/service/debug" + "github.com/owncloud/ocis/v2/ocis-pkg/version" + "github.com/owncloud/ocis/v2/services/ocm/pkg/config" +) + +// Server initializes the debug service and server. +func Server(opts ...Option) (*http.Server, error) { + options := newOptions(opts...) + + return debug.NewService( + debug.Logger(options.Logger), + debug.Name(options.Config.Service.Name), + debug.Version(version.GetString()), + debug.Address(options.Config.Debug.Addr), + debug.Token(options.Config.Debug.Token), + debug.Pprof(options.Config.Debug.Pprof), + debug.Zpages(options.Config.Debug.Zpages), + debug.Health(health(options.Config)), + debug.Ready(ready(options.Config)), + //debug.CorsAllowedOrigins(options.Config.HTTP.CORS.AllowedOrigins), + //debug.CorsAllowedMethods(options.Config.HTTP.CORS.AllowedMethods), + //debug.CorsAllowedHeaders(options.Config.HTTP.CORS.AllowedHeaders), + //debug.CorsAllowCredentials(options.Config.HTTP.CORS.AllowCredentials), + ), nil +} + +// health implements the health check. +func health(cfg *config.Config) func(http.ResponseWriter, *http.Request) { + return func(w http.ResponseWriter, r *http.Request) { + w.Header().Set("Content-Type", "text/plain") + w.WriteHeader(http.StatusOK) + + // TODO: check if services are up and running + + _, err := io.WriteString(w, http.StatusText(http.StatusOK)) + // io.WriteString should not fail but if it does we want to know. + if err != nil { + panic(err) + } + } +} + +// ready implements the ready check. +func ready(cfg *config.Config) func(http.ResponseWriter, *http.Request) { + return func(w http.ResponseWriter, r *http.Request) { + w.Header().Set("Content-Type", "text/plain") + w.WriteHeader(http.StatusOK) + + // TODO: check if services are up and running + + _, err := io.WriteString(w, http.StatusText(http.StatusOK)) + // io.WriteString should not fail but if it does we want to know. + if err != nil { + panic(err) + } + } +} diff --git a/services/proxy/pkg/config/defaults/defaultconfig.go b/services/proxy/pkg/config/defaults/defaultconfig.go index 333ab6d7a..460c0b1b3 100644 --- a/services/proxy/pkg/config/defaults/defaultconfig.go +++ b/services/proxy/pkg/config/defaults/defaultconfig.go @@ -143,6 +143,14 @@ func DefaultPolicies() []config.Policy { Service: "com.owncloud.web.frontend", Unprotected: true, }, + { + Endpoint: "/sciencemesh/", + Service: "com.owncloud.web.ocm", + }, + { + Endpoint: "/ocm/", + Service: "com.owncloud.web.ocm", + }, { Endpoint: "/ocs/", Service: "com.owncloud.web.frontend", diff --git a/services/proxy/pkg/middleware/authentication.go b/services/proxy/pkg/middleware/authentication.go index a726eae4c..f173e94da 100644 --- a/services/proxy/pkg/middleware/authentication.go +++ b/services/proxy/pkg/middleware/authentication.go @@ -25,6 +25,8 @@ var ( _publicPaths = [...]string{ "/dav/public-files/", + "/dav/ocm/", + "/ocm/", "/remote.php/dav/public-files/", "/ocs/v1.php/apps/files_sharing/api/v1/tokeninfo/unprotected", "/ocs/v2.php/apps/files_sharing/api/v1/tokeninfo/unprotected", diff --git a/services/sharing/pkg/config/config.go b/services/sharing/pkg/config/config.go index a00441fe8..c739cdc2c 100644 --- a/services/sharing/pkg/config/config.go +++ b/services/sharing/pkg/config/config.go @@ -105,7 +105,6 @@ type UserSharingJSONCS3Driver struct { SystemUserAPIKey string `yaml:"system_user_api_key" env:"OCIS_SYSTEM_USER_API_KEY;SHARING_USER_JSONCS3_SYSTEM_USER_API_KEY" desc:"API key for the STORAGE-SYSTEM system user."` CacheTTL int `yaml:"cache_ttl" env:"SHARING_USER_JSONCS3_CACHE_TTL" desc:"TTL for the internal caches in seconds."` } - type PublicSharingDrivers struct { JSON PublicSharingJSONDriver `yaml:"json"` JSONCS3 PublicSharingJSONCS3Driver `yaml:"jsoncs3"` diff --git a/vendor/github.com/cs3org/go-cs3apis/cs3/sharing/collaboration/v1beta1/resources.pb.go b/vendor/github.com/cs3org/go-cs3apis/cs3/sharing/collaboration/v1beta1/resources.pb.go index 6b1563eea..d81a843ec 100644 --- a/vendor/github.com/cs3org/go-cs3apis/cs3/sharing/collaboration/v1beta1/resources.pb.go +++ b/vendor/github.com/cs3org/go-cs3apis/cs3/sharing/collaboration/v1beta1/resources.pb.go @@ -147,13 +147,10 @@ type Share struct { Mtime *v1beta12.Timestamp `protobuf:"bytes,8,opt,name=mtime,proto3" json:"mtime,omitempty"` // Optional. // The expiration time of the share. - Expiration *v1beta12.Timestamp `protobuf:"bytes,9,opt,name=expiration,proto3" json:"expiration,omitempty"` - // Optional. - // Hide share, default false - Hide bool `protobuf:"varint,10,opt,name=hide,proto3" json:"hide,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` + Expiration *v1beta12.Timestamp `protobuf:"bytes,9,opt,name=expiration,proto3" json:"expiration,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` } func (m *Share) Reset() { *m = Share{} } @@ -244,13 +241,6 @@ func (m *Share) GetExpiration() *v1beta12.Timestamp { return nil } -func (m *Share) GetHide() bool { - if m != nil { - return m.Hide - } - return false -} - // The permissions for a share. type SharePermissions struct { Permissions *v1beta1.ResourcePermissions `protobuf:"bytes,1,opt,name=permissions,proto3" json:"permissions,omitempty"` @@ -304,10 +294,13 @@ type ReceivedShare struct { State ShareState `protobuf:"varint,2,opt,name=state,proto3,enum=cs3.sharing.collaboration.v1beta1.ShareState" json:"state,omitempty"` // REQUIRED. // The mount point of the share. - MountPoint *v1beta1.Reference `protobuf:"bytes,3,opt,name=mount_point,json=mountPoint,proto3" json:"mount_point,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` + MountPoint *v1beta1.Reference `protobuf:"bytes,3,opt,name=mount_point,json=mountPoint,proto3" json:"mount_point,omitempty"` + // Optional. + // Hide share, default false + Hidden bool `protobuf:"varint,4,opt,name=hidden,proto3" json:"hidden,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` } func (m *ReceivedShare) Reset() { *m = ReceivedShare{} } @@ -356,6 +349,13 @@ func (m *ReceivedShare) GetMountPoint() *v1beta1.Reference { return nil } +func (m *ReceivedShare) GetHidden() bool { + if m != nil { + return m.Hidden + } + return false +} + // Uniquely identifies a share in the share provider. // A share MUST be uniquely identify by four (4) elements: // 1) The share provider id @@ -788,64 +788,64 @@ func init() { } var fileDescriptor_cb95b447da150104 = []byte{ - // 933 bytes of a gzipped FileDescriptorProto + // 934 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x96, 0x4d, 0x6f, 0xe3, 0x44, - 0x18, 0xc7, 0xe3, 0x24, 0x4e, 0xd2, 0x27, 0xbb, 0x95, 0x77, 0x28, 0xc2, 0xda, 0x05, 0x69, 0x6b, - 0x69, 0xa1, 0xbb, 0x80, 0xa3, 0x34, 0x07, 0x04, 0x2c, 0xac, 0x12, 0xc7, 0x34, 0xa6, 0x55, 0x1a, - 0x8d, 0xd3, 0xe5, 0x45, 0x95, 0x22, 0xd7, 0x1e, 0x52, 0x8b, 0xc6, 0x36, 0x63, 0xb7, 0x90, 0x33, - 0x1f, 0x82, 0x13, 0x17, 0x8e, 0xdc, 0xf8, 0x1a, 0x5c, 0xb8, 0x71, 0xe4, 0xc0, 0x27, 0x41, 0xf3, - 0xd8, 0xce, 0x9b, 0xb4, 0x5b, 0xb7, 0xe5, 0xe6, 0x99, 0xf9, 0xff, 0x9e, 0x79, 0xe6, 0x79, 0x93, - 0xa1, 0xed, 0xc6, 0x9d, 0x56, 0x7c, 0xee, 0x70, 0x3f, 0x98, 0xb6, 0xdc, 0xf0, 0xe2, 0xc2, 0x39, - 0x0b, 0xb9, 0x93, 0xf8, 0x61, 0xd0, 0xba, 0x6a, 0x9f, 0xb1, 0xc4, 0x69, 0xb7, 0x38, 0x8b, 0xc3, - 0x4b, 0xee, 0xb2, 0x58, 0x8f, 0x78, 0x98, 0x84, 0x64, 0xd7, 0x8d, 0x3b, 0x7a, 0x86, 0xe8, 0x6b, - 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x2f, 0xe9, 0x1a, 0x19, 0x62, + 0xac, 0x21, 0x46, 0x86, 0x3c, 0x78, 0x2c, 0xac, 0x06, 0x3e, 0x0b, 0xd3, 0x20, 0x5d, 0xb4, 0x2f, + 0x12, 0xc6, 0x5f, 0x64, 0xed, 0xc1, 0x07, 0xe8, 0x40, 0x1a, 0x71, 0x77, 0xc6, 0xda, 0x31, 0x8f, + 0x2e, 0x03, 0xff, 0x25, 0xea, 0xb7, 0x85, 0x3a, 0x5d, 0xc4, 0x2c, 0x59, 0x4a, 0x70, 0x25, 0x8f, + 0x5b, 0x7f, 0x56, 0x41, 0x75, 0xce, 0x5c, 0xce, 0xc8, 0x27, 0x50, 0x0e, 0x7c, 0x5d, 0x79, 0x47, + 0xd9, 0x6d, 0xee, 0x3d, 0x31, 0xae, 0xf5, 0xd8, 0x40, 0xca, 0xf6, 0x69, 0x39, 0xf0, 0x89, 0x0d, + 0xcd, 0xfc, 0xde, 0x69, 0xe0, 0xeb, 0x65, 0x34, 0xb2, 0x2b, 0x8d, 0x48, 0x47, 0x8d, 0xdc, 0xd1, + 0x25, 0x4f, 0x33, 0xc0, 0xf6, 0x29, 0xf0, 0xe5, 0x37, 0x39, 0x86, 0x66, 0xcc, 0xf8, 0x3c, 0x48, + 0x92, 0x20, 0x0a, 0x13, 0xbd, 0x82, 0xa6, 0xba, 0x45, 0xfd, 0x19, 0x5f, 0xa1, 0x74, 0xd5, 0x0e, + 0x79, 0x06, 0xf5, 0x19, 0x77, 0xc3, 0x94, 0x31, 0xbd, 0x8a, 0x26, 0x1f, 0xbd, 0xdc, 0xbb, 0x7d, + 0x29, 0xa6, 0x39, 0x45, 0x3e, 0x02, 0x35, 0xfa, 0x31, 0x64, 0x5c, 0x57, 0x11, 0xdf, 0x41, 0x3c, + 0x4f, 0x98, 0x21, 0x12, 0xb6, 0x64, 0x8f, 0x13, 0xc6, 0x6d, 0x9f, 0x4a, 0x3d, 0xf9, 0x14, 0xea, + 0x1e, 0x67, 0x6e, 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d, 0xc6, 0xe2, 0x9f, 0x6a, 0xac, 0x7c, 0x7b, 0x7f, 0x4d, + 0x98, 0xe9, 0x7e, 0x2b, 0x57, 0x4c, 0xc7, 0xfc, 0xbd, 0xbc, 0x63, 0x26, 0x5d, 0xcc, 0x90, 0xb0, + 0x68, 0xae, 0x59, 0x7c, 0xde, 0xe9, 0x0b, 0xe5, 0x5f, 0xa8, 0x39, 0xc9, 0x34, 0x27, 0x6b, 0x9a, + 0x93, 0x4c, 0x73, 0x5a, 0xc3, 0x1f, 0xb8, 0xee, 0x7f, 0x01, 0x00, 0x00, 0xff, 0xff, 0x41, 0x35, + 0x12, 0xf0, 0x90, 0x0a, 0x00, 0x00, } diff --git a/vendor/github.com/cs3org/reva/v2/internal/http/services/owncloud/ocs/handlers/apps/sharing/shares/pending.go b/vendor/github.com/cs3org/reva/v2/internal/http/services/owncloud/ocs/handlers/apps/sharing/shares/pending.go index 237b23d59..b5fdf23c3 100644 --- a/vendor/github.com/cs3org/reva/v2/internal/http/services/owncloud/ocs/handlers/apps/sharing/shares/pending.go +++ b/vendor/github.com/cs3org/reva/v2/internal/http/services/owncloud/ocs/handlers/apps/sharing/shares/pending.go @@ -122,9 +122,20 @@ func (h *Handler) AcceptReceivedShare(w http.ResponseWriter, r *http.Request) { // TODO we could delete shares here if the stat returns code NOT FOUND ... but listening for file deletes would be better } } + // we need to add a path to the share + receivedShare := &collaboration.ReceivedShare{ + Share: &collaboration.Share{ + Id: &collaboration.ShareId{OpaqueId: shareID}, + }, + State: collaboration.ShareState_SHARE_STATE_ACCEPTED, + MountPoint: &provider.Reference{ + Path: mount, + }, + } + updateMask := &fieldmaskpb.FieldMask{Paths: []string{"state", "hidden", "mount_point"}} for id := range sharesToAccept { - data := h.updateReceivedShare(w, r, id, false, mount) + data := h.updateReceivedShare(w, r, receivedShare, updateMask) // only render the data for the changed share if id == shareID && data != nil { response.WriteOCSSuccess(w, r, []*conversions.ShareData{data}) @@ -135,45 +146,69 @@ func (h *Handler) AcceptReceivedShare(w http.ResponseWriter, r *http.Request) { // RejectReceivedShare handles DELETE Requests on /apps/files_sharing/api/v1/shares/{shareid} func (h *Handler) RejectReceivedShare(w http.ResponseWriter, r *http.Request) { shareID := chi.URLParam(r, "shareid") - data := h.updateReceivedShare(w, r, shareID, true, "") + // we need to add a path to the share + receivedShare := &collaboration.ReceivedShare{ + Share: &collaboration.Share{ + Id: &collaboration.ShareId{OpaqueId: shareID}, + }, + State: collaboration.ShareState_SHARE_STATE_REJECTED, + } + updateMask := &fieldmaskpb.FieldMask{Paths: []string{"state", "hidden"}} + + data := h.updateReceivedShare(w, r, receivedShare, updateMask) if data != nil { response.WriteOCSSuccess(w, r, []*conversions.ShareData{data}) } } -func (h *Handler) updateReceivedShare(w http.ResponseWriter, r *http.Request, shareID string, rejectShare bool, mountPoint string) *conversions.ShareData { +func (h *Handler) UpdateReceivedShare(w http.ResponseWriter, r *http.Request) { + shareID := chi.URLParam(r, "shareid") + hideFlag, _ := strconv.ParseBool(r.URL.Query().Get("hidden")) + + // unfortunately we need to get the share first to read the state + client, err := h.getClient() + if err != nil { + response.WriteOCSError(w, r, response.MetaServerError.StatusCode, "error getting grpc gateway client", err) + return + } + + // we need to add a path to the share + receivedShare := &collaboration.ReceivedShare{ + Share: &collaboration.Share{ + Id: &collaboration.ShareId{OpaqueId: shareID}, + }, + Hidden: hideFlag, + } + updateMask := &fieldmaskpb.FieldMask{Paths: []string{"state", "hidden"}} + + rs, _ := getReceivedShareFromID(r.Context(), client, shareID) + if rs != nil && rs.Share != nil { + receivedShare.State = rs.Share.State + } + + data := h.updateReceivedShare(w, r, receivedShare, updateMask) + if data != nil { + response.WriteOCSSuccess(w, r, []*conversions.ShareData{data}) + } + // TODO: do we need error handling here? +} + +func (h *Handler) updateReceivedShare(w http.ResponseWriter, r *http.Request, receivedShare *collaboration.ReceivedShare, fieldMask *fieldmaskpb.FieldMask) *conversions.ShareData { ctx := r.Context() logger := appctx.GetLogger(ctx) + updateShareRequest := &collaboration.UpdateReceivedShareRequest{ + Share: receivedShare, + UpdateMask: fieldMask, + } + client, err := h.getClient() if err != nil { response.WriteOCSError(w, r, response.MetaServerError.StatusCode, "error getting grpc gateway client", err) return nil } - hideFlag, _ := strconv.ParseBool(r.URL.Query().Get("hide")) - - // we need to add a path to the share - shareRequest := &collaboration.UpdateReceivedShareRequest{ - Share: &collaboration.ReceivedShare{ - Share: &collaboration.Share{ - Id: &collaboration.ShareId{OpaqueId: shareID}, - Hide: hideFlag, - }, - MountPoint: &provider.Reference{ - Path: mountPoint, - }, - }, - UpdateMask: &fieldmaskpb.FieldMask{Paths: []string{"state", "hide"}}, - } - if rejectShare { - shareRequest.Share.State = collaboration.ShareState_SHARE_STATE_REJECTED - } else { - shareRequest.UpdateMask.Paths = append(shareRequest.UpdateMask.Paths, "mount_point") - shareRequest.Share.State = collaboration.ShareState_SHARE_STATE_ACCEPTED - } - - shareRes, err := client.UpdateReceivedShare(ctx, shareRequest) + shareRes, err := client.UpdateReceivedShare(ctx, updateShareRequest) if err != nil { response.WriteOCSError(w, r, response.MetaServerError.StatusCode, "grpc update received share request failed", err) return nil @@ -203,6 +238,7 @@ func (h *Handler) updateReceivedShare(w http.ResponseWriter, r *http.Request, sh } data.State = mapState(rs.GetState()) + data.Hidden = rs.Hidden h.addFileInfo(ctx, data, info) h.mapUserIds(r.Context(), client, data) diff --git a/vendor/github.com/cs3org/reva/v2/internal/http/services/owncloud/ocs/handlers/apps/sharing/shares/shares.go b/vendor/github.com/cs3org/reva/v2/internal/http/services/owncloud/ocs/handlers/apps/sharing/shares/shares.go index 5b6c28816..03350ad62 100644 --- a/vendor/github.com/cs3org/reva/v2/internal/http/services/owncloud/ocs/handlers/apps/sharing/shares/shares.go +++ b/vendor/github.com/cs3org/reva/v2/internal/http/services/owncloud/ocs/handlers/apps/sharing/shares/shares.go @@ -580,9 +580,9 @@ func (h *Handler) GetShare(w http.ResponseWriter, r *http.Request) { }, }) if err == nil && uRes.GetShare() != nil { - receivedshare = uRes.Share resourceID = uRes.Share.Share.ResourceId share, err = conversions.CS3Share2ShareData(ctx, uRes.Share.Share) + share.Hidden = uRes.Share.Hidden if err != nil { response.WriteOCSError(w, r, response.MetaServerError.StatusCode, "error mapping share data", err) return @@ -739,7 +739,7 @@ func (h *Handler) updateShare(w http.ResponseWriter, r *http.Request, share *col share.Permissions = &collaboration.SharePermissions{Permissions: role.CS3ResourcePermissions()} - var fieldMaskPaths = []string{"permissions", "hide"} + var fieldMaskPaths = []string{"permissions"} expireDate := r.PostFormValue("expireDate") var expirationTs *types.Timestamp @@ -958,7 +958,7 @@ func (h *Handler) listSharesWithMe(w http.ResponseWriter, r *http.Request) { // TODO(refs) filter out "invalid" shares for _, rs := range lrsRes.GetShares() { - if rs.Share.Hide && !showHidden { + if rs.Hidden && !showHidden { continue } if stateFilter != ocsStateUnknown && rs.GetState() != stateFilter { diff --git a/vendor/github.com/cs3org/reva/v2/internal/http/services/owncloud/ocs/ocs.go b/vendor/github.com/cs3org/reva/v2/internal/http/services/owncloud/ocs/ocs.go index 09fcfa02d..2982e4dfa 100644 --- a/vendor/github.com/cs3org/reva/v2/internal/http/services/owncloud/ocs/ocs.go +++ b/vendor/github.com/cs3org/reva/v2/internal/http/services/owncloud/ocs/ocs.go @@ -122,6 +122,7 @@ func (s *svc) routerInit(log *zerolog.Logger) error { r.Route("/pending/{shareid}", func(r chi.Router) { r.Post("/", sharesHandler.AcceptReceivedShare) r.Delete("/", sharesHandler.RejectReceivedShare) + r.Put("/", sharesHandler.UpdateReceivedShare) }) r.Route("/remote_shares", func(r chi.Router) { r.Get("/", sharesHandler.ListFederatedShares) diff --git a/vendor/github.com/cs3org/reva/v2/pkg/conversions/main.go b/vendor/github.com/cs3org/reva/v2/pkg/conversions/main.go index 509068c74..755faa64a 100644 --- a/vendor/github.com/cs3org/reva/v2/pkg/conversions/main.go +++ b/vendor/github.com/cs3org/reva/v2/pkg/conversions/main.go @@ -172,7 +172,7 @@ type ShareData struct { Quicklink bool `json:"quicklink,omitempty" xml:"quicklink,omitempty"` // PasswordProtected represents a public share is password protected // PasswordProtected bool `json:"password_protected,omitempty" xml:"password_protected,omitempty"` - Hide bool `json:"hide" xml:"hide"` + Hidden bool `json:"hidden" xml:"hidden"` } // ShareeData holds share recipient search results @@ -233,7 +233,6 @@ func CS3Share2ShareData(ctx context.Context, share *collaboration.Share) (*Share // Displaynames are added later UIDOwner: LocalUserIDToString(share.GetCreator()), UIDFileOwner: LocalUserIDToString(share.GetOwner()), - Hide: share.Hide, } if share.Grantee.Type == provider.GranteeType_GRANTEE_TYPE_USER { diff --git a/vendor/github.com/cs3org/reva/v2/pkg/ocm/share/repository/json/json.go b/vendor/github.com/cs3org/reva/v2/pkg/ocm/share/repository/json/json.go index bb7d8b23e..8e3251772 100644 --- a/vendor/github.com/cs3org/reva/v2/pkg/ocm/share/repository/json/json.go +++ b/vendor/github.com/cs3org/reva/v2/pkg/ocm/share/repository/json/json.go @@ -23,6 +23,7 @@ import ( "encoding/json" "io" "os" + "path/filepath" "sync" "time" @@ -69,6 +70,9 @@ func New(m map[string]interface{}) (share.Repository, error) { func loadOrCreate(file string) (*shareModel, error) { _, err := os.Stat(file) if os.IsNotExist(err) { + if err := os.MkdirAll(filepath.Dir(file), 0700); err != nil { + return nil, errors.Wrap(err, "error creating the base directory: "+filepath.Dir(file)) + } if err := os.WriteFile(file, []byte("{}"), 0700); err != nil { return nil, errors.Wrap(err, "error creating the file: "+file) } diff --git a/vendor/github.com/cs3org/reva/v2/pkg/share/manager/cs3/cs3.go b/vendor/github.com/cs3org/reva/v2/pkg/share/manager/cs3/cs3.go index 35095ca06..a22693f32 100644 --- a/vendor/github.com/cs3org/reva/v2/pkg/share/manager/cs3/cs3.go +++ b/vendor/github.com/cs3org/reva/v2/pkg/share/manager/cs3/cs3.go @@ -647,7 +647,7 @@ func (m *Manager) UpdateReceivedShare(ctx context.Context, rshare *collaboration rs.State = rshare.State case "mount_point": rs.MountPoint = rshare.MountPoint - case "hide": + case "hidden": continue default: return nil, errtypes.NotSupported("updating " + fieldMask.Paths[i] + " is not supported") diff --git a/vendor/github.com/cs3org/reva/v2/pkg/share/manager/json/json.go b/vendor/github.com/cs3org/reva/v2/pkg/share/manager/json/json.go index 68f39f137..19b394052 100644 --- a/vendor/github.com/cs3org/reva/v2/pkg/share/manager/json/json.go +++ b/vendor/github.com/cs3org/reva/v2/pkg/share/manager/json/json.go @@ -403,7 +403,7 @@ func (m *mgr) UpdateShare(ctx context.Context, ref *collaboration.ShareReference m.model.Shares[idx].Permissions = updated.Permissions case "expiration": m.model.Shares[idx].Expiration = updated.Expiration - case "hide": + case "hidden": continue default: return nil, errtypes.NotSupported("updating " + fieldMask.Paths[i] + " is not supported") diff --git a/vendor/github.com/cs3org/reva/v2/pkg/share/manager/jsoncs3/jsoncs3.go b/vendor/github.com/cs3org/reva/v2/pkg/share/manager/jsoncs3/jsoncs3.go index 3a70d1866..220c34b3f 100644 --- a/vendor/github.com/cs3org/reva/v2/pkg/share/manager/jsoncs3/jsoncs3.go +++ b/vendor/github.com/cs3org/reva/v2/pkg/share/manager/jsoncs3/jsoncs3.go @@ -511,8 +511,6 @@ func (m *Manager) UpdateShare(ctx context.Context, ref *collaboration.ShareRefer toUpdate.Permissions = updated.Permissions case "expiration": toUpdate.Expiration = updated.Expiration - case "hide": - toUpdate.Hide = updated.Hide default: return nil, errtypes.NotSupported("updating " + fieldMask.Paths[i] + " is not supported") } @@ -886,11 +884,11 @@ func (m *Manager) ListReceivedShares(ctx context.Context, filters []*collaborati if share.IsGrantedToUser(s, user) { if share.MatchesFiltersWithState(s, state.State, filters) { - s.Hide = state.Hide rs := &collaboration.ReceivedShare{ Share: s, State: state.State, MountPoint: state.MountPoint, + Hidden: state.Hidden, } select { case results <- rs: @@ -942,7 +940,7 @@ func (m *Manager) convert(ctx context.Context, userID string, s *collaboration.S if err == nil && state != nil { rs.State = state.State rs.MountPoint = state.MountPoint - rs.Share.Hide = state.Hide + rs.Hidden = state.Hidden } return rs } @@ -1007,8 +1005,8 @@ func (m *Manager) UpdateReceivedShare(ctx context.Context, receivedShare *collab rs.State = receivedShare.State case "mount_point": rs.MountPoint = receivedShare.MountPoint - case "hide": - rs.Share.Hide = receivedShare.Share.Hide + case "hidden": + rs.Hidden = receivedShare.Hidden default: return nil, errtypes.NotSupported("updating " + fieldMask.Paths[i] + " is not supported") } diff --git a/vendor/github.com/cs3org/reva/v2/pkg/share/manager/jsoncs3/receivedsharecache/receivedsharecache.go b/vendor/github.com/cs3org/reva/v2/pkg/share/manager/jsoncs3/receivedsharecache/receivedsharecache.go index fe84f40d7..65111e7e7 100644 --- a/vendor/github.com/cs3org/reva/v2/pkg/share/manager/jsoncs3/receivedsharecache/receivedsharecache.go +++ b/vendor/github.com/cs3org/reva/v2/pkg/share/manager/jsoncs3/receivedsharecache/receivedsharecache.go @@ -68,7 +68,7 @@ type Space struct { type State struct { State collaboration.ShareState MountPoint *provider.Reference - Hide bool + Hidden bool } // New returns a new Cache instance @@ -118,7 +118,7 @@ func (c *Cache) Add(ctx context.Context, userID, spaceID string, rs *collaborati receivedSpace.States[rs.Share.Id.GetOpaqueId()] = &State{ State: rs.State, MountPoint: rs.MountPoint, - Hide: rs.Share.Hide, + Hidden: rs.Hidden, } return c.persist(ctx, userID) @@ -200,7 +200,7 @@ func (c *Cache) List(ctx context.Context, userID string) (map[string]*Space, err spaceCopy.States[shareID] = &State{ State: state.State, MountPoint: state.MountPoint, - Hide: state.Hide, + Hidden: state.Hidden, } } spaces[spaceID] = spaceCopy diff --git a/vendor/github.com/cs3org/reva/v2/pkg/share/manager/memory/memory.go b/vendor/github.com/cs3org/reva/v2/pkg/share/manager/memory/memory.go index d2d80f543..e321db730 100644 --- a/vendor/github.com/cs3org/reva/v2/pkg/share/manager/memory/memory.go +++ b/vendor/github.com/cs3org/reva/v2/pkg/share/manager/memory/memory.go @@ -243,8 +243,6 @@ func (m *manager) UpdateShare(ctx context.Context, ref *collaboration.ShareRefer m.shares[i].Permissions = updated.Permissions case "expiration": m.shares[i].Expiration = updated.Expiration - case "hide": - m.shares[i].Hide = updated.Hide default: return nil, errtypes.NotSupported("updating " + path + " is not supported") } @@ -366,7 +364,7 @@ func (m *manager) UpdateReceivedShare(ctx context.Context, receivedShare *collab rs.State = receivedShare.State case "mount_point": rs.MountPoint = receivedShare.MountPoint - case "hide": + case "hidden": continue default: return nil, errtypes.NotSupported("updating " + fieldMask.Paths[i] + " is not supported") diff --git a/vendor/github.com/cs3org/reva/v2/pkg/share/manager/owncloudsql/owncloudsql.go b/vendor/github.com/cs3org/reva/v2/pkg/share/manager/owncloudsql/owncloudsql.go index c162967ed..efdef7738 100644 --- a/vendor/github.com/cs3org/reva/v2/pkg/share/manager/owncloudsql/owncloudsql.go +++ b/vendor/github.com/cs3org/reva/v2/pkg/share/manager/owncloudsql/owncloudsql.go @@ -454,7 +454,7 @@ func (m *mgr) UpdateReceivedShare(ctx context.Context, receivedShare *collaborat fields = append(fields, "file_target=?") rs.MountPoint = receivedShare.MountPoint params = append(params, rs.MountPoint.Path) - case "hide": + case "hidden": continue default: return nil, errtypes.NotSupported("updating " + fieldMask.Paths[i] + " is not supported") diff --git a/vendor/modules.txt b/vendor/modules.txt index c38044075..b6b0f018b 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -334,7 +334,7 @@ github.com/crewjam/saml github.com/crewjam/saml/logger github.com/crewjam/saml/samlsp github.com/crewjam/saml/xmlenc -# github.com/cs3org/go-cs3apis v0.0.0-20230727093620-0f4399be4543 => github.com/aduffeck/go-cs3apis v0.0.0-20231009082215-ad45e19edac0 +# github.com/cs3org/go-cs3apis v0.0.0-20231023073225-7748710e0781 ## explicit; go 1.13 github.com/cs3org/go-cs3apis/cs3/app/provider/v1beta1 github.com/cs3org/go-cs3apis/cs3/app/registry/v1beta1 @@ -357,7 +357,7 @@ github.com/cs3org/go-cs3apis/cs3/storage/provider/v1beta1 github.com/cs3org/go-cs3apis/cs3/storage/registry/v1beta1 github.com/cs3org/go-cs3apis/cs3/tx/v1beta1 github.com/cs3org/go-cs3apis/cs3/types/v1beta1 -# github.com/cs3org/reva/v2 v2.16.1-0.20231023124625-f9a66375fd79 +# github.com/cs3org/reva/v2 v2.16.1-0.20231024092538-194fbe4a2c31 ## explicit; go 1.20 github.com/cs3org/reva/v2/cmd/revad/internal/grace github.com/cs3org/reva/v2/cmd/revad/runtime @@ -2255,4 +2255,3 @@ stash.kopano.io/kgol/oidc-go # stash.kopano.io/kgol/rndm v1.1.2 ## explicit; go 1.13 stash.kopano.io/kgol/rndm -# github.com/cs3org/go-cs3apis => github.com/aduffeck/go-cs3apis v0.0.0-20231009082215-ad45e19edac0