Merge branch 'master' into update-bridge-docs

This commit is contained in:
A.Unger
2021-09-29 12:09:29 +02:00
511 changed files with 12687 additions and 17566 deletions

View File

@@ -0,0 +1,160 @@
package command
import (
"context"
"flag"
"os"
"path"
"github.com/cs3org/reva/cmd/revad/runtime"
"github.com/gofrs/uuid"
"github.com/oklog/run"
ociscfg "github.com/owncloud/ocis/ocis-pkg/config"
"github.com/owncloud/ocis/ocis-pkg/sync"
"github.com/owncloud/ocis/storage/pkg/config"
"github.com/owncloud/ocis/storage/pkg/flagset"
"github.com/owncloud/ocis/storage/pkg/server/debug"
"github.com/owncloud/ocis/storage/pkg/tracing"
"github.com/thejerf/suture/v4"
"github.com/urfave/cli/v2"
)
// AppProvider is the entrypoint for the app provider command.
func AppProvider(cfg *config.Config) *cli.Command {
return &cli.Command{
Name: "app-provider",
Usage: "Start appprovider for providing apps",
Flags: flagset.AppProviderWithConfig(cfg),
Before: func(c *cli.Context) error {
cfg.Reva.AppProvider.Services = c.StringSlice("service")
return nil
},
Action: func(c *cli.Context) error {
logger := NewLogger(cfg)
tracing.Configure(cfg, logger)
gr := run.Group{}
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
uuid := uuid.Must(uuid.NewV4())
pidFile := path.Join(os.TempDir(), "revad-"+c.Command.Name+"-"+uuid.String()+".pid")
rcfg := appProviderConfigFromStruct(c, cfg)
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()
})
debugServer, err := debug.Server(
debug.Name(c.Command.Name+"-debug"),
debug.Addr(cfg.Reva.AppProvider.DebugAddr),
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.Reva.AppProvider.Supervised {
sync.Trap(&gr, cancel)
}
return gr.Run()
},
}
}
// appProviderConfigFromStruct will adapt an oCIS config struct into a reva mapstructure to start a reva service.
func appProviderConfigFromStruct(c *cli.Context, cfg *config.Config) map[string]interface{} {
rcfg := map[string]interface{}{
"core": map[string]interface{}{
"max_cpus": cfg.Reva.AppProvider.MaxCPUs,
"tracing_enabled": cfg.Tracing.Enabled,
"tracing_endpoint": cfg.Tracing.Endpoint,
"tracing_collector": cfg.Tracing.Collector,
"tracing_service_name": c.Command.Name,
},
"shared": map[string]interface{}{
"jwt_secret": cfg.Reva.JWTSecret,
},
"grpc": map[string]interface{}{
"network": cfg.Reva.AppProvider.GRPCNetwork,
"address": cfg.Reva.AppProvider.GRPCAddr,
// TODO build services dynamically
"services": map[string]interface{}{
"appprovider": map[string]interface{}{
"gatewaysvc": cfg.Reva.Gateway.Endpoint,
"app_provider_url": cfg.Reva.AppProvider.ExternalAddr,
"driver": cfg.Reva.AppProvider.Driver,
"drivers": map[string]interface{}{
"wopi": map[string]interface{}{
"app_api_key": cfg.Reva.AppProvider.WopiDriver.AppAPIKey,
"app_desktop_only": cfg.Reva.AppProvider.WopiDriver.AppDesktopOnly,
"app_icon_uri": cfg.Reva.AppProvider.WopiDriver.AppIconURI,
"app_int_url": cfg.Reva.AppProvider.WopiDriver.AppInternalURL,
"app_name": cfg.Reva.AppProvider.WopiDriver.AppName,
"app_url": cfg.Reva.AppProvider.WopiDriver.AppURL,
"insecure_connections": cfg.Reva.AppProvider.WopiDriver.Insecure,
"iop_secret": cfg.Reva.AppProvider.WopiDriver.IopSecret,
"jwt_secret": cfg.Reva.AppProvider.WopiDriver.JWTSecret,
"wopi_url": cfg.Reva.AppProvider.WopiDriver.WopiURL,
},
},
},
},
},
}
return rcfg
}
// AppProviderSutureService allows for the app-provider command to be embedded and supervised by a suture supervisor tree.
type AppProviderSutureService struct {
cfg *config.Config
}
// NewAppProvider creates a new store.AppProviderSutureService
func NewAppProvider(cfg *ociscfg.Config) suture.Service {
if cfg.Mode == 0 {
cfg.Storage.Reva.AppProvider.Supervised = true
}
return AppProviderSutureService{
cfg: cfg.Storage,
}
}
func (s AppProviderSutureService) Serve(ctx context.Context) error {
s.cfg.Reva.AppProvider.Context = ctx
f := &flag.FlagSet{}
for k := range AppProvider(s.cfg).Flags {
if err := AppProvider(s.cfg).Flags[k].Apply(f); err != nil {
return err
}
}
cliCtx := cli.NewContext(nil, f, nil)
if AppProvider(s.cfg).Before != nil {
if err := AppProvider(s.cfg).Before(cliCtx); err != nil {
return err
}
}
if err := AppProvider(s.cfg).Action(cliCtx); err != nil {
return err
}
return nil
}

