default_config.py 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579
  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. GIT_FOLDER = os.path.join(
  114. os.path.abspath(os.path.dirname(__file__)), "..", "lcl", "repos"
  115. )
  116. # Folder containing the clones for the remote pull-requests
  117. REMOTE_GIT_FOLDER = os.path.join(
  118. os.path.abspath(os.path.dirname(__file__)), "..", "lcl", "remotes"
  119. )
  120. # Folder containing attachments
  121. ATTACHMENTS_FOLDER = os.path.join(
  122. os.path.abspath(os.path.dirname(__file__)), "..", "lcl", "attachments"
  123. )
  124. # Whether to enable scanning for viruses in attachments
  125. VIRUS_SCAN_ATTACHMENTS = False
  126. # Configuration keys to specify where the upload folder is and what is its
  127. # name
  128. UPLOAD_FOLDER_PATH = os.path.join(
  129. os.path.abspath(os.path.dirname(__file__)), "..", "lcl", "releases"
  130. )
  131. # Backend for git auth decisions
  132. GIT_AUTH_BACKEND = "pagure_authorized_keys"
  133. # Whether or not to run "git gc --auto" after every change to a project
  134. # This will use default git config values
  135. # See https://git-scm.com/docs/git-gc#git-gc---auto for more details
  136. GIT_GARBAGE_COLLECT = False
  137. # SMTP settings
  138. SMTP_SERVER = "localhost"
  139. SMTP_PORT = 25
  140. SMTP_SSL = False
  141. # Specify both for enabling SMTP auth
  142. SMTP_USERNAME = None
  143. SMTP_PASSWORD = None
  144. # Email used to sent emails
  145. FROM_EMAIL = "pagure@localhost.localdomain"
  146. DOMAIN_EMAIL_NOTIFICATIONS = "localhost.localdomain"
  147. SALT_EMAIL = "<secret key to be changed>"
  148. # Specify which authentication method to use.
  149. # Refer to
  150. # https://docs.pagure.org/pagure/configuration.html?highlight=authentication#pagure-auth
  151. # for information regarding authentication providers.
  152. # Available options: `fas`, `openid`, `oidc`, `local`
  153. # Default: ``local``.
  154. PAGURE_AUTH = "local"
  155. # If PAGURE_AUTH is set to 'oidc', the following variables must be set:
  156. # The path to JSON file with client secrets (provided by your IdP)
  157. # OIDC_CLIENT_SECRETS = 'client_secrets.json'
  158. # When this is set to True, the cookie with OpenID Connect Token will only
  159. # be returned to the server via ssl (https). If you connect to the server
  160. # via plain http, the cookie will not be sent. This prevents sniffing
  161. # of the cookie contents. This may be set to False when testing your
  162. # application but should always be set to True in production.
  163. # OIDC_ID_TOKEN_COOKIE_SECURE = False
  164. # OIDC_SCOPES = ['openid', 'email', 'profile']
  165. # These specify names of expected keys provided as userinfo by IdP.
  166. # They may vary across different IdPs
  167. # OIDC_PAGURE_EMAIL = 'email'
  168. # OIDC_PAGURE_FULLNAME = 'name'
  169. # OIDC_PAGURE_USERNAME = 'preferred_username'
  170. # OIDC_PAGURE_SSH_KEY = 'ssh_key'
  171. # OIDC_PAGURE_GROUPS = 'groups'
  172. # This specifies fallback for getting username assuming OIDC_PAGURE_USERNAME
  173. # is empty - can be `email` (to use the part before `@`) or `sub`
  174. # (IdP-specific user id, can be a nickname, email or a numeric ID
  175. # depending on IdP).
  176. # OIDC_PAGURE_USERNAME_FALLBACK = 'email'
  177. #
  178. # More settings for OIDC are available from flask-oidc at:
  179. # http://flask-oidc.readthedocs.io/en/latest/#settings-reference
  180. # When this is set to True, the session cookie will only be returned to the
  181. # server via ssl (https). If you connect to the server via plain http, the
  182. # cookie will not be sent. This prevents sniffing of the cookie contents.
  183. # This may be set to False when testing your application but should always
  184. # be set to True in production.
  185. # Default: ``True``.
  186. SESSION_COOKIE_SECURE = False
  187. SESSION_COOKIE_NAME = "pagure"
  188. # Boolean specifying whether to check the user's IP address when retrieving
  189. # its session. This make things more secure (thus is on by default) but
  190. # under certain setup it might not work (for example is there are proxies
  191. # in front of the application).
  192. CHECK_SESSION_IP = True
  193. # Lenght for short commits ids or file hex
  194. SHORT_LENGTH = 7
  195. # Used by SESSION_COOKIE_PATH
  196. APPLICATION_ROOT = "/"
  197. # List of blacklisted project names
  198. BLACKLISTED_PROJECTS = [
  199. "static",
  200. "pv",
  201. "releases",
  202. "new",
  203. "api",
  204. "settings",
  205. "search",
  206. "fork",
  207. "logout",
  208. "login",
  209. "user",
  210. "users",
  211. "groups",
  212. "projects",
  213. "ssh_info",
  214. "issues",
  215. "pull-requests",
  216. "commits",
  217. "tree",
  218. "forks",
  219. "admin",
  220. "c",
  221. "wait",
  222. "dashboard",
  223. "docs/*",
  224. "tickets/*",
  225. "requests/*",
  226. ]
  227. # List of prefix allowed in project names
  228. ALLOWED_PREFIX = []
  229. # List of blacklisted group names
  230. BLACKLISTED_GROUPS = ["forks", "group"]
  231. ACLS = {
  232. "create_branch": "Create a git branch on a project",
  233. "create_project": "Create a new project",
  234. "commit_flag": "Flag a commit",
  235. "fork_project": "Fork a project",
  236. "internal_access": "Access Pagure's internal APIs",
  237. "issue_assign": "Assign issue to someone",
  238. "issue_change_status": "Change the status of a ticket",
  239. "issue_comment": "Comment on a ticket",
  240. "issue_create": "Create a new ticket",
  241. "issue_subscribe": "Subscribe the user with this token to an issue",
  242. "issue_update": "Update an issue, status, comments, custom fields...",
  243. "issue_update_custom_fields": "Update the custom fields of an issue",
  244. "issue_update_milestone": "Update the milestone of an issue",
  245. "modify_project": "Modify an existing project",
  246. "pull_request_create": "Open a new pull-request",
  247. "pull_request_close": "Close a pull-request",
  248. "pull_request_comment": "Comment on a pull-request",
  249. "pull_request_flag": "Flag a pull-request",
  250. "pull_request_merge": "Merge a pull-request",
  251. "pull_request_subscribe": (
  252. "Subscribe the user with this token to a pull-request"
  253. ),
  254. "pull_request_assign": "Assign someone to a pull-request",
  255. "pull_request_update": (
  256. "Update a pull-request (title, description, assignee...)"
  257. ),
  258. "update_watch_status": "Update the watch status on a project",
  259. "pull_request_rebase": "Rebase a pull-request",
  260. "tag_project": "Allows adding git tags to a project",
  261. "commit": "Commit to a git repository via http(s)",
  262. "modify_git_alias": "Modify git aliases (create or delete)",
  263. "create_git_alias": "Create git aliases",
  264. "delete_git_alias": "Delete git aliases",
  265. "group_modify": "Add/Remove members from group",
  266. }
  267. # List of ACLs which a regular user is allowed to associate to an API token
  268. # from the ACLs above
  269. USER_ACLS = [key for key in ACLS.keys() if key not in ["internal_access"]]
  270. # From the ACLs above lists which ones are tolerated to be associated with
  271. # an API token that isn't linked to a particular project.
  272. CROSS_PROJECT_ACLS = [
  273. "create_project",
  274. "fork_project",
  275. "modify_project",
  276. "group_modify",
  277. "update_watch_status",
  278. "pull_request_create",
  279. "pull_request_update",
  280. "commit",
  281. ]
  282. # ACLs with which admins are allowed to create project-less API tokens
  283. ADMIN_API_ACLS = [
  284. "internal_access",
  285. "issue_comment",
  286. "issue_create",
  287. "issue_change_status",
  288. "pull_request_flag",
  289. "pull_request_comment",
  290. "pull_request_merge",
  291. "group_modify",
  292. "commit_flag",
  293. "create_branch",
  294. "tag_project",
  295. ]
  296. # List of the type of CI service supported by this pagure instance
  297. PAGURE_CI_SERVICES = []
  298. # Boolean to turn on project being by default in the user's namespace
  299. USER_NAMESPACE = False
  300. # List of groups whose projects should not be shown on the user's info page
  301. # unless the user has direct access to it.
  302. EXCLUDE_GROUP_INDEX = []
  303. TRIGGER_CI = {
  304. "pretty please pagure-ci rebuild": {
  305. "name": "Default CI",
  306. "description": "Rerun default CI",
  307. "requires_project_hook_attr": ("ci_hook", "active_pr", True),
  308. }
  309. }
  310. FLAG_STATUSES_LABELS = {
  311. "success": "badge-success",
  312. "failure": "badge-danger",
  313. "error": "badge-danger",
  314. "pending": "badge-info",
  315. "canceled": "badge-warning",
  316. }
  317. FLAG_SUCCESS = "success"
  318. FLAG_FAILURE = "failure"
  319. FLAG_PENDING = "pending"
  320. # Never enable this option, this is intended for tests only, and can allow
  321. # easy denial of service to the system if enabled.
  322. ALLOW_PROJECT_DOWAIT = False
  323. # Settings for MQTT message sending
  324. MQTT_NOTIFICATIONS = False
  325. MQTT_HOST = None
  326. MQTT_PORT = None
  327. MQTT_USERNAME = None
  328. MQTT_PASSWORD = None
  329. MQTT_CA_CERTS = None
  330. MQTT_CERTFILE = None
  331. MQTT_KEYFILE = None
  332. MQTT_CIPHERS = None
  333. # Settings for Stomp message sending
  334. STOMP_NOTIFICATIONS = False
  335. STOMP_BROKERS = []
  336. STOMP_SSL = False
  337. STOMP_KEY_FILE = None
  338. STOMP_CERT_FILE = None
  339. STOMP_CREDS_PASSWORD = None
  340. STOMP_HIERARCHY = None
  341. LOGGING = {
  342. "version": 1,
  343. "disable_existing_loggers": False,
  344. "formatters": {
  345. "standard": {
  346. "format": "%(asctime)s [%(levelname)s] %(name)s: %(message)s"
  347. },
  348. "email_format": {"format": MSG_FORMAT},
  349. },
  350. "filters": {"myfilter": {"()": ContextInjector}},
  351. "handlers": {
  352. "console": {
  353. "formatter": "standard",
  354. "class": "logging.StreamHandler",
  355. "stream": "ext://sys.stdout",
  356. },
  357. "auth_handler": {
  358. "formatter": "standard",
  359. "class": "logging.StreamHandler",
  360. "stream": "ext://sys.stdout",
  361. },
  362. "email": {
  363. "level": "ERROR",
  364. "formatter": "email_format",
  365. "class": "logging.handlers.SMTPHandler",
  366. "mailhost": "localhost",
  367. "fromaddr": "pagure@localhost",
  368. "toaddrs": "root@localhost",
  369. "subject": "ERROR on pagure",
  370. "filters": ["myfilter"],
  371. },
  372. },
  373. # The root logger configuration; this is a catch-all configuration
  374. # that applies to all log messages not handled by a different logger
  375. "root": {"level": "INFO", "handlers": ["console"]},
  376. "loggers": {
  377. "pagure": {
  378. "handlers": ["console"],
  379. "level": "DEBUG",
  380. "propagate": True,
  381. },
  382. "pagure_auth": {
  383. "handlers": ["auth_handler"],
  384. "level": "DEBUG",
  385. "propagate": False,
  386. },
  387. "flask": {
  388. "handlers": ["console"],
  389. "level": "INFO",
  390. "propagate": False,
  391. },
  392. "sqlalchemy": {
  393. "handlers": ["console"],
  394. "level": "WARN",
  395. "propagate": False,
  396. },
  397. "binaryornot": {
  398. "handlers": ["console"],
  399. "level": "WARN",
  400. "propagate": True,
  401. },
  402. "MARKDOWN": {
  403. "handlers": ["console"],
  404. "level": "WARN",
  405. "propagate": True,
  406. },
  407. "PIL": {"handlers": ["console"], "level": "WARN", "propagate": True},
  408. "chardet": {
  409. "handlers": ["console"],
  410. "level": "WARN",
  411. "propagate": True,
  412. },
  413. "pagure.lib.encoding_utils": {
  414. "handlers": ["console"],
  415. "level": "WARN",
  416. "propagate": False,
  417. },
  418. },
  419. }
  420. # Gives commit access to all, all but some or just some project based on
  421. # groups provided by the auth system.
  422. EXTERNAL_COMMITTER = {}
  423. # Allows to require that the users are members of a certain group to be added
  424. # to a project (not a fork).
  425. REQUIRED_GROUPS = {}
  426. # Predefined reactions. Selecting others is possible by typing their name. The
  427. # order here will be preserved in the web UI picker for reactions.
  428. REACTIONS = [
  429. ("Thumbs up", "emojione-1F44D"), # Thumbs up
  430. ("Thumbs down", "emojione-1F44E"), # Thumbs down
  431. ("Confused", "emojione-1F615"), # Confused
  432. ("Heart", "emojione-2764"), # Heart
  433. ]
  434. # This is used for faster indexing. Do not change.
  435. _REACTIONS_DICT = dict(REACTIONS)
  436. # HTTP pull/push options
  437. # Whether to allow Git HTTP proxying
  438. ALLOW_HTTP_PULL_PUSH = True
  439. # Whether to allow pushing via HTTP
  440. ALLOW_HTTP_PUSH = False
  441. # Configuration for the key helper
  442. # Look a username up in the database, overrides SSH_KEYS_USERNAME_EXPECT
  443. SSH_KEYS_USERNAME_LOOKUP = False
  444. # Except certain usernames from being used via the keyhelper
  445. SSH_KEYS_USERNAME_FORBIDDEN = ["root"]
  446. # Username to expect for ssh. Set to None to disallow any access
  447. SSH_KEYS_USERNAME_EXPECT = None
  448. # Arguments to add to the SSH keys, possible replacements:
  449. # %(username)s: username owning this key
  450. SSH_KEYS_OPTIONS = (
  451. 'restrict,command="/usr/libexec/pagure/aclchecker.py %(username)s"'
  452. )
  453. # If not set to None, aclchecker and keyhelper will use this api admin
  454. # token to get authorized to internal endpoints that they use. The token
  455. # must have the internal_access ACL.
  456. SSH_ADMIN_TOKEN = None
  457. # ACL Checker options
  458. SSH_COMMAND = (
  459. [
  460. "/usr/bin/%(cmd)s",
  461. os.path.join(GIT_FOLDER, "%(reponame)s"),
  462. ],
  463. {"GL_USER": "%(username)s"},
  464. )
  465. CSP_HEADERS = (
  466. "default-src 'self';"
  467. "script-src 'self' '{nonce_script}'; "
  468. "style-src 'self' '{nonce_style}'; "
  469. "object-src 'none';"
  470. "base-uri 'self';"
  471. "img-src 'self' https:;"
  472. )
  473. PR_WARN_CHARACTERS = set(
  474. [
  475. chr(0x202A),
  476. chr(0x202B),
  477. chr(0x202C),
  478. chr(0x202D),
  479. chr(0x202E),
  480. chr(0x2066),
  481. chr(0x2067),
  482. chr(0x2068),
  483. chr(0x2069),
  484. ]
  485. )