mirror of
https://git.mirrors.martin98.com/https://github.com/langgenius/dify.git
synced 2025-08-15 20:06:03 +08:00
Merge branch 'feat/webapp-auth-api' into e-260
This commit is contained in:
commit
2259dfdc58
@ -1,4 +1,3 @@
|
|||||||
import logging
|
|
||||||
import uuid
|
import uuid
|
||||||
from typing import cast
|
from typing import cast
|
||||||
|
|
||||||
@ -68,7 +67,6 @@ class AppListApi(Resource):
|
|||||||
|
|
||||||
if FeatureService.get_system_features().webapp_auth.enabled:
|
if FeatureService.get_system_features().webapp_auth.enabled:
|
||||||
app_ids = [str(app.id) for app in app_pagination.items]
|
app_ids = [str(app.id) for app in app_pagination.items]
|
||||||
logging.info(f"app_ids: {app_ids}")
|
|
||||||
res = EnterpriseService.WebAppAuth.batch_get_app_access_mode_by_id(app_ids=app_ids)
|
res = EnterpriseService.WebAppAuth.batch_get_app_access_mode_by_id(app_ids=app_ids)
|
||||||
if len(res) != len(app_ids):
|
if len(res) != len(app_ids):
|
||||||
raise BadRequest("Invalid app id in webapp auth")
|
raise BadRequest("Invalid app id in webapp auth")
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
import logging
|
|
||||||
from functools import wraps
|
from functools import wraps
|
||||||
|
|
||||||
from flask_login import current_user # type: ignore
|
from flask_login import current_user # type: ignore
|
||||||
@ -61,12 +60,10 @@ def user_allowed_to_access_app(view=None):
|
|||||||
if feature.webapp_auth.enabled:
|
if feature.webapp_auth.enabled:
|
||||||
app_id = installed_app.app_id
|
app_id = installed_app.app_id
|
||||||
app_code = AppService.get_app_code_by_id(app_id)
|
app_code = AppService.get_app_code_by_id(app_id)
|
||||||
logging.info(f"app_id: {app_id}, app_code: {app_code}")
|
|
||||||
res = EnterpriseService.WebAppAuth.is_user_allowed_to_access_webapp(
|
res = EnterpriseService.WebAppAuth.is_user_allowed_to_access_webapp(
|
||||||
user_id=str(current_user.id),
|
user_id=str(current_user.id),
|
||||||
app_code=app_code,
|
app_code=app_code,
|
||||||
)
|
)
|
||||||
logging.info(f"res: {res}")
|
|
||||||
if not res:
|
if not res:
|
||||||
raise AppAccessDeniedError()
|
raise AppAccessDeniedError()
|
||||||
|
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
import logging
|
|
||||||
|
|
||||||
from flask import request
|
from flask import request
|
||||||
from flask_restful import Resource, marshal_with, reqparse # type: ignore
|
from flask_restful import Resource, marshal_with, reqparse # type: ignore
|
||||||
@ -84,10 +83,7 @@ class AppWebAuthPermission(Resource):
|
|||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
app_id = args["appId"]
|
app_id = args["appId"]
|
||||||
logging.info(f"App ID: {app_id}, User ID: {user_id}")
|
|
||||||
|
|
||||||
app_code = AppService.get_app_code_by_id(app_id)
|
app_code = AppService.get_app_code_by_id(app_id)
|
||||||
logging.info(f"App code: {app_code}")
|
|
||||||
|
|
||||||
res = EnterpriseService.WebAppAuth.is_user_allowed_to_access_webapp(str(user_id), app_code)
|
res = EnterpriseService.WebAppAuth.is_user_allowed_to_access_webapp(str(user_id), app_code)
|
||||||
return {"result": res}
|
return {"result": res}
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
import logging
|
|
||||||
|
|
||||||
from pydantic import BaseModel, Field
|
from pydantic import BaseModel, Field
|
||||||
|
|
||||||
@ -46,7 +45,6 @@ class EnterpriseService:
|
|||||||
raise ValueError("No data found.")
|
raise ValueError("No data found.")
|
||||||
|
|
||||||
if not isinstance(data["accessModes"], dict):
|
if not isinstance(data["accessModes"], dict):
|
||||||
logging.info(f"Batch get app access mode by id returns data: {data}")
|
|
||||||
raise ValueError("Invalid data format.")
|
raise ValueError("Invalid data format.")
|
||||||
|
|
||||||
ret = {}
|
ret = {}
|
||||||
@ -55,7 +53,6 @@ class EnterpriseService:
|
|||||||
curr.access_mode = value
|
curr.access_mode = value
|
||||||
ret[key] = curr
|
ret[key] = curr
|
||||||
|
|
||||||
logging.info(f"Batch get app access mode by id returns data: {ret}")
|
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
Loading…
x
Reference in New Issue
Block a user