fix(webui): allow switching Default permissions back to Full Access (#6175)

* fix(webui): allow authenticated access mode switching

* refactor(webui): remove constant full access eligibility helpers

* refactor(webui): remove obsolete full access policy parameter

* docs(webui): remove redundant access switching paragraph

* refactor(webui): remove obsolete full access capability
This commit is contained in:
chengyongru authored and GitHub committed 2026-10-12 15:39:33 +08:00
1 parent ae186cb18d
commit 73af08efab
14 files changed
+87 -204

No files matched your search

-6
View File
@@ -164,9 +164,6 @@ class WebUICommandRouter:
def workspace_project_selection_available(self, connection: ServerConnection) -> bool:
return self._http_router.workspace_project_selection_available(connection)
def workspace_full_access_available(self, connection: ServerConnection) -> bool:
return self._http_router.workspace_full_access_available(connection)
async def send_webui_protocol_error(
self,
connection: ServerConnection,
@@ -310,7 +307,6 @@ class WebUICommandRouter:
lambda: self._workspaces.scope_for_new_chat(
envelope,
can_change_project=self.workspace_project_selection_available(connection),
can_use_full_access=self.workspace_full_access_available(connection),
),
)
if scope is None:
@@ -451,7 +447,6 @@ class WebUICommandRouter:
chat_id=chat_id,
chat_running=websocket_turn_wall_started_at(chat_id) is not None,
can_change_project=self.workspace_project_selection_available(connection),
can_use_full_access=self.workspace_full_access_available(connection),
),
chat_id=chat_id,
)
@@ -630,7 +625,6 @@ class WebUICommandRouter:
chat_id=chat_id,
chat_running=websocket_turn_wall_started_at(chat_id) is not None,
can_change_project=self.workspace_project_selection_available(connection),
can_use_full_access=self.workspace_full_access_available(connection),
)
),
chat_id=chat_id,
-23
View File
@@ -175,7 +175,6 @@ def workspaces_payload(
default_workspace: Path,
default_restrict_to_workspace: bool,
can_change_project: bool,
can_use_full_access: bool,
) -> dict[str, Any]:
state = read_webui_workspace_state()
default_access_mode = state["default_access_mode"]
@@ -203,7 +202,6 @@ def workspaces_payload(
],
"controls": {
"can_change_project": can_change_project,
"can_use_full_access": can_use_full_access,
"can_browse_directories": can_change_project,
"can_resolve_project": can_change_project,
"can_manage_favorites": can_change_project,
@@ -302,13 +300,11 @@ class WebUIWorkspaceController:
self,
*,
can_change_project: bool,
can_use_full_access: bool,
) -> dict[str, Any]:
return workspaces_payload(
default_workspace=self._default_workspace,
default_restrict_to_workspace=self._default_restrict_to_workspace,
can_change_project=can_change_project,
can_use_full_access=can_use_full_access,
)
def resolve_project(self, path: object) -> dict[str, str]:
@@ -358,7 +354,6 @@ class WebUIWorkspaceController:
*,
session_key: str | None,
can_change_project: bool,
can_use_full_access: bool,
) -> WorkspaceScope:
current = self.scope_for_session_key(session_key) if session_key else self.default_scope()
raw = envelope.get(WORKSPACE_SCOPE_METADATA_KEY)
@@ -376,18 +371,6 @@ class WebUIWorkspaceController:
"project selection is unavailable for this connection",
status=403,
)
if (
not can_use_full_access
and scope.access_mode == "full"
and (
current.access_mode != "full"
or scope.project_path != current.project_path
)
):
raise WorkspaceScopeError(
"full workspace access is unavailable for this connection",
status=403,
)
return scope
def scope_for_new_chat(
@@ -395,13 +378,11 @@ class WebUIWorkspaceController:
envelope: dict[str, Any],
*,
can_change_project: bool,
can_use_full_access: bool,
) -> WorkspaceScope:
return self.scope_from_envelope(
envelope,
session_key=None,
can_change_project=can_change_project,
can_use_full_access=can_use_full_access,
)
def scope_for_set_request(
@@ -411,7 +392,6 @@ class WebUIWorkspaceController:
chat_id: str,
chat_running: bool,
can_change_project: bool,
can_use_full_access: bool,
) -> WorkspaceScope:
if chat_running:
raise WorkspaceScopeError("chat_running", status=409)
@@ -419,7 +399,6 @@ class WebUIWorkspaceController:
envelope,
session_key=webui_session_key(chat_id),
can_change_project=can_change_project,
can_use_full_access=can_use_full_access,
)
def scope_for_message(
@@ -429,13 +408,11 @@ class WebUIWorkspaceController:
chat_id: str,
chat_running: bool,
can_change_project: bool,
can_use_full_access: bool,
) -> WorkspaceScope:
scope = self.scope_from_envelope(
envelope,
session_key=webui_session_key(chat_id),
can_change_project=can_change_project,
can_use_full_access=can_use_full_access,
)
if (
WORKSPACE_SCOPE_METADATA_KEY in envelope
-24
View File
@@ -446,26 +446,6 @@ class GatewayHTTPHandler:
"""
return True
def workspace_full_access_available(
self,
connection: Any,
headers: Any | None = None,
) -> bool:
"""Return whether this request may opt into Full Access.
A reverse proxy can make a remote browser look like a localhost TCP
peer. Inspect the original browser headers before granting this
capability so proxy-local requests keep the remote restriction.
"""
if self._runtime_surface == "native":
return True
if headers is None:
request = getattr(connection, "request", None)
headers = getattr(request, "headers", None)
if not isinstance(headers, Mapping):
return False
return _is_local_browser_request(connection, headers)
# -- Token management ---------------------------------------------------
def check_api_token(self, request: WsRequest) -> bool:
@@ -1679,10 +1659,6 @@ class GatewayHTTPHandler:
return _http_json_response(
self.workspaces.payload(
can_change_project=self.workspace_project_selection_available(connection),
can_use_full_access=self.workspace_full_access_available(
connection,
request.headers,
),
)
)