github.com/cs3org/reva/v2@v2.27.7/internal/http/services/owncloud/ocdav/config/config.go (about)

     1  package config
     2  
     3  import "github.com/cs3org/reva/v2/pkg/sharedconf"
     4  
     5  // Config holds the config options that need to be passed down to all ocdav handlers
     6  type Config struct {
     7  	Prefix string `mapstructure:"prefix"`
     8  	// FilesNamespace prefixes the namespace, optionally with user information.
     9  	// Example: if FilesNamespace is /users/{{substr 0 1 .Username}}/{{.Username}}
    10  	// and received path is /docs the internal path will be:
    11  	// /users/<first char of username>/<username>/docs
    12  	FilesNamespace string `mapstructure:"files_namespace"`
    13  	// WebdavNamespace prefixes the namespace, optionally with user information.
    14  	// Example: if WebdavNamespace is /users/{{substr 0 1 .Username}}/{{.Username}}
    15  	// and received path is /docs the internal path will be:
    16  	// /users/<first char of username>/<username>/docs
    17  	WebdavNamespace string `mapstructure:"webdav_namespace"`
    18  	SharesNamespace string `mapstructure:"shares_namespace"`
    19  	OCMNamespace    string `mapstructure:"ocm_namespace"`
    20  	GatewaySvc      string `mapstructure:"gatewaysvc"`
    21  	Timeout         int64  `mapstructure:"timeout"`
    22  	Insecure        bool   `mapstructure:"insecure"`
    23  	// If true, HTTP COPY will expect the HTTP-TPC (third-party copy) headers
    24  	EnableHTTPTpc               bool                              `mapstructure:"enable_http_tpc"`
    25  	PublicURL                   string                            `mapstructure:"public_url"`
    26  	FavoriteStorageDriver       string                            `mapstructure:"favorite_storage_driver"`
    27  	FavoriteStorageDrivers      map[string]map[string]interface{} `mapstructure:"favorite_storage_drivers"`
    28  	Version                     string                            `mapstructure:"version"`
    29  	VersionString               string                            `mapstructure:"version_string"`
    30  	Edition                     string                            `mapstructure:"edition"`
    31  	Product                     string                            `mapstructure:"product"`
    32  	ProductName                 string                            `mapstructure:"product_name"`
    33  	ProductVersion              string                            `mapstructure:"product_version"`
    34  	AllowPropfindDepthInfinitiy bool                              `mapstructure:"allow_depth_infinity"`
    35  
    36  	TransferSharedSecret string `mapstructure:"transfer_shared_secret"`
    37  
    38  	NameValidation NameValidation `mapstructure:"validation"`
    39  
    40  	MachineAuthAPIKey string `mapstructure:"machine_auth_apikey"`
    41  }
    42  
    43  // NameValidation is the validation configuration for file and folder names
    44  type NameValidation struct {
    45  	InvalidChars []string `mapstructure:"invalid_chars"`
    46  	MaxLength    int      `mapstructure:"max_length"`
    47  }
    48  
    49  // Init initializes the configuration
    50  func (c *Config) Init() {
    51  	// note: default c.Prefix is an empty string
    52  	c.GatewaySvc = sharedconf.GetGatewaySVC(c.GatewaySvc)
    53  
    54  	if c.FavoriteStorageDriver == "" {
    55  		c.FavoriteStorageDriver = "memory"
    56  	}
    57  
    58  	if c.Version == "" {
    59  		c.Version = "10.0.11.5"
    60  	}
    61  
    62  	if c.VersionString == "" {
    63  		c.VersionString = "10.0.11"
    64  	}
    65  
    66  	if c.Product == "" {
    67  		c.Product = "reva"
    68  	}
    69  
    70  	if c.ProductName == "" {
    71  		c.ProductName = "reva"
    72  	}
    73  
    74  	if c.ProductVersion == "" {
    75  		c.ProductVersion = "10.0.11"
    76  	}
    77  
    78  	if c.Edition == "" {
    79  		c.Edition = "community"
    80  	}
    81  
    82  	if c.NameValidation.InvalidChars == nil {
    83  		c.NameValidation.InvalidChars = []string{"\f", "\r", "\n", "\\"}
    84  	}
    85  
    86  	if c.NameValidation.MaxLength == 0 {
    87  		c.NameValidation.MaxLength = 255
    88  	}
    89  }