Skip to content
This repository has been archived by the owner on Jan 18, 2021. It is now read-only.

Public Links #133

Closed
wants to merge 20 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 3 additions & 13 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,16 @@ module github.com/owncloud/ocis-reva
go 1.13

require (
github.com/cespare/xxhash/v2 v2.1.1 // indirect
github.com/cs3org/reva v0.1.1-0.20200520150229-ce94fda7436f
github.com/cs3org/reva v0.1.1-0.20200528123359-7d74bf8e9928
github.com/gofrs/uuid v3.3.0+incompatible
github.com/gopherjs/gopherjs v0.0.0-20181103185306-d547d1d9531e // indirect
github.com/haya14busa/goverage v0.0.0-20180129164344-eec3514a20b5 // indirect
github.com/micro/cli/v2 v2.1.1
github.com/micro/go-micro v1.18.0
github.com/micro/go-micro/v2 v2.0.0
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e // indirect
github.com/oklog/run v1.0.0
github.com/owncloud/flaex v0.0.0-20200411150708-dce59891a203
github.com/owncloud/ocis-pkg/v2 v2.2.1
github.com/pelletier/go-toml v1.6.0 // indirect
github.com/prometheus/client_model v0.0.0-20191202183732-d1d2010b5bee // indirect
github.com/prometheus/procfs v0.0.8 // indirect
github.com/owncloud/ocis-pkg/v2 v2.0.1
github.com/restic/calens v0.2.0
github.com/spf13/afero v1.2.2 // indirect
github.com/spf13/cast v1.3.1 // indirect
github.com/spf13/jwalterweatherman v1.1.0 // indirect
github.com/spf13/viper v1.6.1
github.com/uber/jaeger-client-go v2.20.1+incompatible // indirect
golang.org/x/sys v0.0.0-20200103143344-a1369afcdac7 // indirect
gopkg.in/ini.v1 v1.51.1 // indirect
)
546 changes: 421 additions & 125 deletions go.sum

Large diffs are not rendered by default.

