gooderp18绿色标准版
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

47 line
1.5KB

  1. ##########################################################################
  2. #
  3. # pgAdmin 4 - PostgreSQL Tools
  4. #
  5. # Copyright (C) 2013 - 2020, The pgAdmin Development Team
  6. # This software is released under the PostgreSQL Licence
  7. #
  8. #########################################################################
  9. from flask_wtf.csrf import CSRFProtect
  10. from flask import request, current_app
  11. class _PGCSRFProtect(CSRFProtect):
  12. def __init__(self, *args, **kwargs):
  13. super(_PGCSRFProtect, self).__init__(*args, **kwargs)
  14. def init_app(self, app):
  15. super(_PGCSRFProtect, self).init_app(app)
  16. self._pg_csrf_exempt(app)
  17. def _pg_csrf_exempt(self, app):
  18. """Exempt some of the Views/blueprints from CSRF protection
  19. """
  20. exempt_views = [
  21. 'flask.helpers.send_static_file',
  22. 'flask_security.views.login',
  23. 'flask_security.views.logout',
  24. 'pgadmin.tools.translations',
  25. app.blueprints['redirects'],
  26. 'pgadmin.browser.server_groups.servers.supported_servers-js',
  27. 'pgadmin.tools.datagrid.initialize_query_tool',
  28. 'pgadmin.tools.datagrid.panel',
  29. 'pgadmin.tools.debugger.initialize_target',
  30. 'pgadmin.tools.debugger.direct_new',
  31. 'pgadmin.tools.schema_diff.panel',
  32. 'pgadmin.tools.schema_diff.ddl_compare',
  33. 'pgadmin.authenticate.login'
  34. ]
  35. for exempt in exempt_views:
  36. self.exempt(exempt)
  37. pgCSRFProtect = _PGCSRFProtect()
上海开阖软件有限公司 沪ICP备12045867号-1