Merge remote-tracking branch 'origin/release/v0.3.2' into fix/Timebomb_032
This commit is contained in:
@@ -9,7 +9,7 @@ from sqlalchemy.orm import Session
|
|||||||
from sqlalchemy import select
|
from sqlalchemy import select
|
||||||
|
|
||||||
from app.aioRedis import aio_redis
|
from app.aioRedis import aio_redis
|
||||||
from app.models.api_key_model import ApiKey
|
from app.models.api_key_model import ApiKey, ApiKeyType
|
||||||
from app.repositories.api_key_repository import ApiKeyRepository, ApiKeyLogRepository
|
from app.repositories.api_key_repository import ApiKeyRepository, ApiKeyLogRepository
|
||||||
from app.schemas import api_key_schema
|
from app.schemas import api_key_schema
|
||||||
from app.schemas.response_schema import PageData, PageMeta
|
from app.schemas.response_schema import PageData, PageMeta
|
||||||
@@ -65,7 +65,8 @@ class ApiKeyService:
|
|||||||
BizCode.BAD_REQUEST
|
BizCode.BAD_REQUEST
|
||||||
)
|
)
|
||||||
|
|
||||||
if data.resource_id:
|
# SERVICE 类型的 resource_id 指向 workspace,非应用,跳过应用发布校验
|
||||||
|
if data.resource_id and data.type != ApiKeyType.SERVICE.value:
|
||||||
app = db.get(App, data.resource_id)
|
app = db.get(App, data.resource_id)
|
||||||
if not app or not app.current_release_id:
|
if not app or not app.current_release_id:
|
||||||
raise BusinessException("该应用未发布", BizCode.APP_NOT_PUBLISHED)
|
raise BusinessException("该应用未发布", BizCode.APP_NOT_PUBLISHED)
|
||||||
@@ -452,9 +453,12 @@ class ApiKeyAuthService:
|
|||||||
def check_app_published(db: Session, api_key_obj: ApiKey) -> None:
|
def check_app_published(db: Session, api_key_obj: ApiKey) -> None:
|
||||||
"""
|
"""
|
||||||
检查应用是否已发布,未发布则抛出异常
|
检查应用是否已发布,未发布则抛出异常
|
||||||
|
SERVICE 类型的 api_key 不绑定应用(resource_id 指向 workspace),跳过校验
|
||||||
"""
|
"""
|
||||||
if not api_key_obj.resource_id:
|
if not api_key_obj.resource_id:
|
||||||
return
|
return
|
||||||
|
if api_key_obj.type == ApiKeyType.SERVICE.value:
|
||||||
|
return
|
||||||
app = db.get(App, api_key_obj.resource_id)
|
app = db.get(App, api_key_obj.resource_id)
|
||||||
if not app or not app.current_release_id:
|
if not app or not app.current_release_id:
|
||||||
raise BusinessException("应用未发布,不可用", BizCode.APP_NOT_PUBLISHED)
|
raise BusinessException("应用未发布,不可用", BizCode.APP_NOT_PUBLISHED)
|
||||||
|
|||||||
Reference in New Issue
Block a user