Skip to content

Configuration

SourceLab offers a wide varieties of options that must or can be used to adjust its behavior.

All of these options can be edited or added to your configuration file. If you have installed SourceLab, this configuration file is likely located in /etc/sourcelab/sourcelab.cfg. Otherwise, it will depend on your setup/deployment.

Must options

Here are the options you must set up in order to get SourceLab running.

SECRET_KEY

This configuration key signs the session cookie of the web interface, and is the key NeoZen hashes the tokens of the login sessions and of the emailed links with. It should be kept secret and set as a long and random string. Changing it logs everyone out and voids the links already sent.

SALT_EMAIL

This configuration key is used to ensure that when sending notifications to different users, each one of them has a different, unique and unfakeable Reply-To header. This header is then used by the milter to find out if the response received is a real one or a fake/invalid one.

DB_URL

This configuration key indicates to the framework how and where to connect to the database server. SourceLab runs on PostgreSQL, or on SQLite for an installation that runs in one process. It connects through SQLAlchemy, and to PostgreSQL with psycopg 3 (install the postgresql extra), so name that driver in the URL.

Examples values:

DB_URL = 'postgresql+psycopg://user:pass@host/db_name'
DB_URL = 'sqlite:////var/tmp/sourcelab_dev.sqlite'

On SQLite, SourceLab opens the database in WAL mode with a busy timeout of 5 seconds, since its background jobs write to the same file.

Defaults to sqlite:////var/tmp/sourcelab_dev.sqlite

APP_URL

This configuration key indicates the URL at which this SourceLab instance will be made available.

Defaults to: http://localhost.localdomain/

EMAIL_ERROR

SourceLab sends email when it catches an unexpected error (which saves you from having to monitor the logs regularly; but if you like, the error is still present in the logs). This configuration key allows you to specify to which email address to send these error reports.

GIT_URL_SSH

This configuration key tells users how to clone the git repos hosted on SourceLab via SSH.

The URL should end with a slash /.

Defaults to: 'ssh://git@llocalhost.localdomain/'

Note

If you are using a custom setup for your deployment where every user has an account on the machine you may want to tweak this URL to include the username. If that is the case, you can use {username} in the URL and it will be expanded to the username of the user viewing the page when rendered. For example: 'ssh://{username}@pagure.org/'

GIT_URL_GIT

This configuration key tells users how to clone the git repos hosted on SourceLab anonymously. This access can be granted via the git:// or http(s):// protocols.

The URL should end with a slash /.

Defaults to: 'git://localhost.localdomain/'

GIT_FOLDER

This configuration key points to the folder where the git repos are stored. For every project, two to four repos are created:

  • a repo with source code of the project
  • a repo with documentation of the project (if ENABLE_DOCS is True)
  • a repo with metadata of tickets opened against the project (if ENABLE_TICKETS is True)
  • a repo with metadata of pull requests opened against the project

REMOTE_GIT_FOLDER

This configuration key points to the folder where the remote git repos (ie: not hosted on SourceLab) that someone used to open a pull-request against a project hosted on SourceLab are stored.

UPLOAD_FOLDER_PATH

This configuration key points to the folder where user-uploaded tarballs are stored and served from.

ATTACHMENTS_FOLDER

This configuration key points to the folder where attachments can be cached for easier access by the web-server (allowing to not interact with the git repo having it to serve it).

UPLOAD_FOLDER_URL

This configuration key specifies the full URL where the uploads are available. It is highly recommended for security reasons that this URL lives on a different domain than the main application (an entirely different domain, not just a sub-domain).

The default, /releases/, is unsafe in production.

Warning

both UPLOAD_FOLDER_PATH and UPLOAD_FOLDER_URL must be specified for the upload release feature to work

When this is set to True, the session cookie will only be returned to the server via ssl (https). If you connect to the server via plain http, the cookie will not be sent. This prevents sniffing of the cookie contents. This may be set to False when testing your application but should always be set to True in production.

Defaults to: True. Set it to False only to serve over plain http, as make run does.

SESSION_TYPE

Keeps the session of the web pages (their flashes and CSRF secret; the login has its own cookie) on the server instead of in an encrypted cookie, with the keys flask-session read in Pagure:

  • redis: in the redis server of SESSION_REDIS (a redis.Redis client), else of REDIS_HOST, REDIS_PORT and REDIS_DB;
  • filesystem: in files, in SESSION_FILE_DIR (default: flask_session in the current directory).

SourceLab refuses to start with any other value. Defaults to: None, the cookie.

FROM_EMAIL

This configuration key specifies the email address used by this SourceLab instance when sending emails (notifications).

Defaults to: sourcelab@localhost.localdomain

DOMAIN_EMAIL_NOTIFICATIONS

This configuration key specifies the domain used by this SourceLab instance when sending emails (notifications). It is used when building the msg-id header of the emails sent.

Defaults to: localhost.localdomain

EMAIL_REPLIES

This configuration key gives the notification emails a Reply-To address of the form reply+<hash>@<DOMAIN_EMAIL_NOTIFICATIONS>, and tells their readers that they can reply by email. Turn it on once the milter receives those replies: see Email Replies.

Defaults to: False.

VIRUS_SCAN_ATTACHMENTS

