bump reva

Signed-off-by: jkoberg <jkoberg@owncloud.com>
This commit is contained in:
jkoberg
2023-12-15 15:28:53 +01:00
parent 15efafaf23
commit 7acc141e4f
13 changed files with 56 additions and 24 deletions

View File

@@ -37,6 +37,7 @@ import (
"github.com/cs3org/reva/v2/pkg/rgrpc"
"github.com/cs3org/reva/v2/pkg/storagespace"
"github.com/cs3org/reva/v2/pkg/utils"
"github.com/mitchellh/mapstructure"
)
const (
@@ -223,17 +224,11 @@ func publisherFromConfig(m map[string]interface{}) (events.Publisher, error) {
default:
return nil, fmt.Errorf("stream type '%s' not supported", typ)
case "nats":
var tlsCert string
val, ok := m["tls-root-ca-cert"]
if ok {
tlsCert = val.(string)
var cfg stream.NatsConfig
if err := mapstructure.Decode(m, &cfg); err != nil {
return nil, err
}
return stream.NatsFromConfig(m["name"].(string), false, stream.NatsConfig{
Endpoint: m["address"].(string),
Cluster: m["clusterID"].(string),
EnableTLS: m["enable-tls"].(bool),
TLSInsecure: m["tls-insecure"].(bool),
TLSRootCACertificate: tlsCert,
})
name, _ := m["name"].(string)
return stream.NatsFromConfig(name, false, cfg)
}
}

View File

@@ -76,6 +76,8 @@ type eventconfig struct {
TLSInsecure bool `mapstructure:"tls_insecure" docs:"Whether to verify the server TLS certificates."`
TLSRootCACertificate string `mapstructure:"tls_root_ca_cert" docs:"The root CA certificate used to validate the server's TLS certificate."`
EnableTLS bool `mapstructure:"nats_enable_tls" docs:"events tls switch"`
AuthUsername string `mapstructure:"nats_username" docs:"event stream username"`
AuthPassword string `mapstructure:"nats_password" docs:"event stream password"`
}
func (c *config) init() {

View File

@@ -48,6 +48,8 @@ type config struct {
NatsTLSInsecure bool `mapstructure:"nats_tls_insecure"`
NatsRootCACertPath string `mapstructure:"nats_root_ca_cert_path"`
NatsEnableTLS bool `mapstructure:"nats_enable_tls"`
NatsUsername string `mapstructure:"nats_username"`
NatsPassword string `mapstructure:"nats_password"`
}
func (c *config) init() {
@@ -86,6 +88,8 @@ func New(m map[string]interface{}, log *zerolog.Logger) (global.Service, error)
EnableTLS: conf.NatsEnableTLS,
TLSInsecure: conf.NatsTLSInsecure,
TLSRootCACertificate: conf.NatsRootCACertPath,
AuthUsername: conf.NatsUsername,
AuthPassword: conf.NatsPassword,
})
if err != nil {
return nil, err

View File

@@ -1156,7 +1156,7 @@ func mdToPropResponse(ctx context.Context, pf *XML, md *provider.ResourceInfo, p
appendToOK(
prop.Escaped("oc:id", sid),
prop.Escaped("oc:fileid", sid),
prop.Escaped("oc:spaceid", id.SpaceId),
prop.Escaped("oc:spaceid", storagespace.FormatStorageID(id.StorageId, id.SpaceId)),
)
}
@@ -1296,7 +1296,7 @@ func mdToPropResponse(ctx context.Context, pf *XML, md *provider.ResourceInfo, p
}
case "spaceid":
if id != nil {
appendToOK(prop.Escaped("oc:spaceid", id.SpaceId))
appendToOK(prop.Escaped("oc:spaceid", storagespace.FormatStorageID(id.StorageId, id.SpaceId)))
} else {
appendToNotFound(prop.Escaped("oc:spaceid", ""))
}

View File

@@ -17,11 +17,14 @@ import (
// NatsConfig is the configuration needed for a NATS event stream
type NatsConfig struct {
Endpoint string // Endpoint of the nats server
Cluster string // CluserID of the nats cluster
TLSInsecure bool // Whether to verify TLS certificates
TLSRootCACertificate string // The root CA certificate used to validate the TLS certificate
EnableTLS bool // Enable TLS
Endpoint string `mapstructure:"address"` // Endpoint of the nats server
Cluster string `mapstructure:"clusterID"` // CluserID of the nats cluster
TLSInsecure bool `mapstructure:"tls-insecure"` // Whether to verify TLS certificates
TLSRootCACertificate string `mapstructure:"tls-root-ca-cert"` // The root CA certificate used to validate the TLS certificate
EnableTLS bool `mapstructure:"enable-tls"` // Enable TLS
AuthUsername string `mapstructure:"username"` // Username for authentication
AuthPassword string `mapstructure:"password"` // Password for authentication
}
// NatsFromConfig returns a nats stream from the given config
@@ -55,6 +58,7 @@ func NatsFromConfig(connName string, disableDurability bool, cfg NatsConfig) (ev
natsjs.ClusterID(cfg.Cluster),
natsjs.SynchronousPublish(true),
natsjs.Name(connName),
natsjs.Authenticate(cfg.AuthUsername, cfg.AuthPassword),
}
if disableDurability {
@@ -62,7 +66,6 @@ func NatsFromConfig(connName string, disableDurability bool, cfg NatsConfig) (ev
}
return Nats(opts...)
}
// nats returns a nats streaming client

View File

@@ -133,6 +133,8 @@ type EventOptions struct {
TLSInsecure bool `mapstructure:"tlsinsecure"`
TLSRootCACertificate string `mapstructure:"tlsrootcacertificate"`
EnableTLS bool `mapstructure:"enabletls"`
AuthUsername string `mapstructure:"authusername"`
AuthPassword string `mapstructure:"authpassword"`
}
// Manager implements a share manager using a cs3 storage backend with local caching

View File

@@ -51,6 +51,8 @@ type Config struct {
TTL time.Duration `mapstructure:"cache_ttl"`
Size int `mapstructure:"cache_size"`
DisablePersistence bool `mapstructure:"cache_disable_persistence"`
AuthUsername string `mapstructure:"cache_auth_username"`
AuthPassword string `mapstructure:"cache_auth_password"`
}
// Cache handles key value operations on caches
@@ -240,5 +242,6 @@ func getStore(cfg Config) microstore.Store {
store.TTL(cfg.TTL),
store.Size(cfg.Size),
store.DisablePersistence(cfg.DisablePersistence),
store.Authentication(cfg.AuthUsername, cfg.AuthPassword),
)
}

View File

@@ -145,6 +145,7 @@ func NewDefault(m map[string]interface{}, bs tree.Blobstore, es events.Stream) (
microstore.Database(o.IDCache.Database),
microstore.Table(o.IDCache.Table),
store.DisablePersistence(o.IDCache.DisablePersistence),
store.Authentication(o.IDCache.AuthUsername, o.IDCache.AuthPassword),
))
permissionsSelector, err := pool.PermissionsSelector(o.PermissionsSVC, pool.WithTLSMode(o.PermTLSMode))

View File

@@ -89,3 +89,17 @@ func DisablePersistence(val bool) store.Option {
o.Context = context.WithValue(o.Context, disablePersistanceContextKey{}, val)
}
}
type authenticationContextKey struct{}
// Authentication configures the username and password to use for authentication.
// Only supported by the `natsjskv` implementation.
func Authentication(username, password string) store.Option {
return func(o *store.Options) {
if o.Context == nil {
o.Context = context.Background()
}
o.Context = context.WithValue(o.Context, authenticationContextKey{}, []string{username, password})
}
}

View File

@@ -127,6 +127,10 @@ func Create(opts ...microstore.Option) microstore.Store {
// host, port, clusterid
natsOptions := nats.GetDefaultOptions()
natsOptions.Name = "TODO" // we can pass in the service name to allow identifying the client, but that requires adding a custom context option
if auth, ok := options.Context.Value(authenticationContextKey{}).([]string); ok && len(auth) == 2 {
natsOptions.User = auth[0]
natsOptions.Password = auth[1]
}
return natsjs.NewStore(
append(opts,
natsjs.NatsOptions(natsOptions), // always pass in properly initialized default nats options
@@ -141,6 +145,10 @@ func Create(opts ...microstore.Option) microstore.Store {
natsOptions := nats.GetDefaultOptions()
natsOptions.Name = "TODO" // we can pass in the service name to allow identifying the client, but that requires adding a custom context option
if auth, ok := options.Context.Value(authenticationContextKey{}).([]string); ok && len(auth) == 2 {
natsOptions.User = auth[0]
natsOptions.Password = auth[1]
}
return natsjskv.NewStore(
append(opts,
natsjs.NatsOptions(natsOptions), // always pass in properly initialized default nats options