Per-directory permissions: add wildcards support

Signed-off-by: Nicola Murino <nicola.murino@gmail.com>
This commit is contained in:
Nicola Murino
2022-11-18 18:12:04 +01:00
parent ec4cc33364
commit 2017cb60e9
7 changed files with 60 additions and 30 deletions

View File

@@ -489,8 +489,12 @@ func (u *User) GetPermissionsForPath(p string) []string {
// so the first match is the one we are interested to
for idx := range dirsForPath {
if perms, ok := u.Permissions[dirsForPath[idx]]; ok {
permissions = perms
break
return perms
}
for dir, perms := range u.Permissions {
if match, err := path.Match(dir, dirsForPath[idx]); err == nil && match {
return perms
}
}
}
return permissions