mirror of
https://github.com/HKUDS/nanobot.git
synced 2026-06-19 17:24:02 +00:00
fix: handler token issue also checks static token as fallback
This commit is contained in:
parent
0acf7cd373
commit
2420826e05
@ -14,7 +14,7 @@ from collections.abc import Callable
|
|||||||
from contextlib import suppress
|
from contextlib import suppress
|
||||||
from functools import partial
|
from functools import partial
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import TYPE_CHECKING, Any, Self
|
from typing import Any, Self
|
||||||
from urllib.parse import parse_qs, unquote, urlparse
|
from urllib.parse import parse_qs, unquote, urlparse
|
||||||
|
|
||||||
from loguru import logger
|
from loguru import logger
|
||||||
@ -28,7 +28,7 @@ from websockets.http11 import Response
|
|||||||
from nanobot.bus.events import OUTBOUND_META_AGENT_UI, OutboundMessage
|
from nanobot.bus.events import OUTBOUND_META_AGENT_UI, OutboundMessage
|
||||||
from nanobot.bus.queue import MessageBus
|
from nanobot.bus.queue import MessageBus
|
||||||
from nanobot.channels.base import BaseChannel
|
from nanobot.channels.base import BaseChannel
|
||||||
from nanobot.config.paths import get_media_dir, get_workspace_path
|
from nanobot.config.paths import get_media_dir
|
||||||
from nanobot.config.schema import Base
|
from nanobot.config.schema import Base
|
||||||
from nanobot.security.workspace_access import (
|
from nanobot.security.workspace_access import (
|
||||||
WORKSPACE_SCOPE_METADATA_KEY,
|
WORKSPACE_SCOPE_METADATA_KEY,
|
||||||
@ -44,9 +44,6 @@ from nanobot.webui.cli_apps_api import normalize_cli_app_mentions
|
|||||||
from nanobot.webui.mcp_presets_api import normalize_mcp_preset_mentions
|
from nanobot.webui.mcp_presets_api import normalize_mcp_preset_mentions
|
||||||
from nanobot.webui.transcript import append_transcript_object
|
from nanobot.webui.transcript import append_transcript_object
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
|
||||||
from nanobot.session.manager import SessionManager
|
|
||||||
|
|
||||||
|
|
||||||
def _strip_trailing_slash(path: str) -> str:
|
def _strip_trailing_slash(path: str) -> str:
|
||||||
if len(path) > 1 and path.endswith("/"):
|
if len(path) > 1 and path.endswith("/"):
|
||||||
|
|||||||
@ -380,7 +380,7 @@ class GatewayHTTPHandler:
|
|||||||
# -- Token issue --------------------------------------------------------
|
# -- Token issue --------------------------------------------------------
|
||||||
|
|
||||||
def _handle_token_issue(self, connection: Any, request: Any) -> Any:
|
def _handle_token_issue(self, connection: Any, request: Any) -> Any:
|
||||||
secret = self.config.token_issue_secret.strip()
|
secret = self.config.token_issue_secret.strip() or self.config.token.strip()
|
||||||
if secret:
|
if secret:
|
||||||
if not _issue_route_secret_matches(request.headers, secret):
|
if not _issue_route_secret_matches(request.headers, secret):
|
||||||
return connection.respond(401, "Unauthorized")
|
return connection.respond(401, "Unauthorized")
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user