1. fix: No reject when input domain with special character like "test_domain.com"
2. fix: When updating service with "Update from OpenAPI" in Tools Management tab, Tool URL is removed, when reloading it is displayed again.
This commit is contained in:
1 parent
924bee4a96
commit
a744f5a6c4
4 files changed
+37
-3
No files matched your search
@@ -15,6 +15,10 @@ from services.admin_service.services.platform_report_service import PlatformRepo
|
||||
from services.admin_service.constants import sys_config_key
|
||||
from services.common.logging_config import get_logger
|
||||
from services.admin_service.utils.ip import get_public_ip, get_local_ip
|
||||
from services.common.utils.validation_utils import ValidationUtils
|
||||
from services.common.exceptions import ValidationException
|
||||
|
||||
|
||||
|
||||
logger = get_logger(__name__)
|
||||
|
||||
@@ -237,7 +241,12 @@ def set_sysconfig(
|
||||
email_smtp_password = email_config.get("smtp_password")
|
||||
email_smtp_sender = email_config.get("smtp_sender")
|
||||
|
||||
|
||||
if not domain:
|
||||
# 正则检查domain格式
|
||||
try:
|
||||
domain = ValidationUtils.validate_domain(domain)
|
||||
except ValidationException as e:
|
||||
return ResponseUtils.error(message=str(e), code=400)
|
||||
|
||||
# Batch update configuration
|
||||
configs = [
|
||||
|
||||
@@ -85,7 +85,7 @@ class UserRepository:
|
||||
def get_user_list(self, offset: int, limit: int) -> Tuple[int, List[User]]:
|
||||
total = self.db.query(User).filter(User.is_deleted == 0, User.role_id == 2).count()
|
||||
|
||||
users = self.db.query(User).filter(User.is_deleted == 0, User.role_id == 2).offset(offset).limit(limit).all()
|
||||
users = self.db.query(User).filter(User.is_deleted == 0, User.role_id == 2).order_by(User.created_at.desc()).offset(offset).limit(limit).all()
|
||||
return total, users
|
||||
|
||||
def get_admin_user(self) -> Optional[User]:
|
||||
|
||||
@@ -472,7 +472,7 @@ class McpManagerService:
|
||||
# 5. Build return data
|
||||
apis_list = []
|
||||
for temp_api in temp_apis:
|
||||
api_dict = {"id": temp_api.id, "name": temp_api.name, "description": temp_api.description}
|
||||
api_dict = {"id": temp_api.id, "name": temp_api.name,"url": temp_api.path, "description": temp_api.description}
|
||||
apis_list.append(api_dict)
|
||||
|
||||
result = {
|
||||
|
||||
@@ -120,6 +120,31 @@ class ValidationUtils:
|
||||
raise ValidationException(f"Parameter '{param_name}' must be a valid HTTP/HTTPS URL")
|
||||
|
||||
return url
|
||||
@staticmethod
|
||||
def validate_domain(domain: str, param_name: str = "domain") -> str:
|
||||
"""
|
||||
Validate domain format
|
||||
|
||||
Args:
|
||||
domain: The domain to validate
|
||||
param_name: Name of the parameter for error message
|
||||
|
||||
Returns:
|
||||
The validated domain
|
||||
|
||||
Raises:
|
||||
ValidationException: If domain format is invalid
|
||||
"""
|
||||
if not domain or not isinstance(domain, str):
|
||||
raise ValidationException(f"Parameter '{param_name}' must be a valid domain name")
|
||||
|
||||
domain = domain.strip().lower()
|
||||
domain_pattern = r'^(?:(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,})$'
|
||||
|
||||
if not re.match(domain_pattern, domain):
|
||||
raise ValidationException(f"Parameter '{param_name}' must be a valid domain name")
|
||||
|
||||
return domain
|
||||
|
||||
@staticmethod
|
||||
def validate_pagination(page: Any, page_size: Any) -> Tuple[int, int]:
|
||||
|
||||
Reference in new issue
Block a user