filters: we can now set allowed and denied files extensions

This commit is contained in:
Nicola Murino
2020-03-01 22:10:29 +01:00
parent 7163fde724
commit b885d453a2
17 changed files with 826 additions and 59 deletions

View File

@@ -103,11 +103,13 @@ func updateUser(w http.ResponseWriter, r *http.Request) {
}
user, err := dataprovider.GetUserByID(dataProvider, userID)
currentPermissions := user.Permissions
currentFileExtensions := user.Filters.FileExtensions
currentS3AccessSecret := ""
if user.FsConfig.Provider == 1 {
currentS3AccessSecret = user.FsConfig.S3Config.AccessSecret
}
user.Permissions = make(map[string][]string)
user.Filters.FileExtensions = []dataprovider.ExtensionsFilter{}
if _, ok := err.(*dataprovider.RecordNotFoundError); ok {
sendAPIResponse(w, r, err, "", http.StatusNotFound)
return
@@ -124,6 +126,10 @@ func updateUser(w http.ResponseWriter, r *http.Request) {
if len(user.Permissions) == 0 {
user.Permissions = currentPermissions
}
// we use new file extensions if passed otherwise the old ones
if len(user.Filters.FileExtensions) == 0 {
user.Filters.FileExtensions = currentFileExtensions
}
// we use the new access secret if different from the old one and not empty
if user.FsConfig.Provider == 1 {
if utils.RemoveDecryptionKey(currentS3AccessSecret) == user.FsConfig.S3Config.AccessSecret ||