mirror of
https://git.srhtnin.garden/sarah/SaraView.git
synced 2026-10-13 18:28:14 +02:00
Fixed admins being able to see all directories.
This commit is contained in:
1 parent
9a5b9530a3
commit
70a390f7cf
4 files changed
+15
-12
No files matched your search
@@ -10,3 +10,6 @@ Frontend/dist/
|
||||
.DS_Store
|
||||
.vscode/
|
||||
.idea/
|
||||
|
||||
# Misc
|
||||
.Todo/
|
||||
+5
-6
@@ -75,7 +75,7 @@ def RemoveLock(RootName: str, RelativePath: str) -> None:
|
||||
|
||||
|
||||
def IsPathAccessible(
|
||||
RootName: str, RelativePath: str, Username: str, UserGroups: list[str], IsAdmin: bool
|
||||
RootName: str, RelativePath: str, Username: str, UserGroups: list[str]
|
||||
) -> bool:
|
||||
"""A path is inaccessible if it IS a locked file/directory, or lies
|
||||
anywhere underneath a locked directory, and the user isn't permitted
|
||||
@@ -83,11 +83,11 @@ def IsPathAccessible(
|
||||
to subdirectories as separate records — there's only ever one lock
|
||||
entry per locked directory — but access to anything inside still
|
||||
requires being permitted on that ancestor lock, so you always have to
|
||||
"enter the parent first." Admins bypass every lock.
|
||||
"enter the parent first." Admins do NOT bypass locks - Admin is a
|
||||
management group (create users, manage groups, and so on), not a way
|
||||
to view everyone's private directories. Only direct server/filesystem
|
||||
access can see everything.
|
||||
"""
|
||||
if IsAdmin:
|
||||
return True
|
||||
|
||||
for Lock in LoadLocks():
|
||||
if Lock.get("Root") != RootName:
|
||||
continue
|
||||
@@ -119,6 +119,5 @@ def RequirePathAccessible(RootName: str, RelativePath: str, CurrentUser: dict[st
|
||||
RelativePath,
|
||||
CurrentUser["Username"],
|
||||
CurrentUser.get("Groups", []),
|
||||
CurrentUser.get("IsAdmin", False),
|
||||
):
|
||||
raise HTTPException(status_code=404, detail="Not found.")
|
||||
+3
-4
@@ -318,9 +318,10 @@ def PutGroupMembersEndpoint(
|
||||
|
||||
|
||||
# --- Locked files/directories -----------------------------------------------
|
||||
# Setting a lock is open to anyone who currently has access to the path —
|
||||
# Setting a lock is open to anyone who currently has access to the path -
|
||||
# not admin-only. If you can see it, you're trusted to decide who else can.
|
||||
# Admins additionally bypass every lock (see Locks.IsPathAccessible).
|
||||
# Admins do NOT bypass locks (see Locks.IsPathAccessible) - Admin is a
|
||||
# management group, not a way to view everyone's private directories.
|
||||
|
||||
|
||||
@Application.get("/api/lock")
|
||||
@@ -384,7 +385,6 @@ def GetTreeEndpoint(
|
||||
|
||||
Username = CurrentUser["Username"]
|
||||
UserGroups = CurrentUser.get("Groups", [])
|
||||
IsAdmin = CurrentUser.get("IsAdmin", False)
|
||||
|
||||
# A locked subdirectory (or anything inside one) shouldn't even appear
|
||||
# in its parent's listing for someone without access to it.
|
||||
@@ -396,7 +396,6 @@ def GetTreeEndpoint(
|
||||
f"{Path}/{Entry['Name']}" if Path else Entry["Name"],
|
||||
Username,
|
||||
UserGroups,
|
||||
IsAdmin,
|
||||
)
|
||||
]
|
||||
|
||||
|
||||
@@ -151,8 +151,10 @@ restrict a file or directory to specific users and/or groups, whether at
|
||||
creation time (the New File/New Directory dialog includes a search-and-
|
||||
checkbox picker) or afterwards via the 🔒 button next to any entry, in
|
||||
either the sidebar tree or the directory-browse pane. If you can currently
|
||||
see something, you're trusted to change who else can. Admins additionally
|
||||
bypass every restriction, so they can always troubleshoot.
|
||||
see something, you're trusted to change who else can. Admins do not bypass
|
||||
restrictions - Admin is a management group (creating users, managing groups,
|
||||
and so on), not a way to view everyone's private directories. Only direct
|
||||
access to the server's files can see everything.
|
||||
|
||||
Restricting is per-file-or-directory — locking a directory covers everything
|
||||
inside it automatically (there's only ever one restriction record per locked
|
||||
|
||||
Reference in new issue
Block a user