config_local.py.j2 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447
  1. #!/usr/bin/env python3
  2. # -*- coding: utf-8 -*-
  3. ##########################################################################
  4. #
  5. # pgAdmin 4 - PostgreSQL Tools
  6. #
  7. # Copyright (C) 2013 - 2020, The pgAdmin Development Team
  8. # This software is released under the PostgreSQL Licence
  9. #
  10. # config.py - Core application configuration settings
  11. #
  12. ##########################################################################
  13. import builtins
  14. import logging
  15. import os
  16. import sys
  17. # We need to include the root directory in sys.path to ensure that we can
  18. # find everything we need when running in the standalone runtime.
  19. root = os.path.dirname(os.path.realpath(__file__))
  20. if sys.path[0] != root:
  21. sys.path.insert(0, root)
  22. from pgadmin.utils import env, IS_WIN, fs_short_path
  23. # Name of the application to display in the UI
  24. APP_NAME = "pgAdmin 4"
  25. APP_ICON = "pg-icon"
  26. ##########################################################################
  27. # Application settings
  28. ##########################################################################
  29. # NOTE!!!
  30. # If you change any of APP_RELEASE, APP_REVISION or APP_SUFFIX, then you
  31. # must also change APP_VERSION_INT to match.
  32. #
  33. # Any changes made here must also be made in runtime/pgAdmin4.pro and
  34. # runtime/Info.plist
  35. #
  36. # Application version number components
  37. APP_RELEASE = 6
  38. APP_REVISION = 1
  39. # Application version suffix, e.g. 'beta1', 'dev'. Usually an empty string
  40. # for GA releases.
  41. APP_SUFFIX = ""
  42. # Numeric application version for upgrade checks. Should be in the format:
  43. # [X]XYYZZ, where X is the release version, Y is the revision, with a leading
  44. # zero if needed, and Z represents the suffix, with a leading zero if needed
  45. APP_VERSION_INT = 50000
  46. # DO NOT CHANGE!
  47. # The application version string, constructed from the components
  48. if not APP_SUFFIX:
  49. APP_VERSION = "%s.%s" % (APP_RELEASE, APP_REVISION)
  50. else:
  51. APP_VERSION = "%s.%s-%s" % (APP_RELEASE, APP_REVISION, APP_SUFFIX)
  52. # Copyright string for display in the app
  53. # Any changes made here must also be made in runtime/pgAdmin4.pro
  54. APP_COPYRIGHT = "Copyright (C) 2013 - 2020, The pgAdmin Development Team"
  55. ##########################################################################
  56. # Misc stuff
  57. ##########################################################################
  58. # Path to the online help.
  59. HELP_PATH = "../../../docs/en_US/_build/html/"
  60. # Languages we support in the UI
  61. LANGUAGES = {
  62. "en": "English",
  63. "zh": "Chinese (Simplified)",
  64. "cs": "Czech",
  65. "fr": "French",
  66. "de": "German",
  67. "it": "Italian",
  68. "ja": "Japanese",
  69. "ko": "Korean",
  70. "pl": "Polish",
  71. "ru": "Russian",
  72. "es": "Spanish",
  73. }
  74. # DO NOT CHANGE UNLESS YOU KNOW WHAT YOU ARE DOING!
  75. # List of modules to skip when dynamically loading
  76. MODULE_BLACKLIST = ["test"]
  77. # DO NOT CHANGE UNLESS YOU KNOW WHAT YOU ARE DOING!
  78. # List of treeview browser nodes to skip when dynamically loading
  79. NODE_BLACKLIST = []
  80. ##########################################################################
  81. # Server settings
  82. ##########################################################################
  83. # The server mode determines whether or not we're running on a web server
  84. # requiring user authentication, or desktop mode which uses an automatic
  85. # default login.
  86. #
  87. # DO NOT DISABLE SERVER MODE IF RUNNING ON A WEBSERVER!!
  88. #
  89. # We only set SERVER_MODE if it's not already set. That's to allow the
  90. # runtime to force it to False.
  91. #
  92. # NOTE: If you change the value of SERVER_MODE in an included config file,
  93. # you may also need to redefine any values below that are derived
  94. # from it, notably various paths such as LOG_FILE and anything
  95. # using DATA_DIR.
  96. if (not hasattr(builtins, "SERVER_MODE")) or builtins.SERVER_MODE is None:
  97. SERVER_MODE = True
  98. else:
  99. SERVER_MODE = builtins.SERVER_MODE
  100. # HTTP headers to search for CSRF token when it is not provided in the form.
  101. # Default is ['X-CSRFToken', 'X-CSRF-Token']
  102. WTF_CSRF_HEADERS = ["X-pgA-CSRFToken"]
  103. # User ID (email address) to use for the default user in desktop mode.
  104. # The default should be fine here, as it's not exposed in the app.
  105. DESKTOP_USER = "pgadmin4@pgadmin.org"
  106. # This option allows the user to host the application on a LAN
  107. # Default hosting is on localhost (DEFAULT_SERVER='localhost').
  108. # To host pgAdmin4 over LAN set DEFAULT_SERVER='0.0.0.0' (or a specific
  109. # adaptor address.
  110. #
  111. # NOTE: This is NOT recommended for production use, only for debugging
  112. # or testing. Production installations should be run as a WSGI application
  113. # behind Apache HTTPD.
  114. DEFAULT_SERVER = "0.0.0.0"
  115. # The default port on which the app server will listen if not set in the
  116. # environment by the runtime
  117. DEFAULT_SERVER_PORT = 5050
  118. # Enable X-Frame-Option protection.
  119. # Set to one of "SAMEORIGIN", "ALLOW-FROM origin" or "" to disable.
  120. # Note that "DENY" is NOT supported (and will be silently ignored).
  121. # See https://tools.ietf.org/html/rfc7034 for more info.
  122. X_FRAME_OPTIONS = "SAMEORIGIN"
  123. # Hashing algorithm used for password storage
  124. SECURITY_PASSWORD_HASH = "pbkdf2_sha512"
  125. # Reverse Proxy parameters
  126. # You must tell the middleware how many proxies set each header
  127. # so it knows what values to trust.
  128. # See https://tinyurl.com/yyg7r9av
  129. # for more information.
  130. # Number of values to trust for X-Forwarded-For
  131. PROXY_X_FOR_COUNT = 1
  132. # Number of values to trust for X-Forwarded-Proto.
  133. PROXY_X_PROTO_COUNT = 1
  134. # Number of values to trust for X-Forwarded-Host.
  135. PROXY_X_HOST_COUNT = 0
  136. # Number of values to trust for X-Forwarded-Port.
  137. PROXY_X_PORT_COUNT = 1
  138. # Number of values to trust for X-Forwarded-Prefix.
  139. PROXY_X_PREFIX_COUNT = 0
  140. # NOTE: CSRF_SESSION_KEY, SECRET_KEY and SECURITY_PASSWORD_SALT are no
  141. # longer part of the main configuration, but are stored in the
  142. # configuration databases 'keys' table and are auto-generated.
  143. # COMPRESSION
  144. COMPRESS_MIMETYPES = [
  145. "text/html",
  146. "text/css",
  147. "text/xml",
  148. "application/json",
  149. "application/javascript",
  150. ]
  151. COMPRESS_LEVEL = 9
  152. COMPRESS_MIN_SIZE = 500
  153. # Set the cache control max age for static files in flask to 1 year
  154. SEND_FILE_MAX_AGE_DEFAULT = 31556952
  155. # This will be added to static urls as url parameter with value as
  156. # APP_VERSION_INT for cache busting on version upgrade. If the value is set as
  157. # None or empty string then it will not be added.
  158. # eg - http:localhost:5050/pgadmin.css?intver=3.13
  159. APP_VERSION_PARAM = "ver"
  160. # Add the internal version param to below extensions only
  161. APP_VERSION_EXTN = (".css", ".js", ".html", ".svg", ".png", ".gif", ".ico")
  162. # Data directory for storage of config settings etc. This shouldn't normally
  163. # need to be changed - it's here as various other settings depend on it.
  164. # On Windows, we always store data in %APPDATA%\pgAdmin. On other platforms,
  165. # if we're in server mode we use /var/lib/pgadmin, otherwise ~/.pgadmin
  166. if IS_WIN:
  167. # Use the short path on windows
  168. DATA_DIR = os.path.realpath(os.path.join(fs_short_path(env("APPDATA")), u"pgAdmin"))
  169. else:
  170. if SERVER_MODE:
  171. DATA_DIR = "/usr/local/lib/pgadmin"
  172. else:
  173. DATA_DIR = os.path.realpath(os.path.expanduser(u"~/.pgadmin/"))
  174. # An optional login banner to show security warnings/disclaimers etc. at
  175. # login and password recovery etc. HTML may be included for basic formatting,
  176. # For example:
  177. # LOGIN_BANNER = "<h4>Authorised Users Only!</h4>" \
  178. # "Unauthorised use is strictly forbidden."
  179. LOGIN_BANNER = ""
  180. ##########################################################################
  181. # Log settings
  182. ##########################################################################
  183. # Debug mode?
  184. DEBUG = False
  185. # Application log level - one of:
  186. # CRITICAL 50
  187. # ERROR 40
  188. # WARNING 30
  189. # SQL 25
  190. # INFO 20
  191. # DEBUG 10
  192. # NOTSET 0
  193. CONSOLE_LOG_LEVEL = logging.WARNING
  194. FILE_LOG_LEVEL = logging.WARNING
  195. # Log format.
  196. CONSOLE_LOG_FORMAT = "%(asctime)s: %(levelname)s\t%(name)s:\t%(message)s"
  197. FILE_LOG_FORMAT = "%(asctime)s: %(levelname)s\t%(name)s:\t%(message)s"
  198. # Log file name. This goes in the data directory, except on non-Windows
  199. # platforms in server mode.
  200. if SERVER_MODE and not IS_WIN:
  201. LOG_FILE = "/var/log/pgadmin/pgadmin4.log"
  202. else:
  203. LOG_FILE = os.path.join(DATA_DIR, "pgadmin4.log")
  204. ##########################################################################
  205. # Server Connection Driver Settings
  206. ##########################################################################
  207. # The default driver used for making connection with PostgreSQL
  208. PG_DEFAULT_DRIVER = "psycopg2"
  209. # Maximum allowed idle time in minutes before which releasing the connection
  210. # for the particular session. (in minutes)
  211. MAX_SESSION_IDLE_TIME = 60
  212. ##########################################################################
  213. # User account and settings storage
  214. ##########################################################################
  215. # The default path to the SQLite database used to store user accounts and
  216. # settings. This default places the file in the same directory as this
  217. # config file, but generates an absolute path for use througout the app.
  218. SQLITE_PATH = env("SQLITE_PATH") or os.path.join(DATA_DIR, "pgadmin4.db")
  219. # SQLITE_TIMEOUT will define how long to wait before throwing the error -
  220. # OperationError due to database lock. On slower system, you may need to change
  221. # this to some higher value.
  222. # (Default: 500 milliseconds)
  223. SQLITE_TIMEOUT = 500
  224. # Allow database connection passwords to be saved if the user chooses.
  225. # Set to False to disable password saving.
  226. ALLOW_SAVE_PASSWORD = True
  227. # Maximum number of history queries stored per user/server/database
  228. MAX_QUERY_HIST_STORED = 20
  229. ##########################################################################
  230. # Server-side session storage path
  231. #
  232. # SESSION_DB_PATH (Default: $HOME/.pgadmin4/sessions)
  233. ##########################################################################
  234. #
  235. # We use SQLite for server-side session storage. There will be one
  236. # SQLite database object per session created.
  237. #
  238. # Specify the path used to store your session objects.
  239. #
  240. # If the specified directory does not exist, the setup script will create
  241. # it with permission mode 700 to keep the session database secure.
  242. #
  243. # On certain systems, you can use shared memory (tmpfs) for maximum
  244. # scalability, for example, on Ubuntu:
  245. #
  246. # SESSION_DB_PATH = '/run/shm/pgAdmin4_session'
  247. #
  248. ##########################################################################
  249. SESSION_DB_PATH = os.path.join(DATA_DIR, "sessions")
  250. SESSION_COOKIE_NAME = "pga4_session"
  251. ##########################################################################
  252. # Mail server settings
  253. ##########################################################################
  254. # These settings are used when running in web server mode for confirming
  255. # and resetting passwords etc.
  256. # See: http://pythonhosted.org/Flask-Mail/ for more info
  257. MAIL_SERVER = "box.unbl.ink"
  258. MAIL_PORT = 587
  259. MAIL_USE_SSL = True
  260. MAIL_USE_TLS = False
  261. MAIL_USERNAME = "services@unbl.ink"
  262. MAIL_PASSWORD = "{{services_unblink_email_pass}}"
  263. MAIL_DEBUG = False
  264. # Flask-Security overrides Flask-Mail's MAIL_DEFAULT_SENDER setting, so
  265. # that should be set as such:
  266. SECURITY_EMAIL_SENDER = "no-reply@localhost"
  267. ##########################################################################
  268. # Mail content settings
  269. ##########################################################################
  270. # These settings define the content of password reset emails
  271. SECURITY_EMAIL_SUBJECT_PASSWORD_RESET = "Password reset instructions for %s" % APP_NAME
  272. SECURITY_EMAIL_SUBJECT_PASSWORD_NOTICE = "Your %s password has been reset" % APP_NAME
  273. SECURITY_EMAIL_SUBJECT_PASSWORD_CHANGE_NOTICE = (
  274. "Your password for %s has been changed" % APP_NAME
  275. )
  276. ##########################################################################
  277. # Upgrade checks
  278. ##########################################################################
  279. # Check for new versions of the application?
  280. UPGRADE_CHECK_ENABLED = True
  281. # Where should we get the data from?
  282. UPGRADE_CHECK_URL = "https://www.pgadmin.org/versions.json"
  283. # What key should we look at in the upgrade data file?
  284. UPGRADE_CHECK_KEY = "pgadmin4"
  285. # Which CA file should we use?
  286. # Default to cacert.pem in the same directory as config.py et al.
  287. CA_FILE = os.path.join(os.path.dirname(os.path.realpath(__file__)), "cacert.pem")
  288. # Check if the detected browser is supported
  289. CHECK_SUPPORTED_BROWSER = False
  290. ##########################################################################
  291. # Storage Manager storage url config settings
  292. # If user sets STORAGE_DIR to empty it will show all volumes if platform
  293. # is Windows, '/' if it is Linux, Mac or any other unix type system.
  294. # For example:
  295. # 1. STORAGE_DIR = get_drive("C") or get_drive() # return C:/ by default
  296. # where C can be any drive character such as "D", "E", "G" etc
  297. # 2. Set path manually like
  298. # STORAGE_DIR = "/path/to/directory/"
  299. ##########################################################################
  300. STORAGE_DIR = os.path.join(DATA_DIR, "storage")
  301. ##########################################################################
  302. # Default locations for binary utilities (pg_dump, pg_restore etc)
  303. #
  304. # These are intentionally left empty in the main config file, but are
  305. # expected to be overridden by packagers in config_distro.py.
  306. #
  307. # A default location can be specified for each database driver ID, in
  308. # a dictionary. Either an absolute or relative path can be specified.
  309. # In cases where it may be difficult to know what the working directory
  310. # is, "$DIR" can be specified. This will be replaced with the path to the
  311. # top-level pgAdmin4.py file. For example, on macOS we might use:
  312. #
  313. # $DIR/../../SharedSupport
  314. #
  315. ##########################################################################
  316. DEFAULT_BINARY_PATHS = {"pg": "", "ppas": "", "gpdb": ""}
  317. ##########################################################################
  318. # Test settings - used primarily by the regression suite, not for users
  319. ##########################################################################
  320. # The default path for SQLite database for testing
  321. TEST_SQLITE_PATH = os.path.join(DATA_DIR, "test_pgadmin4.db")
  322. ##########################################################################
  323. # Allows flask application to response to the each request asynchronously
  324. ##########################################################################
  325. THREADED_MODE = True
  326. ##########################################################################
  327. # Do not allow SQLALCHEMY to track modification as it is going to be
  328. # deprecated in future
  329. ##########################################################################
  330. SQLALCHEMY_TRACK_MODIFICATIONS = False
  331. ##########################################################################
  332. # Number of records to fetch in one batch in query tool when query result
  333. # set is large.
  334. ##########################################################################
  335. ON_DEMAND_RECORD_COUNT = 1000
  336. ##########################################################################
  337. # Allow users to display Gravatar image for their username in Server mode
  338. ##########################################################################
  339. SHOW_GRAVATAR_IMAGE = True
  340. ##########################################################################
  341. # Set cookie path
  342. ##########################################################################
  343. COOKIE_DEFAULT_PATH = "/"
  344. COOKIE_DEFAULT_DOMAIN = None
  345. SESSION_COOKIE_DOMAIN = None
  346. SESSION_COOKIE_SAMESITE = "Lax"
  347. #########################################################################
  348. # Skip storing session in files and cache for specific paths
  349. #########################################################################
  350. SESSION_SKIP_PATHS = ["/misc/ping"]
  351. ##########################################################################
  352. # Session expiration support
  353. ##########################################################################
  354. # SESSION_EXPIRATION_TIME is the interval in Days. Session will be
  355. # expire after the specified number of *days*.
  356. SESSION_EXPIRATION_TIME = 1
  357. # CHECK_SESSION_FILES_INTERVAL is interval in Hours. Application will check
  358. # the session files for cleanup after specified number of *hours*.
  359. CHECK_SESSION_FILES_INTERVAL = 24
  360. # USER_INACTIVITY_TIMEOUT is interval in Seconds. If the pgAdmin screen is left
  361. # unattended for <USER_INACTIVITY_TIMEOUT> seconds then the user will
  362. # be logged out. When set to 0, the timeout will be disabled.
  363. # If pgAdmin doesn't detect any activity in the time specified (in seconds),
  364. # the user will be forcibly logged out from pgAdmin. Set to zero to disable
  365. # the timeout.
  366. # Note: This is applicable only for SERVER_MODE=True.
  367. USER_INACTIVITY_TIMEOUT = 0