This configuration key configures whether attachments are scanned for viruses on upload. For more information, see the install.rst guide.

Defaults to: False

GIT_AUTH_BACKEND

This configuration key allows specifying which git auth backend to use.

By default SourceLab provides the following backends:

  • `test_auth`: simple debugging backend printing and returning the string Called GitAuthTestHelper.generate_acls()
  • `sourcelab`: SourceLab git auth implementation (using keyhelper.py and aclchecker.py) that is used via sshd AuthorizedKeysCommand
  • `sourcelab_authorized_keys`: SourceLab git auth implementation that writes to authorized_keys file

Defaults to: sourcelab_authorized_keys

HOOK_SECRET

The secret with which the git hooks ask the web application to run them. Every push runs three hooks or more (pre-receive, one update per ref, post-receive). With this key set, the pushes SourceLab starts (over SSH through aclchecker.py, over HTTP, and its own merges and mirrors) give their hooks the URL and the secret. Each hook then sends its push to /pv/hooks on the web application, which has SourceLab loaded already. Without it, each hook loads SourceLab in its own process, which takes about a second.

Set it to a long random string, such as the output of python -c "import secrets; print(secrets.token_urlsafe(32))". The endpoint accepts this secret and nothing else, whatever the caller's address: whoever has it can make the hooks of a push run, with their notifications and builds.

If a hook can't reach the web application, it runs in its own process, so pushes keep working while the application restarts. If the application takes the request but doesn't answer within 5 minutes, the push fails rather than running the hooks twice.

Defaults to: None

HOOK_URL

The address at which the git hooks reach the web application, when HOOK_SECRET is set. The hooks run on the machine that holds the repositories, so a local address that skips the reverse proxy, such as http://127.0.0.1:5000, is faster than the public one.

Defaults to: None, which means APP_URL.

Configure SourceLab Auth

SourceLab offers a simple, but extensible internal authentication mechanism for Git repositories. It relies on SSH for authentication. In other words, SSH lets you in and SourceLab checks if you are allowed to do what you are trying to do once you are inside.

This authentication mechanism uses keyhelper.py and aclchecker.py to check the SourceLab database for user registered SSH keys to authenticate users.

The integrated authentication mechanism has two modes of operation: one where it is configured as the AuthorizedKeysCommand for the SSH user (preferred) and one where it is configured to manage the authorized_keys file for the SSH user.

