mirror of
https://git.srhtnin.garden/sarah/SaraView.git
synced 2026-10-14 02:38:11 +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
|
.DS_Store
|
||||||
.vscode/
|
.vscode/
|
||||||
.idea/
|
.idea/
|
||||||
|
|
||||||
|
# Misc
|
||||||
|
.Todo/
|
||||||
+5
-6
@@ -75,7 +75,7 @@ def RemoveLock(RootName: str, RelativePath: str) -> None:
|
|||||||
|
|
||||||
|
|
||||||
def IsPathAccessible(
|
def IsPathAccessible(
|
||||||
RootName: str, RelativePath: str, Username: str, UserGroups: list[str], IsAdmin: bool
|
RootName: str, RelativePath: str, Username: str, UserGroups: list[str]
|
||||||
) -> bool:
|
) -> bool:
|
||||||
"""A path is inaccessible if it IS a locked file/directory, or lies
|
"""A path is inaccessible if it IS a locked file/directory, or lies
|
||||||
anywhere underneath a locked directory, and the user isn't permitted
|
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
|
to subdirectories as separate records — there's only ever one lock
|
||||||
entry per locked directory — but access to anything inside still
|
entry per locked directory — but access to anything inside still
|
||||||
requires being permitted on that ancestor lock, so you always have to
|
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():
|
for Lock in LoadLocks():
|
||||||
if Lock.get("Root") != RootName:
|
if Lock.get("Root") != RootName:
|
||||||
continue
|
continue
|
||||||
@@ -119,6 +119,5 @@ def RequirePathAccessible(RootName: str, RelativePath: str, CurrentUser: dict[st
|
|||||||
RelativePath,
|
RelativePath,
|
||||||
CurrentUser["Username"],
|
CurrentUser["Username"],
|
||||||
CurrentUser.get("Groups", []),
|
CurrentUser.get("Groups", []),
|
||||||
CurrentUser.get("IsAdmin", False),
|
|
||||||
):
|
):
|
||||||
raise HTTPException(status_code=404, detail="Not found.")
|
raise HTTPException(status_code=404, detail="Not found.")
|
||||||
+3
-4
@@ -318,9 +318,10 @@ def PutGroupMembersEndpoint(
|
|||||||
|
|
||||||
|
|
||||||
# --- Locked files/directories -----------------------------------------------
|
# --- 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.
|
# 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")
|
@Application.get("/api/lock")
|
||||||
@@ -384,7 +385,6 @@ def GetTreeEndpoint(
|
|||||||
|
|
||||||
Username = CurrentUser["Username"]
|
Username = CurrentUser["Username"]
|
||||||
UserGroups = CurrentUser.get("Groups", [])
|
UserGroups = CurrentUser.get("Groups", [])
|
||||||
IsAdmin = CurrentUser.get("IsAdmin", False)
|
|
||||||
|
|
||||||
# A locked subdirectory (or anything inside one) shouldn't even appear
|
# A locked subdirectory (or anything inside one) shouldn't even appear
|
||||||
# in its parent's listing for someone without access to it.
|
# 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"],
|
f"{Path}/{Entry['Name']}" if Path else Entry["Name"],
|
||||||
Username,
|
Username,
|
||||||
UserGroups,
|
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-
|
creation time (the New File/New Directory dialog includes a search-and-
|
||||||
checkbox picker) or afterwards via the 🔒 button next to any entry, in
|
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
|
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
|
see something, you're trusted to change who else can. Admins do not bypass
|
||||||
bypass every restriction, so they can always troubleshoot.
|
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
|
Restricting is per-file-or-directory — locking a directory covers everything
|
||||||
inside it automatically (there's only ever one restriction record per locked
|
inside it automatically (there's only ever one restriction record per locked
|
||||||
|
|||||||
Reference in new issue
Block a user