View File

@@ -9,7 +9,6 @@ import (
"github.com/cs3org/reva/cmd/revad/runtime"
"github.com/gofrs/uuid"
"github.com/micro/cli/v2"
"github.com/oklog/run"
ociscfg "github.com/owncloud/ocis/ocis-pkg/config"
"github.com/owncloud/ocis/ocis-pkg/sync"
@@ -18,6 +17,7 @@ import (
"github.com/owncloud/ocis/storage/pkg/server/debug"
"github.com/owncloud/ocis/storage/pkg/tracing"
"github.com/thejerf/suture/v4"
"github.com/urfave/cli/v2"
)
// AuthBasic is the entrypoint for the auth-basic command.
@@ -118,6 +118,8 @@ func authBasicConfigFromStruct(c *cli.Context, cfg *config.Config) map[string]in
"ldap": map[string]interface{}{
"hostname": cfg.Reva.LDAP.Hostname,
"port": cfg.Reva.LDAP.Port,
"cacert": cfg.Reva.LDAP.CACert,
"insecure": cfg.Reva.LDAP.Insecure,
"base_dn": cfg.Reva.LDAP.BaseDN,
"loginfilter": cfg.Reva.LDAP.LoginFilter,
"bind_username": cfg.Reva.LDAP.BindDN,

View File

@@ -8,7 +8,6 @@ import (
"github.com/cs3org/reva/cmd/revad/runtime"
"github.com/gofrs/uuid"
"github.com/micro/cli/v2"
"github.com/oklog/run"
ociscfg "github.com/owncloud/ocis/ocis-pkg/config"
"github.com/owncloud/ocis/ocis-pkg/sync"
@@ -17,6 +16,7 @@ import (
"github.com/owncloud/ocis/storage/pkg/server/debug"
"github.com/owncloud/ocis/storage/pkg/tracing"
"github.com/thejerf/suture/v4"
"github.com/urfave/cli/v2"
)
// AuthBearer is the entrypoint for the auth-bearer command.
@@ -101,7 +101,7 @@ func authBearerConfigFromStruct(c *cli.Context, cfg *config.Config) map[string]i
// TODO build services dynamically
"services": map[string]interface{}{
"authprovider": map[string]interface{}{
"auth_manager": "oidc",
"auth_manager": cfg.Reva.AuthBearerConfig.Driver,
"auth_managers": map[string]interface{}{
"oidc": map[string]interface{}{
"issuer": cfg.Reva.OIDC.Issuer,
@@ -111,6 +111,9 @@ func authBearerConfigFromStruct(c *cli.Context, cfg *config.Config) map[string]i
"gid_claim": cfg.Reva.OIDC.GIDClaim,
"gatewaysvc": cfg.Reva.Gateway.Endpoint,
},
"machine": map[string]interface{}{
"api_key": cfg.Reva.AuthBearerConfig.MachineAuthAPIKey,
},
},
},
},

View File

@@ -6,11 +6,11 @@ import (
"fmt"
"os"
"path"
"strconv"
"strings"
"github.com/cs3org/reva/cmd/revad/runtime"
"github.com/gofrs/uuid"
"github.com/micro/cli/v2"
"github.com/oklog/run"
ociscfg "github.com/owncloud/ocis/ocis-pkg/config"
"github.com/owncloud/ocis/ocis-pkg/conversions"
@@ -20,6 +20,7 @@ import (
"github.com/owncloud/ocis/storage/pkg/server/debug"
"github.com/owncloud/ocis/storage/pkg/tracing"
"github.com/thejerf/suture/v4"
"github.com/urfave/cli/v2"
)
// Frontend is the entrypoint for the frontend command.
@@ -30,7 +31,7 @@ func Frontend(cfg *config.Config) *cli.Command {
Flags: flagset.FrontendWithConfig(cfg),
Before: func(c *cli.Context) error {
cfg.Reva.Frontend.Services = c.StringSlice("service")
cfg.Reva.ChecksumSupportedTypes = c.StringSlice("checksum-suppored-type")
cfg.Reva.ChecksumSupportedTypes = c.StringSlice("checksum-supported-type")
return loadUserAgent(c, cfg)
},
Action: func(c *cli.Context) error {
@@ -54,12 +55,34 @@ func Frontend(cfg *config.Config) *cli.Command {
desktopRedirectURIs[port] = fmt.Sprintf("http://localhost:%d", (port + 1024))
}
archivers := []map[string]interface{}{
{
"enabled": true,
"version": "2.0.0",
"formats": []string{"tar", "zip"},
"archiver_url": cfg.Reva.Archiver.ArchiverURL,
"max_num_files": strconv.FormatInt(cfg.Reva.Archiver.MaxNumFiles, 10),
"max_size": strconv.FormatInt(cfg.Reva.Archiver.MaxSize, 10),
},
}
appProviders := []map[string]interface{}{
{
"enabled": true,
"version": "1.0.0",
"apps_url": cfg.Reva.AppProvider.AppsURL,
"open_url": cfg.Reva.AppProvider.OpenURL,
},
}
filesCfg := map[string]interface{}{
"private_links": false,
"bigfilechunking": false,
"blacklisted_files": []string{},
"undelete": true,
"versioning": true,
"archivers": archivers,
"app_providers": appProviders,
}
if cfg.Reva.DefaultUploadProtocol == "tus" {
@@ -141,6 +164,19 @@ func frontendConfigFromStruct(c *cli.Context, cfg *config.Config, filesCfg map[s
},
// TODO build services dynamically
"services": map[string]interface{}{
"appprovider": map[string]interface{}{
"prefix": cfg.Reva.Frontend.AppProviderPrefix,
"transfer_shared_secret": cfg.Reva.TransferSecret,
"timeout": 86400,
"insecure": true,
},
"archiver": map[string]interface{}{
"prefix": cfg.Reva.Frontend.ArchiverPrefix,
"timeout": 86400,
"insecure": true,
"max_num_files": cfg.Reva.Archiver.MaxNumFiles,
"max_size": cfg.Reva.Archiver.MaxSize,
},
"datagateway": map[string]interface{}{
"prefix": cfg.Reva.Frontend.DatagatewayPrefix,
"transfer_shared_secret": cfg.Reva.TransferSecret,
@@ -244,9 +280,6 @@ func frontendConfigFromStruct(c *cli.Context, cfg *config.Config, filesCfg map[s
"incoming": true,
},
},
"notifications": map[string]interface{}{
"endpoints": []string{"disable"},
},
},
"version": map[string]interface{}{
"edition": "reva",

View File

@@ -15,7 +15,6 @@ import (
"github.com/cs3org/reva/cmd/revad/runtime"
"github.com/gofrs/uuid"
"github.com/micro/cli/v2"
"github.com/oklog/run"
ociscfg "github.com/owncloud/ocis/ocis-pkg/config"
"github.com/owncloud/ocis/ocis-pkg/log"
@@ -24,6 +23,7 @@ import (
"github.com/owncloud/ocis/storage/pkg/server/debug"
"github.com/owncloud/ocis/storage/pkg/service/external"
"github.com/thejerf/suture/v4"
"github.com/urfave/cli/v2"
)
// Gateway is the entrypoint for the gateway command.
@@ -165,6 +165,9 @@ func gatewayConfigFromStruct(c *cli.Context, cfg *config.Config, logger log.Logg
},
},
},
"appregistry": map[string]interface{}{
"driver": "static",
},
"storageregistry": map[string]interface{}{
"driver": cfg.Reva.StorageRegistry.Driver,
"drivers": map[string]interface{}{

View File

@@ -7,19 +7,17 @@ import (
"path"
"path/filepath"
"github.com/owncloud/ocis/storage/pkg/tracing"
"github.com/owncloud/ocis/ocis-pkg/sync"
"github.com/cs3org/reva/cmd/revad/runtime"
"github.com/gofrs/uuid"
"github.com/micro/cli/v2"
"github.com/oklog/run"
ociscfg "github.com/owncloud/ocis/ocis-pkg/config"
"github.com/owncloud/ocis/ocis-pkg/sync"
"github.com/owncloud/ocis/storage/pkg/config"
"github.com/owncloud/ocis/storage/pkg/flagset"
"github.com/owncloud/ocis/storage/pkg/server/debug"
"github.com/owncloud/ocis/storage/pkg/tracing"
"github.com/thejerf/suture/v4"
"github.com/urfave/cli/v2"
)
// Groups is the entrypoint for the sharing command.
@@ -120,6 +118,8 @@ func groupsConfigFromStruct(c *cli.Context, cfg *config.Config) map[string]inter
"ldap": map[string]interface{}{
"hostname": cfg.Reva.LDAP.Hostname,
"port": cfg.Reva.LDAP.Port,
"cacert": cfg.Reva.LDAP.CACert,
"insecure": cfg.Reva.LDAP.Insecure,
"base_dn": cfg.Reva.LDAP.BaseDN,
"groupfilter": cfg.Reva.LDAP.GroupFilter,
"attributefilter": cfg.Reva.LDAP.GroupAttributeFilter,

View File

@@ -4,9 +4,9 @@ import (
"fmt"
"net/http"
"github.com/micro/cli/v2"
"github.com/owncloud/ocis/storage/pkg/config"
"github.com/owncloud/ocis/storage/pkg/flagset"
"github.com/urfave/cli/v2"
)
// Health is the entrypoint for the health command.

View File

@@ -4,12 +4,12 @@ import (
"os"
"strings"
"github.com/micro/cli/v2"
"github.com/owncloud/ocis/ocis-pkg/log"
"github.com/owncloud/ocis/storage/pkg/config"
"github.com/owncloud/ocis/storage/pkg/flagset"
"github.com/owncloud/ocis/storage/pkg/version"
"github.com/spf13/viper"
"github.com/urfave/cli/v2"
)
// Execute is the entry point for the storage command.
@@ -76,6 +76,7 @@ func Execute(cfg *config.Config) error {
Gateway(cfg),
Users(cfg),
Groups(cfg),
AppProvider(cfg),
AuthBasic(cfg),
AuthBearer(cfg),
Sharing(cfg),

View File

@@ -13,13 +13,13 @@ import (
"github.com/cs3org/reva/cmd/revad/runtime"
"github.com/gofrs/uuid"
"github.com/micro/cli/v2"
"github.com/oklog/run"
ociscfg "github.com/owncloud/ocis/ocis-pkg/config"
"github.com/owncloud/ocis/storage/pkg/config"
"github.com/owncloud/ocis/storage/pkg/flagset"
"github.com/owncloud/ocis/storage/pkg/server/debug"
"github.com/thejerf/suture/v4"
"github.com/urfave/cli/v2"
)
// Sharing is the entrypoint for the sharing command.
@@ -113,6 +113,7 @@ func sharingConfigFromStruct(c *cli.Context, cfg *config.Config) map[string]inte
},
"shared": map[string]interface{}{
"jwt_secret": cfg.Reva.JWTSecret,
"gatewaysvc": cfg.Reva.Gateway.Endpoint,
},
"grpc": map[string]interface{}{
"network": cfg.Reva.Sharing.GRPCNetwork,
@@ -125,7 +126,7 @@ func sharingConfigFromStruct(c *cli.Context, cfg *config.Config) map[string]inte
"json": map[string]interface{}{
"file": cfg.Reva.Sharing.UserJSONFile,
},
"sql": map[string]interface{}{
"sql": map[string]interface{}{ // cernbox sql
"db_username": cfg.Reva.Sharing.UserSQLUsername,
"db_password": cfg.Reva.Sharing.UserSQLPassword,
"db_host": cfg.Reva.Sharing.UserSQLHost,
@@ -135,6 +136,15 @@ func sharingConfigFromStruct(c *cli.Context, cfg *config.Config) map[string]inte
"enable_expired_shares_cleanup": cfg.Reva.Sharing.PublicEnableExpiredSharesCleanup,
"janitor_run_interval": cfg.Reva.Sharing.PublicJanitorRunInterval,
},
"oc10-sql": map[string]interface{}{
"gateway_addr": cfg.Reva.Gateway.Endpoint,
"storage_mount_id": cfg.Reva.Sharing.UserStorageMountID,
"db_username": cfg.Reva.Sharing.UserSQLUsername,
"db_password": cfg.Reva.Sharing.UserSQLPassword,
"db_host": cfg.Reva.Sharing.UserSQLHost,
"db_port": cfg.Reva.Sharing.UserSQLPort,
"db_name": cfg.Reva.Sharing.UserSQLName,
},
},
},
"publicshareprovider": map[string]interface{}{
@@ -153,6 +163,18 @@ func sharingConfigFromStruct(c *cli.Context, cfg *config.Config) map[string]inte
"enable_expired_shares_cleanup": cfg.Reva.Sharing.PublicEnableExpiredSharesCleanup,
"janitor_run_interval": cfg.Reva.Sharing.PublicJanitorRunInterval,
},
"oc10-sql": map[string]interface{}{
"gateway_addr": cfg.Reva.Gateway.Endpoint,
"storage_mount_id": cfg.Reva.Sharing.UserStorageMountID,
"db_username": cfg.Reva.Sharing.UserSQLUsername,
"db_password": cfg.Reva.Sharing.UserSQLPassword,
"db_host": cfg.Reva.Sharing.UserSQLHost,
"db_port": cfg.Reva.Sharing.UserSQLPort,
"db_name": cfg.Reva.Sharing.UserSQLName,
"password_hash_cost": cfg.Reva.Sharing.PublicPasswordHashCost,
"enable_expired_shares_cleanup": cfg.Reva.Sharing.PublicEnableExpiredSharesCleanup,
"janitor_run_interval": cfg.Reva.Sharing.PublicJanitorRunInterval,
},
},
},
},

View File

@@ -10,7 +10,6 @@ import (
"github.com/cs3org/reva/cmd/revad/runtime"
"github.com/gofrs/uuid"
"github.com/micro/cli/v2"
"github.com/oklog/run"
ociscfg "github.com/owncloud/ocis/ocis-pkg/config"
"github.com/owncloud/ocis/storage/pkg/config"
@@ -18,6 +17,7 @@ import (
"github.com/owncloud/ocis/storage/pkg/server/debug"
"github.com/owncloud/ocis/storage/pkg/tracing"
"github.com/thejerf/suture/v4"
"github.com/urfave/cli/v2"
)
// StorageHome is the entrypoint for the storage-home command.

View File

@@ -10,7 +10,6 @@ import (
"github.com/cs3org/reva/cmd/revad/runtime"
"github.com/gofrs/uuid"
"github.com/micro/cli/v2"
"github.com/oklog/run"
ociscfg "github.com/owncloud/ocis/ocis-pkg/config"
"github.com/owncloud/ocis/storage/pkg/config"
@@ -19,6 +18,7 @@ import (
"github.com/owncloud/ocis/storage/pkg/service/external"
"github.com/owncloud/ocis/storage/pkg/tracing"
"github.com/thejerf/suture/v4"
"github.com/urfave/cli/v2"
)
// StorageMetadata the entrypoint for the storage-storage-metadata command.

View File

@@ -8,7 +8,6 @@ import (
"github.com/cs3org/reva/cmd/revad/runtime"
"github.com/gofrs/uuid"
"github.com/micro/cli/v2"
"github.com/oklog/run"
ociscfg "github.com/owncloud/ocis/ocis-pkg/config"
"github.com/owncloud/ocis/ocis-pkg/sync"
@@ -17,6 +16,7 @@ import (
"github.com/owncloud/ocis/storage/pkg/server/debug"
"github.com/owncloud/ocis/storage/pkg/tracing"
"github.com/thejerf/suture/v4"
"github.com/urfave/cli/v2"
)
// StoragePublicLink is the entrypoint for the reva-storage-public-link command.

View File

@@ -8,7 +8,6 @@ import (
"github.com/cs3org/reva/cmd/revad/runtime"
"github.com/gofrs/uuid"
"github.com/micro/cli/v2"
"github.com/oklog/run"
ociscfg "github.com/owncloud/ocis/ocis-pkg/config"
"github.com/owncloud/ocis/ocis-pkg/sync"
@@ -17,6 +16,7 @@ import (
"github.com/owncloud/ocis/storage/pkg/server/debug"
"github.com/owncloud/ocis/storage/pkg/tracing"
"github.com/thejerf/suture/v4"
"github.com/urfave/cli/v2"
)
// StorageUsers is the entrypoint for the storage-users command.

View File

@@ -9,7 +9,6 @@ import (
"github.com/cs3org/reva/cmd/revad/runtime"
"github.com/gofrs/uuid"
"github.com/micro/cli/v2"
"github.com/oklog/run"
ociscfg "github.com/owncloud/ocis/ocis-pkg/config"
"github.com/owncloud/ocis/ocis-pkg/sync"
@@ -18,6 +17,7 @@ import (
"github.com/owncloud/ocis/storage/pkg/server/debug"
"github.com/owncloud/ocis/storage/pkg/tracing"
"github.com/thejerf/suture/v4"
"github.com/urfave/cli/v2"
)
// Users is the entrypoint for the sharing command.
@@ -125,6 +125,8 @@ func usersConfigFromStruct(c *cli.Context, cfg *config.Config) map[string]interf
"ldap": map[string]interface{}{
"hostname": cfg.Reva.LDAP.Hostname,
"port": cfg.Reva.LDAP.Port,
"cacert": cfg.Reva.LDAP.CACert,
"insecure": cfg.Reva.LDAP.Insecure,
"base_dn": cfg.Reva.LDAP.BaseDN,
"userfilter": cfg.Reva.LDAP.UserFilter,
"attributefilter": cfg.Reva.LDAP.UserAttributeFilter,
@@ -155,6 +157,18 @@ func usersConfigFromStruct(c *cli.Context, cfg *config.Config) map[string]interf
"oidc_token_endpoint": cfg.Reva.UserGroupRest.OIDCTokenEndpoint,
"target_api": cfg.Reva.UserGroupRest.TargetAPI,
},
"owncloudsql": map[string]interface{}{
"dbusername": cfg.Reva.UserOwnCloudSQL.DBUsername,
"dbpassword": cfg.Reva.UserOwnCloudSQL.DBPassword,
"dbhost": cfg.Reva.UserOwnCloudSQL.DBHost,
"dbport": cfg.Reva.UserOwnCloudSQL.DBPort,
"dbname": cfg.Reva.UserOwnCloudSQL.DBName,
"idp": cfg.Reva.UserOwnCloudSQL.Idp,
"nobody": cfg.Reva.UserOwnCloudSQL.Nobody,
"join_username": cfg.Reva.UserOwnCloudSQL.JoinUsername,
"join_ownclouduuid": cfg.Reva.UserOwnCloudSQL.JoinOwnCloudUUID,
"enable_medial_search": cfg.Reva.UserOwnCloudSQL.EnableMedialSearch,
},
},
},
},