In the preferred mode, when you run a git command on a remote repo over SSH (e.g. git clone ssh://git@localhost.localdomain/repository.git), the SSH server will ask SourceLab to validate the SSH user key. This performs better, since it avoids racy and slow file I/O. It requires changes to the system's sshd_config file.

To use this variant, set the following in sourcelab.cfg:

GIT_AUTH_BACKEND = "sourcelab"

SSH_KEYS_USERNAME_EXPECT = "git"

SSH_COMMAND = ([
    "/usr/bin/%(cmd)s",
    "/srv/git/repositories/%(reponame)s",
], {"GL_USER": "%(username)s"})

Setting the following in /etc/ssh/sshd_config is also required:

Match User git
    AuthorizedKeysCommand /usr/libexec/sourcelab/keyhelper.py "%u" "%h" "%t" "%f"
    AuthorizedKeysCommandUser git

If you do not have the ability to modify the sshd configuration to set up the sourcelab backend, then you need to use the sourcelab_authorized_keys alternative backend. This backend will write to the git user's authorized_keys file instead. This is slower than the preferred mode and also has the disadvantage of making it impossible to scale to multiple SourceLab frontend instances on top of a shared Git storage without causing races and triggering inconsistencies. It also adds to the I/O contention on a heavily used system, but for most smaller setups with few users, the trade-off is not noticeable.

To use this variant, run the keys service of the layout in a process of its own, as the user that owns SSH_FOLDER (the unit sourcelab_authorized_keys_worker runs the process keys of /etc/sourcelab/layout.toml), and set the following to sourcelab.cfg:

SSH_FOLDER = "/srv/git/.ssh"

GIT_AUTH_BACKEND = "sourcelab_authorized_keys"

SSH_COMMAND = ([
    "/usr/bin/%(cmd)s",
    "/srv/git/repositories/%(reponame)s",
], {"GL_USER": "%(username)s"})

Live updates

LIVE_UPDATES

This configuration key turns on the live updates of the issue and pull request pages, which show the changes made elsewhere without reloading. See Live Updates.

Defaults to: False.

Note

The live updates require a redis server (see Redis options below)

Web-hooks notifications

WEBHOOK

This configuration key allows turning on or off web-hooks notifications for this SourceLab instance.

Defaults to: False.

Note

The Web-hooks server requires a redis server (see Redis options below)

Redis options

REDIS_HOST

This configuration key indicates the host at which the redis server is running.

Defaults to: 0.0.0.0.

REDIS_PORT

This configuration key indicates the port at which the redis server can be contacted.

Defaults to: 6379.

REDIS_SOCKET

This configuration key gives the Unix socket of the redis server, instead of REDIS_HOST and REDIS_PORT.

REDIS_DB

This configuration key indicates the redis database to connect to. The live updates don't depend on it: redis channels belong to no database.

Defaults to: 0.

Authentication options

ADMIN_GROUP

This configuration key lists the groups whose members are the site admins. These admins can regenerate the ssh key files, and the hook-token for every project as well as manage users and groups.

SOURCELAB_ADMIN_USERS

This configuration key lists the local users who are the site admins. These admins have the same rights as the users in the admin groups listed above as well as admin rights to all projects hosted on this SourceLab instance.

Stomp Options

SourceLab integration with Stomp allows you to emit messages to any stomp-compliant message bus.

STOMP_NOTIFICATIONS

This configuration key can be used to enable or disable notifications via stomp protocol. All other stomp-related settings don't need to be present if this is set to False.

Defaults to: False.

STOMP_BROKERS

This configuration key lists the brokers, as 2-tuples of a domain name and a port. For example [('primary.msg.bus.com', 6543), ('backup.msg.bus.com`, 6543)].

STOMP_HIERARCHY

This configuration key specifies the base name of the hierarchy to emit messages to. For example /queue/some.hierarchy.. Note that this must end with a dot. SourceLab will append queue names such as project.new to this value, resulting in queue names being e.g. /queue/some.hierarchy.project.new.

STOMP_SSL

Whether or not to use SSL when connecting to message brokers.

Defaults to: False.

STOMP_KEY_FILE

This configuration key specifies the absolute path to the key file for the SSL connection. Only required if STOMP_SSL is set to True.

STOMP_CERT_FILE

This configuration key specifies the absolute path to the certificate file for the SSL connection. Only required if STOMP_SSL is set to True.

STOMP_CREDS_PASSWORD

Password for decoding STOMP_CERT_FILE and STOMP_KEY_FILE. Only required if STOMP_SSL is set to True and credentials files are password-encoded.

ALWAYS_STOMP_ON_COMMITS

This configuration key can be used to enforce stomp notifications on commits made on all projects in a SourceLab instance.

Defaults to: False.

API token ACLs

ACLS

This configuration key lists all the ACLs that can be associated with an API token with a short description of what the ACL allows one to do. This key it not really meant to be changed unless you really know what you are doing.

With builds, a token reaches the builds' API as its user; it is one of the CROSS_PROJECT_ACLS, for a token of the user rather than of a project. An instance that existed before it gets it from its migration (alembic upgrade head).

With fetch, a token of a project fetches its repository over HTTP, even a private one, but never pushes, which needs commit: the builds' jobs clone their private projects with one. An instance that existed before it gets it from its migration too.

USER_ACLS

This configuration key can be used to list which of the ACLs listed in ACLS can be associated with an API token of a project in the (web) user interface.

Use this configuration key in combination with ADMIN_API_ACLS to disable certain ACLs for users while allowing admins to generate keys with them.

Defaults to: [key for key in ACLS.keys() if key != 'generate_acls_project'] (ie: all the ACLs in ACLS except for generate_acls_project)

ADMIN_API_ACLS

This configuration key can be used to list which of the ACLs listed in ACLS can be generated by the sourcelab-admin CLI tool by admins.

Defaults to: ['issue_comment', 'issue_create', 'issue_change_status', 'pull_request_flag', 'pull_request_comment', 'pull_request_merge', 'generate_acls_project', 'commit_flag', 'create_branch']

CROSS_PROJECT_ACLS

This configuration key can be used to list which of the ACLs listed in ACLS can be associated with a project-less API token in the (web) user interface. These project-less API tokens can be generated in the user's settings page and allows action in multiple projects instead of being restricted to a specific one.

Defaults to: ['create_project', 'fork_project', 'modify_project']

Optional options

ENABLE_GIVE_PROJECTS

This configuration key can be used to enable or disable giving a project to another user on this instance.

Defaults to: True.

ALWAYS_RENDER_SSH_CLONE_URL

This configuration key specifies whether git SSH URLs are displayed even if the user has not uploaded an SSH key.

Defaults to: False.

SSH_FOLDER

This configuration key specifies the folder containing the SSH authorized_keys of the user running SourceLab.

The default is the .ssh folder in lcl/, at the root of the sources, which only suits a development instance.

REACTIONS

This configuration key lists the predefined reactions, as pairs of a name and an emoji, such as ("Thumbs up", "👍"). Their order is preserved in the picker of the web UI. Other reactions can be selected by typing their name. The classes of the EmojiOne sprites that older versions used, such as emojione-1F44D, still work.

Defaults to thumbs up, thumbs down, confused and heart: see sourcelab/default_config.py.

ALLOW_PROJECT_DOWAIT

This configuration key is intended for tests only. Never enable it, as it can allow an easy denial of service of the system.

Defaults to: False.

Git repository templates

PROJECT_TEMPLATE_PATH

This configuration key allows you to specify the path to a git repository to use as a template when creating new repository for new projects. This template is only used for the sources repository of a new project. Forks, and the tickets, requests and docs repositories, don't use it.

FORK_TEMPLATE_PATH

This configuration key allows you to specify the path to a git repository to use as a template when creating new repository for new forks. This template is only used for the sources repository of a new fork. The tickets, requests and docs repositories don't use it.

SSH_KEYS

It is a good practice to publish the fingerprint and public SSH key of a server you provide access to. SourceLab offers the possibility to expose this information based on the values set in the configuration file, in the SSH_KEYS configuration key.

See the SSH hostkeys/Fingerprints page on pagure.io.

Warning

The format is important:

SSH_KEYS = {'RSA': {'fingerprint': '<foo>', 'pubkey': '<bar>'}}

Where <foo> and <bar> must be replaced by your values.

CSP_HEADERS

Content Security Policy (CSP) is a computer security standard introduced to prevent cross-site scripting (XSS), clickjacking and other code injection attacks resulting from execution of malicious content in the trusted web page context

Source: https://en.wikipedia.org/wiki/Content_Security_Policy

Defaults to:

CSP_HEADERS = (
    "default-src 'self' https:; "
    "script-src 'self' 'nonce-{nonce}'; "
    "style-src 'self' 'nonce-{nonce}'"
)

Where {nonce} is dynamically set by SourceLab.

LOGGING_GIT_HOOKS

This configuration key allows to have a different logging configuration for the web application and the git hooks.

If un-specified (default), the logging configuration used by the git hooks will be the same as the one for the web application (i.e.: defined in LOGGING here below).

Defaults to: None.

LOGGING

This configuration key allows you to set up the logging of the application. It relies on the standard python logging module.

The default value is:

LOGGING = {
     "version": 1,
     "disable_existing_loggers": False,
     "formatters": {
         "standard": {
             "format": "%(asctime)s [%(levelname)s] %(name)s: %(message)s"
         },
         "email_format": {"()": "sourcelab.infra.mail_logging.email_formatter"},
     },
     "filters": {"myfilter": {"()": "sourcelab.infra.mail_logging.ContextInjector"}},
     "handlers": {
         "console": {
             "formatter": "standard",
             "class": "logging.StreamHandler",
             "stream": "ext://sys.stdout",
         },
         "auth_handler": {
             "formatter": "standard",
             "class": "logging.StreamHandler",
             "stream": "ext://sys.stdout",
         },
         "email": {
             "level": "ERROR",
             "formatter": "email_format",
             "class": "logging.handlers.SMTPHandler",
             "mailhost": "localhost",
             "fromaddr": "sourcelab@localhost",
             "toaddrs": "root@localhost",
             "subject": "ERROR on sourcelab",
             "filters": ["myfilter"],
         },
     },
     # The root logger configuration; this is a catch-all configuration
     # that applies to all log messages not handled by a different logger
     "root": {"level": "INFO", "handlers": ["console"]},
     "loggers": {
         "sourcelab": {
             "handlers": ["console"],
             "level": "DEBUG",
             "propagate": True,
         },
         "sourcelab_auth": {
             "handlers": ["auth_handler"],
             "level": "DEBUG",
             "propagate": False,
         },
         "sqlalchemy": {
             "handlers": ["console"],
             "level": "WARN",
             "propagate": False,
         },
         "binaryornot": {
             "handlers": ["console"],
             "level": "WARN",
             "propagate": True,
         },
         "MARKDOWN": {
             "handlers": ["console"],
             "level": "WARN",
             "propagate": True,
         },
         "PIL": {"handlers": ["console"], "level": "WARN", "propagate": True},
         "chardet": {
             "handlers": ["console"],
             "level": "WARN",
             "propagate": True,
         },
         "sourcelab.infra.encoding_utils": {
             "handlers": ["console"],
             "level": "WARN",
             "propagate": False,
         },
     },
 }

Note

There is an email handler defined, which isn't used by default. You can use it to get error reports by email, and thus monitor your SourceLab instance. To do this, set on the root logger:

'handlers': ['console', 'email'],

Note

The sourcelab_auth logger is a special one, logging all activities regarding read and write access to git repositories. It can be an important log for auditing. You can separate it into its own file with the following handler:

"auth_handler": {
    "formatter": "standard",
    "class": "logging.handlers.TimedRotatingFileHandler",
    "filename": "/var/log/sourcelab/sourcelab_auth.log",
    "backupCount": 10,
    "when": "midnight",
    "utc": True,
},

This snippet makes the logs rotate at midnight each day, keeps them for 10 days and uses UTC as their timezone. Depending on how your SourceLab instance is set up, you may have to tweak the filesystem permissions on the folder and file so the rotation works properly.

ITEM_PER_PAGE

This configuration key allows you to configure the length of a page by setting the number of items on the page. Items can be commits, users, groups, or projects for example.

Defaults to: 50.

PR_TARGET_MATCHING_BRANCH

If set to True, the default target branch for all pull requests in UI is the branch that is longest substring of the branch that the pull request is created from. For example, a mybranch branch in original repo will be the default target of a pull request from branch mybranch-feature-1 in a fork when opening a new pull request. If this is set to False, the default branch of the repo will be the default target of all pull requests.

Defaults to: False.

SSH_ACCESS_GROUPS

Some instances of SourceLab are deployed in such a way that only the members of certain groups are allowed to commit via ssh. This configuration key allows to specify which groups have commit access and thus let SourceLab hide the ssh URL from the drop-down "Clone" menu for all the person who are not in one of these groups. If this configuration key is not defined or left empty, it is assume that there is no such group restriction and everyone can commit via ssh (default behavior).

Defaults to: []

SMTP configuration

SMTP_SERVER

This configuration key specifies the SMTP server to use when sending emails.

Defaults to: localhost.

See also the SMTP_STARTTLS section.

SMTP_PORT

This configuration key specifies the SMTP server port.

SMTP by default uses TCP port 25. The protocol for mail submission is the same, but uses port 587. SMTP connections secured by SSL, known as SMTPS, default to port 465 (nonstandard, but sometimes used for legacy reasons).

Defaults to: 25

SMTP_SSL

This configuration key specifies whether the SMTP connections should be secured over SSL.

Defaults to: False

SMTP_STARTTLS

This configuration key specifies instructs SourceLab to starts connecting to the SMTP server via a starttls command.

When enabling STARTTLS in conjunction with a local smtp server, you should replace localhost with a host name that is included in the server's certificate. If the server only relays messages originating from localhost, then you should also ensure that the above host name resolves to the same tcp address as localhost, for instance by adding an appropriate record to /etc/hosts.

Defaults to: False

SMTP_KEYFILE

This configuration key allows to specify a key file to be used in the starttls command when connecting to the smtp server.

Defaults to: None

SMTP_CERTFILE

This configuration key allows to specify a certificate file to be used in the starttls command when connecting to the smtp server.

Defaults to: None

SMTP_USERNAME

This configuration key allows usage of SMTP with auth.

Specify both SMTP_USERNAME and SMTP_PASSWORD to use SMTP authentication.

Defaults to: None

SMTP_PASSWORD

This configuration key allows usage of SMTP with auth.

Specify both SMTP_USERNAME and SMTP_PASSWORD to use SMTP authentication.

Defaults to: None

SHORT_LENGTH

This configuration key specifies the length of the commit ids or file hex displayed in the user interface.

Defaults to: 6.

BLACKLISTED_PROJECTS

This configuration key specifies a list of project names that are forbidden. This list is used for example to avoid conflicts at the URL level between the static files located under /static/ and a project that would be named static and thus be located at /static.

Defaults to:

[
    'static', 'pv', 'releases', 'new', 'api', 'settings',
    'logout', 'login', 'users', 'groups', 'about'
]

IP_ALLOWED_INTERNAL

This configuration key specifies which IP addresses are allowed to access the internal API endpoint. These endpoints are accessed by the milters for example and allow performing actions in the name of someone else which is sensitive, thus the origin of the request using these endpoints is validated. Internal endpoints lists them.

A request with an Authorization header is judged by its token instead, whatever its address: the token must hold the internal_access ACL (see SSH_ADMIN_TOKEN). Being logged in to the web interface never counts.

The address is the one the application server reports. Behind a reverse proxy on a unix socket, uvicorn reports none, so only a token gets in; behind a proxy on TCP, check that the server takes the client's address from X-Forwarded-For (uvicorn's --forwarded-allow-ips), or every proxied request comes from the proxy's address.

The entries are addresses, not host names: localhost would never match.

Defaults to: ['127.0.0.1', '::1'].

MAX_CONTENT_LENGTH

This configuration key specifies the maximum size of a request's body, so of the files uploaded to SourceLab (for example, screenshots to a ticket); a larger one gets a 413. A push over HTTP isn't bounded by it.

Defaults to: 4 * 1024 * 1024 which corresponds to 4 megabytes.

PLUGINS_DISABLED

The installed plugins of the forge to leave out, by the names of their entry points in the sourcelab.plugins group. SourceLab loads every other installed plugin when it starts, and refuses to start if one fails to load: disabling it lets the forge start without it.

These are the forge's plugins, installed as packages (the builds, for example), not the plugins a project enables in its settings.

Defaults to: []

ENABLE_TICKETS

This configuration key activates or deactivates the ticketing system for all the projects hosted on this SourceLab instance.

Defaults to: True

ENABLE_TICKETS_NAMESPACE

This configuration key can be used to restrict the namespace in which the ticketing system is enabled. So if your SourceLab instance has ENABLE_TICKETS as True and sets ENABLE_TICKETS_NAMESPACE to ['tests', 'infra'] only the projects opened in these two namespaces will have the ticketing system enabled. All the other namespaces will not.

Defaults to: []

ENABLE_DOCS

This configuration key activates or deactivates creation of git repos for documentation for all the projects hosted on this SourceLab instance.

Defaults to: True

ENABLE_NEW_PROJECTS

This configuration key permits or forbids creation of new projects via the user interface and the API of this SourceLab instance.

Defaults to: True

ENABLE_UI_NEW_PROJECTS

This configuration key permits or forbids creation of new projects via the user interface (only) of this SourceLab instance. It allows forbidding to create new project in the user interface while letting a set of trusted person to create projects via the API granted they have the API token with the corresponding ACL.

Defaults to: True

ENABLE_DEL_PROJECTS

This configuration key permits or forbids deletion of projects via the user interface of this SourceLab instance.

Defaults to: True

ENABLE_DEL_FORKS

This configuration key permits or forbids deletion of forks via the user interface of this SourceLab instance.

Defaults to: ENABLE_DEL_PROJECTS

GIT_HOOK_DB_RO

This configuration key specifies if the git hook have a read-only (RO) access to the database or not. Some SourceLab deployment provide an actual shell account on the host and thus the git hook called upon git push are executed under that account. If the user manages to by-pass git and is able to access the configuration file, they could have access to "private" information. So in those deployments the git hooks have a specific configuration file with a database access that is read-only, making SourceLab behave differently in those situations.

The hooks still put their background jobs (commit log, web-hooks, pull-request refreshes) in Myxo's queue, a table of the same database: their access must allow inserting into myxo_jobs.

Defaults to: False

EMAIL_SEND

This configuration key enables or disables all email notifications for this SourceLab instance. This can be useful to turn off when developing on SourceLab, or for test or pre-production instances.

Defaults to: False.

Note

This does not disable emails to the email address set in EMAIL_ERROR.

FEDMSG_NOTIFICATIONS

This configuration key can be used to enable or disable notifications via fedmsg.

Defaults to: False.

FEDORA_MESSAGING_NOTIFICATIONS

This configuration key can be used to enable or disable sending notifications via fedora-messaging.

Defaults to: False.

ALWAYS_FEDMSG_ON_COMMITS

This configuration key can be used to enforce fedmsg notifications on commits made on all projects in a SourceLab instance.

Defaults to: True.

ALLOW_DELETE_BRANCH

This configuration keys enables or disables allowing users to delete git branches from the user interface. In sensible SourceLab instance you may want to turn this off.

Defaults to: True.

ALLOW_ADMIN_IGNORE_EXISTING_REPOS

This enables a checkbox "Ignore existing repos" for admins when creating a new project. When this is checkbox is checked, existing repositories will not cause project creation to fail. This could be used to assume responsibility of existing repositories.

Defaults to: False.

USERS_IGNORE_EXISTING_REPOS

This configuration key lists the users who can also create a project while ignoring existing repositories.

Defaults to: [].

LOCAL_SSH_KEY

This configuration key can be used to let SourceLab administrate the user's ssh keys or have a third party tool do it for you. In most cases, it will be fine to let SourceLab handle it.

Defaults to True.

DEPLOY_KEY

This configuration key can be used to disable the deploy keys feature of an entire SourceLab instance. This feature enable to add extra public ssh keys that a third party could use to push to a project.

Defaults to True.

OLD_VIEW_COMMIT_ENABLED

In version 1.3, SourceLab changed its URL scheme to view the commit of a project in order to add support for pseudo-namespaced projects.

For SourceLab instances older than 1.3, who care about backward compatibility, we added an endpoint view_commit_old that brings URL backward compatibility for URLs using the complete git hash (the 40 characters). For URLs using a shorter hash, the URLs will remain broken.

This configuration key enables or disables this backward compatibility which is useful for SourceLab instances running since before 1.3 but is not for newer instances.

Defaults to: False.

DISABLE_REMOTE_PR

In some SourceLab deployments remote pull requests need to be disabled due to legal / policy reasons.

Defaults to: False.

INSTANCE_NAME

This allows giving a name to this running instance of SourceLab. The name is then used in the welcome screen shown upon first login.

Defaults to: SourceLab

Note

the welcome screen currently does not work with the local authentication.

ADMIN_EMAIL

This configuration key allows you to change the default administrator email which is displayed on the "about" page. It can also be used elsewhere.

Defaults to: root@localhost.localdomain

USER_NAMESPACE

This configuration key can be used to enforce that project are namespaced under the user's username, behaving in this way in a similar fashion as github.com or gitlab.com.

Defaults to: False

DOC_APP_URL

This configuration key allows you to specify where the documentation server is running (preferably in a different domain name entirely). If not set, the documentation page will show an error message saying that this SourceLab instance does not have a documentation server.

Defaults to: None

PRIVATE_PROJECTS

This configuration key allows you to host private repositories. These repositories are visible only to the creator of the repository and to the users who are given access to the repository. No information is leaked about the private repository which means redis doesn't have the access to the repository and even fedmsg doesn't get any notifications.

Defaults to: True

EXCLUDE_GROUP_INDEX

This configuration key can be used to hide project an user has access to via one of the groups listed in this key.

The use-case is the following: the Fedora project deploys Pagure, which SourceLab derives from, as a front-end for the git repositories of the packages in the distribution, about 17,000 of them. A group of people have access to all of these repositories. So the page of a member of that group would list all the projects hosted in that SourceLab instance, burying the projects that this person works on. Using this configuration key, SourceLab will hide all the projects that this user has access to via the specified groups and thus return only the groups of forks of that users.

Defaults to: []

FLAG_STATUSES_LABELS

By default, SourceLab has success, failure, error, pending and canceled statuses of PR and commit flags. This setting allows you to define a custom mapping of statuses to their respective Bootstrap labels.

FLAG_SUCCESS

Holds name of PR/commit flag that is considered a success.

Defaults to: success

FLAG_FAILURE

Holds name of PR/commit flag that is considered a failure.

Defaults to: failure

FLAG_PENDING

Holds name of PR/commit flag that is considered a pending state.

Defaults to: pending

EXTERNAL_COMMITTER

The external committer feature is a way to allow members of groups defined outside SourceLab (and provided to SourceLab upon login by the authentication system) to be consider committers on SourceLab.

This feature can give access to all the projects on the instance, all but some or just some.

Defaults to: {}

To give access to all the projects to a group named fedora-altarch use a such a structure:

EXTERNAL_COMMITTER = {
    'fedora-altarch': {}
}

To give access to all the projects but one (named rpms/test) to a group named provenpackager use a such a structure:

EXTERNAL_COMMITTER = {
    'fedora-altarch': {},
    'provenpackager': {
        'exclude': ['rpms/test']
    }
}

To give access to just some projects (named rpms/test and modules/test) to a group named testers use a such a structure:

EXTERNAL_COMMITTER = {
    'fedora-altarch': {},
    'provenpackager': {
        'exclude': ['rpms/test']
    },
    'testers': {
        'restrict': ['rpms/test', 'modules/test']
    }
}

REQUIRED_GROUPS

The required groups allows one to specify in which group an user must be to be added to a project with commit or admin access.

Defaults to: {}

Example configuration:

REQUIRED_GROUPS = {
    'rpms/kernel': ['packager', 'kernel-team'],
    'modules/*': ['module-packager', 'packager'],
    'rpms/*': ['packager'],
    '*': ['contributor'],
}

This configuration is evaluated in the given order:

  • only users that are in the groups packager and kernel-team will be allowed to be added the rpms/kernel project (where rpms is the namespace and kernel the project name).
  • only users that are in the groups module-packager and packager will be allowed to be added to projects in the modules namespace.
  • only users that are in the group packager will be allowed to be added to projects in the rpms namespace.
  • only users in the contributor group will be allowed to be added to any project on this SourceLab instance.

GIT_GARBAGE_COLLECT

This configuration key allows for explicit running of git gc --auto after every operation that adds new objects to any git repository - that is after pushing and merging. The reason for having this functionality in SourceLab is that gc is not guaranteed to be run by git after every object-adding operation.

The garbage collection run by SourceLab will respect git settings, so you can tweak gc.auto and gc.autoPackLimit to your liking and that will have immediate effect on the task that runs the garbage collection. These values can be configured system-wide in /etc/gitconfig. See https://git-scm.com/docs/git-gc#git-gc---auto for more details.

This is especially useful if repositories are stored on NFS (or similar network storage), where file metadata access is expensive - having unpacked objects in repositories requires a lot of metadata reads.

Defaults to: False

CASE_SENSITIVE

This configuration key can be used to make this SourceLab instance case sensitive instead of its default: case-insensitive.

Defaults to: False

PROJECT_NAME_REGEX

This configuration key can be used to customize the regular expression used to validate new project name.

Defaults to: ^[a-zA-z0-9_][a-zA-Z0-9-_]*$

APPLICATION_ROOT

This configuration key is used in the path of the cookie used by SourceLab.

Defaults to: '/'

ALLOWED_PREFIX

This configuration key can be used to specify a list of allowed namespaces that will not require creating a group for users to create projects in.

Defaults to: []

ADMIN_SESSION_LIFETIME

This configuration key allows specifying the lifetime of the session during which the user won't have to log in again for admin actions. In other words, it is the longest time during which a user can access a project's settings page without logging in again.

Defaults to: timedelta(minutes=20)

where timedelta comes from the python datetime module

BLACKLISTED_GROUPS

This configuration key can be used to blacklist some group names.

Defaults to: ['forks', 'group']

ENABLE_GROUP_MNGT

This configuration key can be used to enable or disable managing (ie: creating a group, adding or removing users in that group) groups in this SourceLab instance. If turned off, groups and group members are to be managed outside of SourceLab and synced upon login.

Defaults to: True

ENABLE_USER_MNGT

This configuration key can be used to enable or disable managing users (adding or removing them from a project) in this SourceLab instance. If turned off, users are managed outside of SourceLab.

Defaults to: True

ALLOW_USER_REGISTRATION

This configuration key can be used to enable or disable user registration (that is, the ability for users to create an account) in this SourceLab instance. If turned off, user accounts cannot be created through the UI or API.

Defaults to: True

This configuration key can be used to specify the name of the session cookie used by SourceLab. The login session has its own cookie, named after it: <SESSION_COOKIE_NAME>_local_cookie.

Defaults to: 'sourcelab'

SHOW_PROJECTS_INDEX

This configuration key can be used to specify what is shown in the index page of logged in users.

Defaults to: ['repos', 'myrepos', 'myforks']

EMAIL_ON_WATCHCOMMITS

By default SourceLab sends an email to every one watch commits on a project when a commit is made. However some SourceLab instances may be using a different notification mechanism on commits and thus may not want this feature to double the notifications received. This configuration key can be used to turn on or off email being sent to people watching commits on a project upon commits.

Defaults to: True

ALLOW_HTTP_PULL_PUSH

This configuration key controls whether any HTTP access to repositories is provided via the support for that that's embedded in SourceLab. This provides HTTP pull access via <sourcelaburl>/<reponame>.git if nothing else serves this URL.

Defaults to: True

ALLOW_HTTP_PUSH

This configuration key controls whether pushing is possible via the HTTP interface. This is disabled by default, as it requires setting up an authentication mechanism on the webserver that sets REMOTE_USER.

Defaults to: False

MIRROR_SSHKEYS_FOLDER

This configuration key specificies where SourceLab should store the ssh keys generated for the mirroring feature. This folder should be properly backed up and kept secure.

Each project's key is named after the project's id (project-<id>, with .pub for the public key), and the host keys of its remotes, accepted at its first push to each, are in project-<id>.known_hosts: a remote whose host key later changes is refused. A key named after the project's full name, as earlier versions did, gets renamed the first time it is used.

Defaults to: /var/lib/sourcelab/sshkeys/

LOG_ALL_COMMITS

This configuration key will make SourceLab log all commits pushed to all branches of all repositories instead of logging only the once that are pushed to the default branch.

Defaults to: False

DISABLE_MIRROR_IN

This configuration key allows a SourceLab instance to not support mirroring in projects (from third party git server).

Defaults to: False

ALLOW_API_UPDATE_GIT_TAGS

This configuration key determines whether users are allowed to update existing git tags via the API. When set to False, this essentially makes the API ignore whether the force argument is set or not.

Defaults to: True

GIT_DEFAULT_BRANCH

This configuration key allows to specify the default branch configured upon project creation. The default branch can be specified by the user upon project creation but if the user does not specify any branch, this branch name will be used.

The default, None, makes master the default branch.

PR_WARN_CHARACTERS

This configuration key lists the characters that trigger a warning to the users when found in a commit of a pull request. Each commit is checked.

Defaults to:

set([
    chr(0x202a), chr(0x202b), chr(0x202c), chr(0x202d), chr(0x202e),
    chr(0x2066), chr(0x2067), chr(0x2068), chr(0x2069)
])

DB_POOL_RECYCLE

This is the lifetime of a database connection in the connection pool, in seconds. For more details, refer to SQLAlchemy's documentation on the pool_recycle option.

Defaults to: 3600 (1 hour)

SSH_KEYS_USERNAME_LOOKUP

This configuration key is used by the keyhelper script to indicate that the git username should be used and looked up. Use this if the username that is sent to ssh is specific for a unique SourceLab user (i.e. not using a single "git@" user for all git operations).

SSH_KEYS_USERNAME_FORBIDDEN

This configuration key lists the usernames exempted from verification by the keyhelper.

SSH_KEYS_USERNAME_EXPECT

This configuration key should contain the username that is used for git if a single SSH user is used for all git ssh traffic (i.e. "git").

SSH_KEYS_OPTIONS

This configuration key provides the options added to keys as they are returned to sshd, in the same format as AuthorizedKeysFile (see "AUTHORIZED_KEYS FILE FORMAT" in sshd(8)).

SSH_ADMIN_TOKEN

If not set to None, aclchecker and keyhelper will use this api admin token to get authorized to internal endpoints that they use. The token must have the internal_access ACL.

This is useful when the IP address of sshd service is not predictable (e.g. because of running in a distributed cloud environment) and so it's not possible to use the IP_ALLOWED_INTERNAL address list.

Defaults to: None

SSH_COMMAND

This configuration key specifies the command to run when aclchecker is in use.

MQTT Options

If approprietly configured SourceLab supports sending messages to an MQTT message queue.

Here below are the different configuration options to make it so.

MQTT_NOTIFICATIONS

This global configuration key enables or disables sending notifications to an MQTT message queue.

Defaults to: False

MQTT_HOST

This configuration key specifies the host name of the MQTT server to send the notifications to.

Defaults to: None

MQTT_PORT

This configuration key specifies the port of the MQTT server to send the notifications to.

Defaults to: None

MQTT_USERNAME

This configuration key specifies the username to authenticate to the MQTT server as.

Defaults to: None

MQTT_PASSWORD

This configuration key specifies the password to authenticate to the MQTT server with.

Defaults to: None

MQTT_CA_CERTS

When using SSL-based authentication to the MQTT server, use this configuration key to point to the CA cert to use.

Defaults to: None

MQTT_CERTFILE

When using SSL-based authentication to the MQTT server, use this configuration key to point to the cert file to use.

Defaults to: None

MQTT_KEYFILE

When using SSL-based authentication to the MQTT server, use this configuration key to point to the key file to use.

Defaults to: None

MQTT_CERT_REQS

When using SSL-based authentication to the MQTT server, use this configuration key to specify if the CERT is required.

The default is ssl.CERT_REQUIRED, from Python's ssl library.

MQTT_TLS_VERSION

When using SSL-based authentication to the MQTT server, use this configuration key to specify the TLS protocols to support/use.

Defaults to: ssl.PROTOCOL_TLS_CLIENT (from python's ssl library), which negotiates TLS 1.2 or later

MQTT_CIPHERS

When using SSL-based authentication to the MQTT server, use this configuration key to specify the ciphers.

Defaults to: None

MQTT_TOPIC_PREFIX

This configuration key can be used to specify a prefix to the mqtt messages sent. This prefix will be added to the topic used by SourceLab thus allowing the mqtt admins to specify a parent topic for all sourcelab-related messages.

Defaults to: None

ALWAYS_MQTT_ON_COMMITS

This configuration key can be used to enforce mqtt notifications on commits made on all projects in a SourceLab instance.

Defaults to: False.

NOGITHOOKS

This configuration key should not be touched. It is used in the test suite as a way to prevent all the git hooks from running (which includes checking if the user is allowed to push). Using this mechanism we are able to check some behavior in the test suite that in a deployed SourceLab instance are happening in a different process.

Do not change this option in production

Defaults to: None.