diff --git a/auth/hook.go b/auth/hook.go
index 3e57560e..d11bbdb1 100644
--- a/auth/hook.go
+++ b/auth/hook.go
@@ -11,6 +11,7 @@ import (
"github.com/filebrowser/filebrowser/v2/errors"
"github.com/filebrowser/filebrowser/v2/files"
+ "github.com/filebrowser/filebrowser/v2/rules"
"github.com/filebrowser/filebrowser/v2/settings"
"github.com/filebrowser/filebrowser/v2/users"
)
@@ -31,6 +32,7 @@ type HookAuth struct {
Cred hookCred `json:"-"`
Fields hookFields `json:"-"`
Command string `json:"command"`
+ Rules []rules.Rule `json:"rules"`
}
// Auth authenticates the user via a json in content body.
@@ -228,6 +230,7 @@ func (a *HookAuth) GetUser(d *users.User) *users.User {
Asc: a.Fields.GetBoolean("user.sorting.asc", d.Sorting.Asc),
By: a.Fields.GetString("user.sorting.by", d.Sorting.By),
},
+ Rules: a.Fields.GetRules("user.perm.rule", d.Rules),
Commands: a.Fields.GetArray("user.commands", d.Commands),
HideDotfiles: a.Fields.GetBoolean("user.hideDotfiles", d.HideDotfiles),
Perm: perms,
@@ -261,6 +264,7 @@ var validHookFields = []string{
"user.perm.delete",
"user.perm.share",
"user.perm.download",
+ "user.perm.rule",
}
// IsValid checks if the provided field is on the valid fields list
@@ -300,3 +304,20 @@ func (hf *hookFields) GetArray(k string, dv []string) []string {
}
return dv
}
+
+func (hf *hookFields) GetRules(k string, dv []rules.Rule) []rules.Rule {
+ val, ok := hf.Values[k]
+ if !ok {
+ return dv
+ }
+ var dvv []rules.Rule
+ for _, ruleString := range strings.Split(val, ";") {
+ var rule rules.Rule
+ err := json.Unmarshal([]byte(ruleString), &rule)
+ if err != nil {
+ return dv
+ }
+ dvv = append(dvv, rule)
+ }
+ return dvv
+}
diff --git a/cmd/config_init.go b/cmd/config_init.go
index 7848e706..22d628a1 100644
--- a/cmd/config_init.go
+++ b/cmd/config_init.go
@@ -37,7 +37,7 @@ override the options.`,
Branding: settings.Branding{
Name: mustGetString(flags, "branding.name"),
DisableExternal: mustGetBool(flags, "branding.disableExternal"),
- DisableUsedPercentage: mustGetBool(flags, "branding.DisableUsedPercentage"),
+ DisableUsedPercentage: mustGetBool(flags, "branding.disableUsedPercentage"),
Files: mustGetString(flags, "branding.files"),
},
}
diff --git a/files/file.go b/files/file.go
index 1daf384b..7b8d0d70 100644
--- a/files/file.go
+++ b/files/file.go
@@ -58,7 +58,7 @@ type FileOptions struct {
// object will be automatically filled depending on if it is a directory
// or a file. If it's a video file, it will also detect any subtitles.
func NewFileInfo(opts FileOptions) (*FileInfo, error) {
- if !opts.Checker.Check(opts.Path) {
+ if !opts.Checker.CheckReadPerm(opts.Path) { // display folder/file list
return nil, os.ErrPermission
}
@@ -319,7 +319,7 @@ func (i *FileInfo) readListing(checker rules.Checker, readHeader bool) error {
name := f.Name()
fPath := path.Join(i.Path, name)
- if !checker.Check(fPath) {
+ if !checker.CheckReadPerm(fPath) {
continue
}
diff --git a/frontend/src/components/settings/Rules.vue b/frontend/src/components/settings/Rules.vue
index 8f3c45eb..2b93f691 100644
--- a/frontend/src/components/settings/Rules.vue
+++ b/frontend/src/components/settings/Rules.vue
@@ -4,20 +4,15 @@
-
-
+
+
+
+
+