default_config.py 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619
  1. # -*- coding: utf-8 -*-
  2. """
  3. (c) 2014-2015 - Copyright Red Hat Inc
  4. Authors:
  5. Pierre-Yves Chibon <pingou@pingoured.fr>
  6. """
  7. from __future__ import absolute_import, unicode_literals
  8. import os
  9. from datetime import timedelta
  10. from pagure.mail_logging import MSG_FORMAT, ContextInjector # noqa: I101
  11. # Set the time after which the admin session expires
  12. ADMIN_SESSION_LIFETIME = timedelta(minutes=20)
  13. # secret key used to generate unique csrf token
  14. SECRET_KEY = str("<insert here your own key>")
  15. # url to the database server:
  16. DB_URL = "sqlite:////var/tmp/pagure_dev.sqlite"
  17. # Name the instance, used in the welcome screen upon first login (not
  18. # working with `local` auth)
  19. INSTANCE_NAME = "Pagure"
  20. # Provide an email to contact an instance Administrator
  21. ADMIN_EMAIL = "root@localhost.localdomain"
  22. # url to datagrepper (optional):
  23. # DATAGREPPER_URL = 'https://apps.fedoraproject.org/datagrepper'
  24. # DATAGREPPER_CATEGORY = 'pagure'
  25. # Send FedMsg notifications of events in pagure
  26. FEDMSG_NOTIFICATIONS = False
  27. # The FAS group in which the admin of pagure are
  28. ADMIN_GROUP = "sysadmin-main"
  29. # Hard-code a list of users that are global admins
  30. PAGURE_ADMIN_USERS = []
  31. # Whether or not to send emails
  32. EMAIL_SEND = False
  33. # The email address to which the flask.log will send the errors (tracebacks)
  34. EMAIL_ERROR = "root@localhost.localdomain"
  35. # The URL at which the project is available.
  36. APP_URL = "http://localhost.localdomain/"
  37. # Enables / Disables tickets for project for the entire pagure instance
  38. ENABLE_TICKETS = True
  39. # Enables / Disables docs for project for the entire pagure instance
  40. ENABLE_DOCS = True
  41. # Enables / Disables creating projects on this pagure instance
  42. ENABLE_NEW_PROJECTS = True
  43. # When using OIDC auth, users must be in this OIDC group to create new projects
  44. RESTRICT_CREATE_BY_OIDC_GROUP = None
  45. # When using OIDC auth, users must be a member of
  46. # RESTRICT_NEW_PROJECTS_BY_OIDC_GROUP and in total
  47. # this many groups to create new projects
  48. RESTRICT_CREATE_BY_OIDC_GROUP_COUNT = 0
  49. # Enables / Disables deleting projects on this pagure instance
  50. ENABLE_DEL_PROJECTS = True
  51. # Enables / Disables giving projects on this pagure instance
  52. ENABLE_GIVE_PROJECTS = True
  53. # Enables / Disables managing access to the repos
  54. ENABLE_USER_MNGT = True
  55. # Enables / Disables managing groups via the UI
  56. ENABLE_GROUP_MNGT = True
  57. # Enables / Disables private projects
  58. PRIVATE_PROJECTS = True
  59. # Enable / Disable user registration (local auth only)
  60. ALLOW_USER_REGISTRATION = True
  61. # Enable / Disable deleting branches in the UI
  62. ALLOW_DELETE_BRANCH = True
  63. # Allow admins to ignore existing repos when creating a new project
  64. ALLOW_ADMIN_IGNORE_EXISTING_REPOS = False
  65. # List of users that can ignore existing repos when creating a new project
  66. USERS_IGNORE_EXISTING_REPOS = []
  67. # Enable / Disable having pagure manage the user's ssh keys
  68. LOCAL_SSH_KEY = True
  69. # Enable / Disable deploy keys
  70. DEPLOY_KEY = True
  71. # Set to True if default target branch for all PRs in UI
  72. # should be the branch that is longest substring of the branch
  73. # that the PR is to be created from
  74. PR_TARGET_MATCHING_BRANCH = False
  75. # Enables / Disables showing all the projects by default on the front page
  76. SHOW_PROJECTS_INDEX = ["repos", "myrepos", "myforks"]
  77. # The URL to use to clone the git repositories.
  78. GIT_URL_SSH = "ssh://git@localhost.localdomain/"
  79. GIT_URL_GIT = "git://localhost.localdomain/"
  80. # Set to True if git ssh URLs should be displayed even if user
  81. # doesn't have SSH key uploaded
  82. ALWAYS_RENDER_SSH_CLONE_URL = False
  83. # Default queue names for the different services
  84. WEBHOOK_CELERY_QUEUE = "pagure_webhook"
  85. LOGCOM_CELERY_QUEUE = "pagure_logcom"
  86. LOADJSON_CELERY_QUEUE = "pagure_loadjson"
  87. CI_CELERY_QUEUE = "pagure_ci"
  88. MIRRORING_QUEUE = "pagure_mirror"
  89. # Number of items displayed per page
  90. ITEM_PER_PAGE = 48
  91. # Maximum size of the uploaded content
  92. MAX_CONTENT_LENGTH = 4 * 1024 * 1024 # 4 megabytes
  93. # IP addresses allowed to access the internal endpoints
  94. IP_ALLOWED_INTERNAL = ["127.0.0.1", "localhost", "::1"]
  95. # Worker configuration
  96. CELERY_CONFIG = {}
  97. # Redis configuration
  98. EVENTSOURCE_SOURCE = None
  99. WEBHOOK = False
  100. REDIS_HOST = "0.0.0.0"
  101. REDIS_PORT = 6379
  102. REDIS_DB = 0
  103. EVENTSOURCE_PORT = 8080
  104. # Disallow remote pull requests
  105. DISABLE_REMOTE_PR = False
  106. # Folder where to place the ssh keys for the mirroring feature
  107. MIRROR_SSHKEYS_FOLDER = "/var/lib/pagure/sshkeys/"
  108. # Folder containing the pagure user SSH authorized keys
  109. SSH_FOLDER = os.path.join(
  110. os.path.abspath(os.path.dirname(__file__)), "..", "lcl", ".ssh"
  111. )
  112. # Folder containing to the git repos
  113. # Note that this must be exactly the same as GL_REPO_BASE in gitolite.rc
  114. GIT_FOLDER = os.path.join(
  115. os.path.abspath(os.path.dirname(__file__)), "..", "lcl", "repos"
  116. )
  117. # Folder containing the clones for the remote pull-requests
  118. REMOTE_GIT_FOLDER = os.path.join(
  119. os.path.abspath(os.path.dirname(__file__)), "..", "lcl", "remotes"
  120. )
  121. # Folder containing attachments
  122. ATTACHMENTS_FOLDER = os.path.join(
  123. os.path.abspath(os.path.dirname(__file__)), "..", "lcl", "attachments"
  124. )
  125. # Whether to enable scanning for viruses in attachments
  126. VIRUS_SCAN_ATTACHMENTS = False
  127. # Configuration file for gitolite
  128. GITOLITE_CONFIG = os.path.join(
  129. os.path.abspath(os.path.dirname(__file__)), "..", "lcl", "gitolite.conf"
  130. )
  131. # Configuration keys to specify where the upload folder is and what is its
  132. # name
  133. UPLOAD_FOLDER_PATH = os.path.join(
  134. os.path.abspath(os.path.dirname(__file__)), "..", "lcl", "releases"
  135. )
  136. # Home folder of the gitolite user -- Folder where to run gl-compile-conf from
  137. GITOLITE_HOME = None
  138. # Version of gitolite used: 2 or 3?
  139. GITOLITE_VERSION = 3
  140. # Folder containing all the public ssh keys for gitolite
  141. GITOLITE_KEYDIR = None
  142. # Backend for git auth decisions
  143. # This may be either a static helper (like gitolite based) or dynamic.
  144. GIT_AUTH_BACKEND = "pagure_authorized_keys"
  145. # Legacy option name for GIT_AUTH_BACKEND, retained for backwards compatibility
  146. # This option overrides GIT_AUTH_BACKEND
  147. # GITOLITE_BACKEND = "gitolite3"
  148. # Whether or not this installation of Pagure should use `gitolite compile-1`
  149. # to improve speed of some gitolite operations. See documentation for more
  150. # info about how to set this up.
  151. GITOLITE_HAS_COMPILE_1 = False
  152. # Path to the gitolite.rc file
  153. GL_RC = None
  154. # Path to the /bin directory where the gitolite tools can be found
  155. GL_BINDIR = None
  156. # Whether or not to run "git gc --auto" after every change to a project
  157. # This will use default git config values
  158. # See https://git-scm.com/docs/git-gc#git-gc---auto for more details
  159. GIT_GARBAGE_COLLECT = False
  160. # SMTP settings
  161. SMTP_SERVER = "localhost"
  162. SMTP_PORT = 25
  163. SMTP_SSL = False
  164. # Specify both for enabling SMTP auth
  165. SMTP_USERNAME = None
  166. SMTP_PASSWORD = None
  167. # Email used to sent emails
  168. FROM_EMAIL = "pagure@localhost.localdomain"
  169. DOMAIN_EMAIL_NOTIFICATIONS = "localhost.localdomain"
  170. SALT_EMAIL = "<secret key to be changed>"
  171. # Specify which authentication method to use.
  172. # Refer to
  173. # https://docs.pagure.org/pagure/configuration.html?highlight=authentication#pagure-auth
  174. # for information regarding authentication providers.
  175. # Available options: `fas`, `openid`, `oidc`, `local`
  176. # Default: ``local``.
  177. PAGURE_AUTH = "local"
  178. # If PAGURE_AUTH is set to 'oidc', the following variables must be set:
  179. # The path to JSON file with client secrets (provided by your IdP)
  180. # OIDC_CLIENT_SECRETS = 'client_secrets.json'
  181. # When this is set to True, the cookie with OpenID Connect Token will only
  182. # be returned to the server via ssl (https). If you connect to the server
  183. # via plain http, the cookie will not be sent. This prevents sniffing
  184. # of the cookie contents. This may be set to False when testing your
  185. # application but should always be set to True in production.
  186. # OIDC_ID_TOKEN_COOKIE_SECURE = False
  187. # OIDC_SCOPES = ['openid', 'email', 'profile']
  188. # These specify names of expected keys provided as userinfo by IdP.
  189. # They may vary across different IdPs
  190. # OIDC_PAGURE_EMAIL = 'email'
  191. # OIDC_PAGURE_FULLNAME = 'name'
  192. # OIDC_PAGURE_USERNAME = 'preferred_username'
  193. # OIDC_PAGURE_SSH_KEY = 'ssh_key'
  194. # OIDC_PAGURE_GROUPS = 'groups'
  195. # This specifies fallback for getting username assuming OIDC_PAGURE_USERNAME
  196. # is empty - can be `email` (to use the part before `@`) or `sub`
  197. # (IdP-specific user id, can be a nickname, email or a numeric ID
  198. # depending on IdP).
  199. # OIDC_PAGURE_USERNAME_FALLBACK = 'email'
  200. #
  201. # More settings for OIDC are available from flask-oidc at:
  202. # http://flask-oidc.readthedocs.io/en/latest/#settings-reference
  203. # When this is set to True, the session cookie will only be returned to the
  204. # server via ssl (https). If you connect to the server via plain http, the
  205. # cookie will not be sent. This prevents sniffing of the cookie contents.
  206. # This may be set to False when testing your application but should always
  207. # be set to True in production.
  208. # Default: ``True``.
  209. SESSION_COOKIE_SECURE = False
  210. SESSION_COOKIE_NAME = "pagure"
  211. # Boolean specifying whether to check the user's IP address when retrieving
  212. # its session. This make things more secure (thus is on by default) but
  213. # under certain setup it might not work (for example is there are proxies
  214. # in front of the application).
  215. CHECK_SESSION_IP = True
  216. # Lenght for short commits ids or file hex
  217. SHORT_LENGTH = 7
  218. # Used by SESSION_COOKIE_PATH
  219. APPLICATION_ROOT = "/"
  220. # List of blacklisted project names
  221. BLACKLISTED_PROJECTS = [
  222. "static",
  223. "pv",
  224. "releases",
  225. "new",
  226. "api",
  227. "settings",
  228. "search",
  229. "fork",
  230. "logout",
  231. "login",
  232. "user",
  233. "users",
  234. "groups",
  235. "projects",
  236. "ssh_info",
  237. "issues",
  238. "pull-requests",
  239. "commits",
  240. "tree",
  241. "forks",
  242. "admin",
  243. "c",
  244. "wait",
  245. "dashboard",
  246. "docs/*",
  247. "tickets/*",
  248. "requests/*",
  249. ]
  250. # List of prefix allowed in project names
  251. ALLOWED_PREFIX = []
  252. # List of blacklisted group names
  253. BLACKLISTED_GROUPS = ["forks", "group"]
  254. ACLS = {
  255. "create_branch": "Create a git branch on a project",
  256. "create_project": "Create a new project",
  257. "commit_flag": "Flag a commit",
  258. "fork_project": "Fork a project",
  259. "generate_acls_project": "Generate the Gitolite ACLs on a project",
  260. "internal_access": "Access Pagure's internal APIs",
  261. "issue_assign": "Assign issue to someone",
  262. "issue_change_status": "Change the status of a ticket",
  263. "issue_comment": "Comment on a ticket",
  264. "issue_create": "Create a new ticket",
  265. "issue_subscribe": "Subscribe the user with this token to an issue",
  266. "issue_update": "Update an issue, status, comments, custom fields...",
  267. "issue_update_custom_fields": "Update the custom fields of an issue",
  268. "issue_update_milestone": "Update the milestone of an issue",
  269. "modify_project": "Modify an existing project",
  270. "pull_request_create": "Open a new pull-request",
  271. "pull_request_close": "Close a pull-request",
  272. "pull_request_comment": "Comment on a pull-request",
  273. "pull_request_flag": "Flag a pull-request",
  274. "pull_request_merge": "Merge a pull-request",
  275. "pull_request_subscribe": (
  276. "Subscribe the user with this token to a pull-request"
  277. ),
  278. "pull_request_assign": "Assign someone to a pull-request",
  279. "pull_request_update": (
  280. "Update a pull-request (title, description, assignee...)"
  281. ),
  282. "update_watch_status": "Update the watch status on a project",
  283. "pull_request_rebase": "Rebase a pull-request",
  284. "tag_project": "Allows adding git tags to a project",
  285. "commit": "Commit to a git repository via http(s)",
  286. "modify_git_alias": "Modify git aliases (create or delete)",
  287. "create_git_alias": "Create git aliases",
  288. "delete_git_alias": "Delete git aliases",
  289. "group_modify": "Add/Remove members from group",
  290. }
  291. # List of ACLs which a regular user is allowed to associate to an API token
  292. # from the ACLs above
  293. USER_ACLS = [
  294. key
  295. for key in ACLS.keys()
  296. if key not in ["generate_acls_project", "internal_access"]
  297. ]
  298. # From the ACLs above lists which ones are tolerated to be associated with
  299. # an API token that isn't linked to a particular project.
  300. CROSS_PROJECT_ACLS = [
  301. "create_project",
  302. "fork_project",
  303. "modify_project",
  304. "group_modify",
  305. "update_watch_status",
  306. "pull_request_create",
  307. "pull_request_update",
  308. "commit",
  309. ]
  310. # ACLs with which admins are allowed to create project-less API tokens
  311. ADMIN_API_ACLS = [
  312. "internal_access",
  313. "issue_comment",
  314. "issue_create",
  315. "issue_change_status",
  316. "pull_request_flag",
  317. "pull_request_comment",
  318. "pull_request_merge",
  319. "generate_acls_project",
  320. "group_modify",
  321. "commit_flag",
  322. "create_branch",
  323. "tag_project",
  324. ]
  325. # List of the type of CI service supported by this pagure instance
  326. PAGURE_CI_SERVICES = []
  327. # Boolean to turn on project being by default in the user's namespace
  328. USER_NAMESPACE = False
  329. # List of groups whose projects should not be shown on the user's info page
  330. # unless the user has direct access to it.
  331. EXCLUDE_GROUP_INDEX = []
  332. TRIGGER_CI = {
  333. "pretty please pagure-ci rebuild": {
  334. "name": "Default CI",
  335. "description": "Rerun default CI",
  336. "requires_project_hook_attr": ("ci_hook", "active_pr", True),
  337. }
  338. }
  339. FLAG_STATUSES_LABELS = {
  340. "success": "badge-success",
  341. "failure": "badge-danger",
  342. "error": "badge-danger",
  343. "pending": "badge-info",
  344. "canceled": "badge-warning",
  345. }
  346. FLAG_SUCCESS = "success"
  347. FLAG_FAILURE = "failure"
  348. FLAG_PENDING = "pending"
  349. # Never enable this option, this is intended for tests only, and can allow
  350. # easy denial of service to the system if enabled.
  351. ALLOW_PROJECT_DOWAIT = False
  352. # Settings for MQTT message sending
  353. MQTT_NOTIFICATIONS = False
  354. MQTT_HOST = None
  355. MQTT_PORT = None
  356. MQTT_USERNAME = None
  357. MQTT_PASSWORD = None
  358. MQTT_CA_CERTS = None
  359. MQTT_CERTFILE = None
  360. MQTT_KEYFILE = None
  361. MQTT_CIPHERS = None
  362. # Settings for Stomp message sending
  363. STOMP_NOTIFICATIONS = False
  364. STOMP_BROKERS = []
  365. STOMP_SSL = False
  366. STOMP_KEY_FILE = None
  367. STOMP_CERT_FILE = None
  368. STOMP_CREDS_PASSWORD = None
  369. STOMP_HIERARCHY = None
  370. LOGGING = {
  371. "version": 1,
  372. "disable_existing_loggers": False,
  373. "formatters": {
  374. "standard": {
  375. "format": "%(asctime)s [%(levelname)s] %(name)s: %(message)s"
  376. },
  377. "email_format": {"format": MSG_FORMAT},
  378. },
  379. "filters": {"myfilter": {"()": ContextInjector}},
  380. "handlers": {
  381. "console": {
  382. "formatter": "standard",
  383. "class": "logging.StreamHandler",
  384. "stream": "ext://sys.stdout",
  385. },
  386. "auth_handler": {
  387. "formatter": "standard",
  388. "class": "logging.StreamHandler",
  389. "stream": "ext://sys.stdout",
  390. },
  391. "email": {
  392. "level": "ERROR",
  393. "formatter": "email_format",
  394. "class": "logging.handlers.SMTPHandler",
  395. "mailhost": "localhost",
  396. "fromaddr": "pagure@localhost",
  397. "toaddrs": "root@localhost",
  398. "subject": "ERROR on pagure",
  399. "filters": ["myfilter"],
  400. },
  401. },
  402. # The root logger configuration; this is a catch-all configuration
  403. # that applies to all log messages not handled by a different logger
  404. "root": {"level": "INFO", "handlers": ["console"]},
  405. "loggers": {
  406. "pagure": {
  407. "handlers": ["console"],
  408. "level": "DEBUG",
  409. "propagate": True,
  410. },
  411. "pagure_auth": {
  412. "handlers": ["auth_handler"],
  413. "level": "DEBUG",
  414. "propagate": False,
  415. },
  416. "flask": {
  417. "handlers": ["console"],
  418. "level": "INFO",
  419. "propagate": False,
  420. },
  421. "sqlalchemy": {
  422. "handlers": ["console"],
  423. "level": "WARN",
  424. "propagate": False,
  425. },
  426. "binaryornot": {
  427. "handlers": ["console"],
  428. "level": "WARN",
  429. "propagate": True,
  430. },
  431. "MARKDOWN": {
  432. "handlers": ["console"],
  433. "level": "WARN",
  434. "propagate": True,
  435. },
  436. "PIL": {"handlers": ["console"], "level": "WARN", "propagate": True},
  437. "chardet": {
  438. "handlers": ["console"],
  439. "level": "WARN",
  440. "propagate": True,
  441. },
  442. "pagure.lib.encoding_utils": {
  443. "handlers": ["console"],
  444. "level": "WARN",
  445. "propagate": False,
  446. },
  447. },
  448. }
  449. # Gives commit access to all, all but some or just some project based on
  450. # groups provided by the auth system.
  451. EXTERNAL_COMMITTER = {}
  452. # Allows to require that the users are members of a certain group to be added
  453. # to a project (not a fork).
  454. REQUIRED_GROUPS = {}
  455. # Predefined reactions. Selecting others is possible by typing their name. The
  456. # order here will be preserved in the web UI picker for reactions.
  457. REACTIONS = [
  458. ("Thumbs up", "emojione-1F44D"), # Thumbs up
  459. ("Thumbs down", "emojione-1F44E"), # Thumbs down
  460. ("Confused", "emojione-1F615"), # Confused
  461. ("Heart", "emojione-2764"), # Heart
  462. ]
  463. # This is used for faster indexing. Do not change.
  464. _REACTIONS_DICT = dict(REACTIONS)
  465. # HTTP pull/push options
  466. # Whether to allow Git HTTP proxying
  467. ALLOW_HTTP_PULL_PUSH = True
  468. # Whether to allow pushing via HTTP
  469. ALLOW_HTTP_PUSH = False
  470. # Path to Gitolite-shell if using that, None to use Git directly
  471. HTTP_REPO_ACCESS_GITOLITE = None
  472. # Configuration for the key helper
  473. # Look a username up in the database, overrides SSH_KEYS_USERNAME_EXPECT
  474. SSH_KEYS_USERNAME_LOOKUP = False
  475. # Except certain usernames from being used via the keyhelper
  476. SSH_KEYS_USERNAME_FORBIDDEN = ["root"]
  477. # Username to expect for ssh. Set to None to disallow any access
  478. SSH_KEYS_USERNAME_EXPECT = None
  479. # Arguments to add to the SSH keys, possible replacements:
  480. # %(username)s: username owning this key
  481. SSH_KEYS_OPTIONS = (
  482. 'restrict,command="/usr/libexec/pagure/aclchecker.py %(username)s"'
  483. )
  484. # If not set to None, aclchecker and keyhelper will use this api admin
  485. # token to get authorized to internal endpoints that they use. The token
  486. # must have the internal_access ACL.
  487. SSH_ADMIN_TOKEN = None
  488. # ACL Checker options
  489. SSH_COMMAND = (
  490. [
  491. "/usr/bin/%(cmd)s",
  492. os.path.join(GIT_FOLDER, "%(reponame)s"),
  493. ],
  494. {"GL_USER": "%(username)s"},
  495. )
  496. CSP_HEADERS = (
  497. "default-src 'self';"
  498. "script-src 'self' '{nonce_script}'; "
  499. "style-src 'self' '{nonce_style}'; "
  500. "object-src 'none';"
  501. "base-uri 'self';"
  502. "img-src 'self' https:;"
  503. )
  504. PR_WARN_CHARACTERS = set(
  505. [
  506. chr(0x202A),
  507. chr(0x202B),
  508. chr(0x202C),
  509. chr(0x202D),
  510. chr(0x202E),
  511. chr(0x2066),
  512. chr(0x2067),
  513. chr(0x2068),
  514. chr(0x2069),
  515. ]
  516. )