From 92e8ec70024a266684f166dfce2cc711caaa51a4 Mon Sep 17 00:00:00 2001 From: ytqh Date: Mon, 3 Feb 2025 09:26:12 +0800 Subject: [PATCH] change auth and docs path --- api/controllers/admin/auth/login.py | 2 +- api/controllers/admin/stats/stats.py | 6 +++--- api/controllers/service_api/auth/login.py | 4 ++-- api/extensions/ext_swagger.py | 11 +++++++---- 4 files changed, 13 insertions(+), 10 deletions(-) diff --git a/api/controllers/admin/auth/login.py b/api/controllers/admin/auth/login.py index 7602ee892b..797932bbf0 100644 --- a/api/controllers/admin/auth/login.py +++ b/api/controllers/admin/auth/login.py @@ -104,7 +104,7 @@ class LogoutApi(Resource): summary: Admin Logout description: Logs out the authenticated admin and invalidates the JWT token security: - - JWT: [] + - ApiKeyAuth: [] responses: 200: description: Logout successful diff --git a/api/controllers/admin/stats/stats.py b/api/controllers/admin/stats/stats.py index 54b69d3645..b885c13705 100644 --- a/api/controllers/admin/stats/stats.py +++ b/api/controllers/admin/stats/stats.py @@ -12,7 +12,7 @@ class RiskStats(Resource): summary: Get risk level user counts description: Get counts of users at different risk levels and their changes security: - - JWT: [] + - ApiKeyAuth: [] parameters: - name: start_date in: query @@ -58,7 +58,7 @@ class UserStats(Resource): summary: Get daily active and new user counts description: Get statistics of daily active users and new users security: - - JWT: [] + - ApiKeyAuth: [] parameters: - name: start_date in: query @@ -106,7 +106,7 @@ class ConversationStats(Resource): summary: Get daily conversation counts and averages description: Get statistics of daily total conversations and average conversations per user security: - - JWT: [] + - ApiKeyAuth: [] parameters: - name: start_date in: query diff --git a/api/controllers/service_api/auth/login.py b/api/controllers/service_api/auth/login.py index 3ef4271766..e7ec285bc2 100644 --- a/api/controllers/service_api/auth/login.py +++ b/api/controllers/service_api/auth/login.py @@ -35,7 +35,7 @@ class LogoutApi(Resource): summary: Logout User description: Logs out the authenticated user and invalidates the session security: - - JWT: [] + - ApiKeyAuth: [] responses: 200: description: Successfully logged out @@ -226,7 +226,7 @@ class RefreshTokenApi(Resource): summary: Refresh Token description: Refreshes an access token using a valid refresh token security: - - JWT: [] + - ApiKeyAuth: [] parameters: - in: body name: body diff --git a/api/extensions/ext_swagger.py b/api/extensions/ext_swagger.py index 3bff3fe948..17c4452a33 100644 --- a/api/extensions/ext_swagger.py +++ b/api/extensions/ext_swagger.py @@ -8,12 +8,15 @@ def init_app(app: DifyApp): app.config['SWAGGER'] = { 'title': 'API Docs', 'uiversion': 3, + 'url_prefix': '/openapi', + 'specs_route': '/', + 'static_url_path': '/flasgger_static', 'securityDefinitions': { - 'JWT': { + 'ApiKeyAuth': { 'type': 'apiKey', - 'name': 'access-token', # name of the cookie - 'in': 'header', # specify that auth is in cookie - 'description': 'JWT Authorization cookie' + 'name': 'Authorization', + 'in': 'header', + 'description': 'API Key Authorization header using Bearer scheme. Example: "Bearer {token}"' } } }