7 changes: 2 additions & 5 deletions pkg/command/authbasic.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,8 @@ func AuthBasic(cfg *config.Config) *cli.Command {

rcfg := map[string]interface{}{
"core": map[string]interface{}{
"max_cpus": cfg.Reva.Users.MaxCPUs,
"tracing_enabled": cfg.Tracing.Enabled,
"tracing_endpoint": cfg.Tracing.Endpoint,
"tracing_collector": cfg.Tracing.Collector,
"tracing_service_name": "auth-basic",
"max_cpus": cfg.Reva.AuthBasic.MaxCPUs,
"tracing_enabled": true,
},
"shared": map[string]interface{}{
"jwt_secret": cfg.Reva.JWTSecret,
Expand Down
7 changes: 2 additions & 5 deletions pkg/command/authbearer.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,8 @@ func AuthBearer(cfg *config.Config) *cli.Command {

rcfg := map[string]interface{}{
"core": map[string]interface{}{
"max_cpus": cfg.Reva.Users.MaxCPUs,
"tracing_enabled": cfg.Tracing.Enabled,
"tracing_endpoint": cfg.Tracing.Endpoint,
"tracing_collector": cfg.Tracing.Collector,
"tracing_service_name": "auth-bearer",
"max_cpus": cfg.Reva.AuthBearer.MaxCPUs,
"tracing_enabled": true,
},
"shared": map[string]interface{}{
"jwt_secret": cfg.Reva.JWTSecret,
Expand Down
9 changes: 3 additions & 6 deletions pkg/command/frontend.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,8 @@ func Frontend(cfg *config.Config) *cli.Command {

rcfg := map[string]interface{}{
"core": map[string]interface{}{
"max_cpus": cfg.Reva.Users.MaxCPUs,
"tracing_enabled": cfg.Tracing.Enabled,
"tracing_endpoint": cfg.Tracing.Endpoint,
"tracing_collector": cfg.Tracing.Collector,
"tracing_service_name": "frontend",
"max_cpus": cfg.Reva.Frontend.MaxCPUs,
"tracing_enabled": true,
},
"shared": map[string]interface{}{
"jwt_secret": cfg.Reva.JWTSecret,
Expand Down Expand Up @@ -186,7 +183,7 @@ func Frontend(cfg *config.Config) *cli.Command {
},
},
"notifications": map[string]interface{}{
"endpoints": []string{"list", "get", "delete"},
"endpoints": []string{"disable"},
},
},
"version": map[string]interface{}{
Expand Down
36 changes: 18 additions & 18 deletions pkg/command/gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,8 @@ func Gateway(cfg *config.Config) *cli.Command {

rcfg := map[string]interface{}{
"core": map[string]interface{}{
"max_cpus": cfg.Reva.Users.MaxCPUs,
"tracing_enabled": cfg.Tracing.Enabled,
"tracing_endpoint": cfg.Tracing.Endpoint,
"tracing_collector": cfg.Tracing.Collector,
"tracing_service_name": "gateway",
"max_cpus": cfg.Reva.Gateway.MaxCPUs,
"tracing_enabled": true,
},
"shared": map[string]interface{}{
"jwt_secret": cfg.Reva.JWTSecret,
Expand Down Expand Up @@ -115,8 +112,9 @@ func Gateway(cfg *config.Config) *cli.Command {
"drivers": map[string]interface{}{
"static": map[string]interface{}{
"rules": map[string]interface{}{
"basic": cfg.Reva.AuthBasic.URL,
"bearer": cfg.Reva.AuthBearer.URL,
"basic": cfg.Reva.AuthBasic.URL,
"bearer": cfg.Reva.AuthBearer.URL,
"publicshares": "localhost:10054",
},
},
},
Expand All @@ -130,17 +128,19 @@ func Gateway(cfg *config.Config) *cli.Command {
cfg.Reva.StorageRoot.MountPath: cfg.Reva.StorageRoot.URL,
cfg.Reva.StorageRoot.MountID: cfg.Reva.StorageRoot.URL,
cfg.Reva.StorageHome.MountPath: cfg.Reva.StorageHome.URL,
// the home storage has no mount id. In responses it returns the mount id of the actual storage
cfg.Reva.StorageEOS.MountPath: cfg.Reva.StorageEOS.URL,
cfg.Reva.StorageEOS.MountID: cfg.Reva.StorageEOS.URL,
cfg.Reva.StorageOC.MountPath: cfg.Reva.StorageOC.URL,
cfg.Reva.StorageOC.MountID: cfg.Reva.StorageOC.URL,
cfg.Reva.StorageS3.MountPath: cfg.Reva.StorageS3.URL,
cfg.Reva.StorageS3.MountID: cfg.Reva.StorageS3.URL,
cfg.Reva.StorageWND.MountPath: cfg.Reva.StorageWND.URL,
cfg.Reva.StorageWND.MountID: cfg.Reva.StorageWND.URL,
cfg.Reva.StorageCustom.MountPath: cfg.Reva.StorageCustom.URL,
cfg.Reva.StorageCustom.MountID: cfg.Reva.StorageCustom.URL,
// home has no lookup by mount id because it resolves to another storage
cfg.Reva.StorageEOS.MountPath: cfg.Reva.StorageEOS.URL,
cfg.Reva.StorageEOS.MountID: cfg.Reva.StorageEOS.URL,
cfg.Reva.StorageOC.MountPath: cfg.Reva.StorageOC.URL,
"/public/": "localhost:10054",
"e1a73ede-549b-4226-abdf-40e69ca8230d": "localhost:10054",
cfg.Reva.StorageOC.MountID: cfg.Reva.StorageOC.URL,
cfg.Reva.StorageS3.MountPath: cfg.Reva.StorageS3.URL,
cfg.Reva.StorageS3.MountID: cfg.Reva.StorageS3.URL,
cfg.Reva.StorageWND.MountPath: cfg.Reva.StorageWND.URL,
cfg.Reva.StorageWND.MountID: cfg.Reva.StorageWND.URL,
cfg.Reva.StorageCustom.MountPath: cfg.Reva.StorageCustom.URL,
cfg.Reva.StorageCustom.MountID: cfg.Reva.StorageCustom.URL,
},
},
},
Expand Down
1 change: 1 addition & 0 deletions pkg/command/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ func Execute() error {
StorageRoot(cfg),
StorageHome(cfg),
StorageHomeData(cfg),
StoragePublicLink(cfg),
StorageOC(cfg),
StorageOCData(cfg),
StorageEOS(cfg),
Expand Down
7 changes: 2 additions & 5 deletions pkg/command/sharing.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,8 @@ func Sharing(cfg *config.Config) *cli.Command {

rcfg := map[string]interface{}{
"core": map[string]interface{}{
"max_cpus": cfg.Reva.Users.MaxCPUs,
"tracing_enabled": cfg.Tracing.Enabled,
"tracing_endpoint": cfg.Tracing.Endpoint,
"tracing_collector": cfg.Tracing.Collector,
"tracing_service_name": "sharing",
"max_cpus": cfg.Reva.Sharing.MaxCPUs,
"tracing_enabled": true,
},
"shared": map[string]interface{}{
"jwt_secret": cfg.Reva.JWTSecret,
Expand Down
7 changes: 2 additions & 5 deletions pkg/command/storagehome.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,8 @@ func StorageHome(cfg *config.Config) *cli.Command {

rcfg := map[string]interface{}{
"core": map[string]interface{}{
"max_cpus": cfg.Reva.Users.MaxCPUs,
"tracing_enabled": cfg.Tracing.Enabled,
"tracing_endpoint": cfg.Tracing.Endpoint,
"tracing_collector": cfg.Tracing.Collector,
"tracing_service_name": "storage-home",
"max_cpus": cfg.Reva.StorageHome.MaxCPUs,
"tracing_enabled": true,
},
"shared": map[string]interface{}{
"jwt_secret": cfg.Reva.JWTSecret,
Expand Down
7 changes: 2 additions & 5 deletions pkg/command/storagehomedata.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,8 @@ func StorageHomeData(cfg *config.Config) *cli.Command {

rcfg := map[string]interface{}{
"core": map[string]interface{}{
"max_cpus": cfg.Reva.Users.MaxCPUs,
"tracing_enabled": cfg.Tracing.Enabled,
"tracing_endpoint": cfg.Tracing.Endpoint,
"tracing_collector": cfg.Tracing.Collector,
"tracing_service_name": "storage-home-data",
"max_cpus": cfg.Reva.StorageHomeData.MaxCPUs,
"tracing_enabled": true,
},
"shared": map[string]interface{}{
"jwt_secret": cfg.Reva.JWTSecret,
Expand Down
7 changes: 2 additions & 5 deletions pkg/command/storageoc.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,8 @@ func StorageOC(cfg *config.Config) *cli.Command {

rcfg := map[string]interface{}{
"core": map[string]interface{}{
"max_cpus": cfg.Reva.StorageOC.MaxCPUs,
"tracing_enabled": cfg.Tracing.Enabled,
"tracing_endpoint": cfg.Tracing.Endpoint,
"tracing_collector": cfg.Tracing.Collector,
"tracing_service_name": "storage-oc",
"max_cpus": cfg.Reva.StorageOC.MaxCPUs,
"tracing_enabled": true,
},
"shared": map[string]interface{}{
"jwt_secret": cfg.Reva.JWTSecret,
Expand Down
7 changes: 2 additions & 5 deletions pkg/command/storageocdata.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,8 @@ func StorageOCData(cfg *config.Config) *cli.Command {

rcfg := map[string]interface{}{
"core": map[string]interface{}{
"max_cpus": cfg.Reva.StorageOCData.MaxCPUs,
"tracing_enabled": cfg.Tracing.Enabled,
"tracing_endpoint": cfg.Tracing.Endpoint,
"tracing_collector": cfg.Tracing.Collector,
"tracing_service_name": "storage-oc-data",
"max_cpus": cfg.Reva.StorageOCData.MaxCPUs,
"tracing_enabled": true,
},
"shared": map[string]interface{}{
"jwt_secret": cfg.Reva.JWTSecret,
Expand Down
175 changes: 175 additions & 0 deletions pkg/command/storagepubliclink.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,175 @@
package command

import (
"context"
"os"
"os/signal"
"path"
"time"

"github.com/cs3org/reva/cmd/revad/runtime"
"github.com/gofrs/uuid"
"github.com/micro/cli/v2"
"github.com/oklog/run"
"github.com/owncloud/ocis-reva/pkg/config"
"github.com/owncloud/ocis-reva/pkg/flagset"
"github.com/owncloud/ocis-reva/pkg/server/debug"
)

// StoragePublicLink is the entrypoint for the reva-storage-public-link command.
func StoragePublicLink(cfg *config.Config) *cli.Command {
return &cli.Command{
Name: "reva-storage-public-link",
Usage: "Start reva storage-public-link service",
Flags: flagset.StoragePublicLink(cfg),
Category: "Extensions",
Action: func(c *cli.Context) error {
logger := NewLogger(cfg)

if cfg.Tracing.Enabled {
switch t := cfg.Tracing.Type; t {
case "agent":
logger.Error().
Str("type", t).
Msg("Reva only supports the jaeger tracing backend")

case "jaeger":
logger.Info().
Str("type", t).
Msg("configuring reva to use the jaeger tracing backend")

case "zipkin":
logger.Error().
Str("type", t).
Msg("Reva only supports the jaeger tracing backend")

default:
logger.Warn().
Str("type", t).
Msg("Unknown tracing backend")
}

} else {
logger.Debug().
Msg("Tracing is not enabled")
}

var (
gr = run.Group{}
ctx, cancel = context.WithCancel(context.Background())
//metrics = metrics.New()
)

defer cancel()

{
uuid := uuid.Must(uuid.NewV4())
pidFile := path.Join(os.TempDir(), "revad-"+c.Command.Name+"-"+uuid.String()+".pid")

rcfg := map[string]interface{}{
"core": map[string]interface{}{
"max_cpus": cfg.Reva.StoragePublicLink.MaxCPUs,
"tracing_enabled": true,
},
"shared": map[string]interface{}{
"jwt_secret": cfg.Reva.JWTSecret,
},
"grpc": map[string]interface{}{
"network": cfg.Reva.StoragePublicLink.Network,
"address": cfg.Reva.StoragePublicLink.Addr,
"interceptors": map[string]interface{}{
"log": map[string]interface{}{},
},
"services": map[string]interface{}{
"publicstorageprovider": map[string]interface{}{
"mount_path": "/public/", // localhost:[ocdavport]/remote.php/dav/public-files/{token}/folderA/folderB/files.txt
"mount_id": "e1a73ede-549b-4226-abdf-40e69ca8230d",
"public_share_provider_addr": cfg.Reva.StoragePublicLink.PublicShareProviderAddr,
"storage_provider_addr": cfg.Reva.StoragePublicLink.StorageProviderAddr,
},
"authprovider": map[string]interface{}{
"auth_manager": "publicshares",
"auth_managers": map[string]interface{}{
"publicshares": map[string]interface{}{
"gateway_addr": "localhost:9142",
refs marked this conversation as resolved.
Show resolved Hide resolved
},
},
},
},
},
}

gr.Add(func() error {
runtime.RunWithOptions(
rcfg,
pidFile,
runtime.WithLogger(&logger.Logger),
)
return nil
}, func(_ error) {
logger.Info().
Str("server", c.Command.Name).
Msg("Shutting down server")

cancel()
})
}

{
server, err := debug.Server(
debug.Name(c.Command.Name+"-debug"),
debug.Addr(cfg.Reva.StoragePublicLink.DebugAddr),
debug.Logger(logger),
debug.Context(ctx),
debug.Config(cfg),
)

if err != nil {
logger.Info().
Err(err).
Str("server", c.Command.Name+"-debug").
Msg("Failed to initialize server")

return err
}

gr.Add(func() error {
return server.ListenAndServe()
}, func(_ error) {
ctx, timeout := context.WithTimeout(ctx, 5*time.Second)

defer timeout()
defer cancel()

if err := server.Shutdown(ctx); err != nil {
logger.Info().
Err(err).
Str("server", c.Command.Name+"-debug").
Msg("Failed to shutdown server")
} else {
logger.Info().
Str("server", c.Command.Name+"-debug").
Msg("Shutting down server")
}
})
}

{
stop := make(chan os.Signal, 1)

gr.Add(func() error {
signal.Notify(stop, os.Interrupt)

<-stop

return nil
}, func(err error) {
close(stop)
cancel()
})
}

return gr.Run()
},
}
}
Loading