createUserDir should not apply to admin users
Is your feature request related to a problem? Please describe.
When a source has createUserDir: true, admin users are treated the same as regular users: their scope gets rewritten to / and a user folder is created for them. The admin ends up rooted in their own folder instead of the source root.
Config file:
server:
sources:
- path: /storage
config:
defaultEnabled: true
defaultUserScope: '/users'
createUserDir: trueObserved behavior:
- Regular users correctly land in /storage/users/ (the intended behavior).
- Admins get their /storage scope rewritten to /users/ (or / from scope /) on login, so the /storage source opens at their personal folder. The source root and other users' folders are no longer reachable via that source.
- The admin also gets a user folder created on disk (MakeUserDirs runs for admins too, e.g. /storage/users/admin).
This also makes defaultEnabled: false useless as a way to keep a source admin-only: disabled sources are never auto-granted to anyone, including admins (MergeDefaultEnabledBackendScopes), so the only way to give admins a disabled source is a manual per-user grant.
Describe the solution you'd like
Admins get the top level source view, so they are exempt from createUserDir behavior.
- ExpandBackendScopesForCreateUserDir (backend/pkg/settings/user_scopes.go) currently skips only anonymous; it should also skip users with Permissions.Admin, leaving their scope untouched.
- MakeUserDirs (backend/internal/adapters/fs/files/user.go) should not create user directories for admins.
Expected result with the config above: regular users land in /storage/users/; the admin keeps the configured scope (e.g. /) and sees the full source. No per-user grants needed.
Additional context
Related code paths: backend/pkg/settings/user_scopes.go:12 (skip condition), backend/pkg/settings/settings.go:172 (expansion on user defaults, runs for
all users including admins), backend/web/auth.go (runs on every login + MakeUserDirs).
Source: gtsteffaniak/filebrowser