plugin.py 864 B

123456789101112131415161718192021222324252627
  1. from flask_login import current_user
  2. from flask_restful import Resource
  3. from werkzeug.exceptions import Forbidden
  4. from controllers.console import api
  5. from controllers.console.setup import setup_required
  6. from controllers.console.wraps import account_initialization_required
  7. from libs.login import login_required
  8. from services.plugin.plugin_debugging_service import PluginDebuggingService
  9. class PluginDebuggingKeyApi(Resource):
  10. @setup_required
  11. @login_required
  12. @account_initialization_required
  13. def get(self):
  14. user = current_user
  15. if not user.is_admin_or_owner:
  16. raise Forbidden()
  17. tenant_id = user.current_tenant_id
  18. return {
  19. "key": PluginDebuggingService.get_plugin_debugging_key(tenant_id)
  20. }
  21. api.add_resource(PluginDebuggingKeyApi, "/workspaces/current/plugin/debugging-key")