[fix]fix token auth (#69)

* fix tocken auth

* Further fixes to the token overwriting issue and restoration of hot reloading of tokens.json.
This commit is contained in:
bingquanzhao
2025-12-24 20:39:16 +08:00
committed by GitHub
parent 43143f0b30
commit 81305ffbf9
6 changed files with 384 additions and 40 deletions

View File

@@ -22,6 +22,7 @@ Implements enterprise-level authentication, authorization, SQL security validati
import logging
import re
from contextvars import ContextVar
from dataclasses import dataclass, field
from datetime import datetime
from enum import Enum
@@ -34,6 +35,10 @@ from sqlparse.tokens import Keyword, Name
from .logger import get_logger
from .config import DatabaseConfig
# Global ContextVar for auth_context - must be a single instance shared across all modules
# This allows token-bound database configuration to work correctly in concurrent requests
mcp_auth_context_var: ContextVar['AuthContext'] = ContextVar('mcp_auth_context', default=None)
class SecurityLevel(Enum):
"""Security level enumeration"""