Self-hosting
Secure your Leantime server
- Self-hosted only
- Checked with Leantime 3.15
At a glance
You need
- Leantime installed on your own server or in Docker
- Access to its config/.env file or Docker settings
When you host Leantime yourself, keeping it safe is up to you. Go through this checklist once Leantime is installed, and again when you move it to a new server. Every item is a setting in config/.env (or a Docker variable), a step on the server, or a choice in Leantime. On Leantime Cloud, all of this is done for you.
The checklist
Section titled “The checklist”- Set your own
LEAN_SESSION_PASSWORD - Replace the sample database passwords
- Use HTTPS
- Make only the
publicfolder reachable from the web - Keep debug mode off
- Decide how long sign-ins last
- Turn on two-factor authentication for Administrators and Owners
- Check who has access, and which API keys exist
- Install plugins only from sources you trust
- Update Leantime with every release
- Back up, including your settings and secret key
Why do I need my own LEAN_SESSION_PASSWORD?
Section titled “Why do I need my own LEAN_SESSION_PASSWORD?”Despite its name, LEAN_SESSION_PASSWORD is Leantime’s secret key. Leantime uses it to encrypt stored secrets, like the passwords of connected CalDAV calendars, and to build everyone’s private calendar (iCal) links. The sample .env files and Leantime’s built-in default all use the same public value, so anyone could know it.
-
Make a random value:
Terminal window openssl rand -base64 32 -
Put it in
config/.env(in Docker, in your.envfile or with-e):LEAN_SESSION_PASSWORD = 'the value you made'It needs at least 32 characters: encryption uses the first 32. Calendar links use the whole value, so keep all of it, not only the first 32 characters.
Set it before you install, if you can. If you change it on a server that’s already in use:
- Everyone’s calendar (iCal) links change, so people have to copy their new link from the Calendar and update their calendar apps.
- Calendars connected through the CalDAV plugin have to be connected again, because their saved passwords can’t be read anymore.
Keep the value safe, and include it in your backups (see What should my backups include?).
Docker secrets. The official Docker image can read secrets from files instead of the environment. Set LEAN_SESSION_PASSWORD_FILE, LEAN_DB_PASSWORD_FILE, LEAN_EMAIL_SMTP_PASSWORD_FILE, LEAN_S3_SECRET_FILE or LEAN_REDIS_PASSWORD_FILE to the path of a mounted secret, and the image reads the value from that file when it starts.
How do I protect the database?
Section titled “How do I protect the database?”- Replace the sample passwords. The Docker
sample.envsetschangeme123forMYSQL_ROOT_PASSWORD,MYSQL_PASSWORDandLEAN_DB_PASSWORD. Those values are public. Replace them before the first start, as Install Leantime with Docker describes. - Give Leantime its own database user, with full rights on Leantime’s database and nothing else. Don’t use the
rootuser. - Keep the database off the internet. Only Leantime needs to reach it. The official
docker-compose.ymldoesn’t publish the database port, so keep it that way. On your own server, let MySQL listen only on127.0.0.1or a private network, or block port 3306 (5432 for PostgreSQL) in your firewall.
How do I set up HTTPS?
Section titled “How do I set up HTTPS?”Serve Leantime over HTTPS only, and set:
LEAN_APP_URL = 'https://projects.example.com'LEAN_SESSION_SECURE = true-
LEAN_APP_URLis the address Leantime puts in links, like the ones in password-reset and invitation emails. Set it to the address people really use. -
LEAN_SESSION_SECURE = truesends the sign-in cookie over HTTPS only. -
Behind a proxy or CDN on a public address, like Cloudflare, add its address ranges to
LEAN_TRUSTED_PROXIES. Otherwise Leantime sees every request as coming from the proxy. Then everyone shares one limit on sign-in attempts, and Leantime may not notice that the site is on HTTPS. KeepPRIVATE_SUBNETSat the start of the list, so a proxy on your own server or in Docker stays trusted. Without it, Leantime refuses every request that comes through that proxy:LEAN_TRUSTED_PROXIES = 'PRIVATE_SUBNETS,173.245.48.0/20,103.21.244.0/22'
The steps for Nginx, Caddy, Traefik and Cloudflare are in Run Leantime behind a reverse proxy.
Which folders can people reach from the web?
Section titled “Which folders can people reach from the web?”Only the public folder. Your settings (config/.env), uploaded files (userfiles), database backups (backupdb) and logs (storage) sit next to it, outside the web root.
- Your own server: point the web server’s document root at
leantime/public, never at theleantimefolder (see Package based Installation and Shared hosting (cPanel)). - Docker: the image is set up this way already. Its web server and PHP run as the unprivileged
www-datauser, not as root.
While it runs, Leantime writes to storage/, bootstrap/cache/, userfiles/ and public/userfiles/, and to app/Plugins/ when you install or update plugins. Database backups and the command line updater also write to the Leantime folder, so run them as the user that owns it. Make config/.env readable only by that user and the server’s administrators, for example:
chmod 640 config/.envOnce Leantime is installed, its installer (/install) only sends visitors on to Leantime, so you don’t need to block it.
Why should debug mode stay off?
Section titled “Why should debug mode stay off?”With LEAN_DEBUG = 1, Leantime shows and logs details meant for developers, like file paths and full error messages. Turn it on only while you track down a problem, then set it back:
LEAN_DEBUG = 0How long do sign-ins last?
Section titled “How long do sign-ins last?”LEAN_SESSION_EXPIRATION is the number of minutes without activity before someone is signed out. The default is 480 (8 hours).
The Docker sample.env sets 28800 and calls it seconds, but Leantime reads minutes, so 28800 keeps people signed in for 20 days. For 8 hours, set:
LEAN_SESSION_EXPIRATION = 480How do I protect sign-ins?
Section titled “How do I protect sign-ins?”- Turn on two-factor authentication for every Administrator and Owner, and ask everyone else to do the same. Each person turns it on in their own account settings. Leantime can’t make it mandatory, and has no backup codes (see What about two-factor authentication?).
- Keep the sign-in limits on. By default, Leantime allows 20 sign-in attempts per minute from one address, 5 password-reset requests per 10 minutes, and 5 two-factor codes per 5 minutes. The settings are the
LEAN_RATELIMIT_*lines inconfig/sample.env. Raise them only if a whole office shares one address and people get locked out. - With a sign-in provider (SSO), keep the provider’s checks on:
LEAN_OIDC_REQUIRE_VERIFIED_EMAILstaystrueandLEAN_OIDC_SKIP_TLS_VERIFYstaysfalse, and the same goes forLEAN_EMAIL_SMTP_SSLNOVERIFYfor your mail server. If everyone signs in through the provider,LEAN_DISABLE_LOGIN_FORM = truehides the password form. Keep a way back in if the provider fails, for example by setting it tofalseagain. See Authentication.
Two protections are on by default; leave them that way. LEAN_CSRF_ORIGIN_CHECK refuses changes sent from other websites, and LEAN_PERMISSIONS_ENFORCE makes Leantime refuse actions a person’s role doesn’t allow.
How do I keep access tidy?
Section titled “How do I keep access tidy?”- Deactivate people who leave, right away. They can’t sign in anymore, and their work stays (see How do I deactivate or delete someone?).
- Keep few Administrators and Owners. Check the roles in User Management now and then.
- API keys: give each tool its own key, with the lowest role and only the projects it needs, and delete keys nobody uses. The API Keys tab shows when each key was last used (see How do I keep keys and tokens safe?).
What about plugins?
Section titled “What about plugins?”A plugin runs inside Leantime, with access to all of its data. Install plugins from the Leantime marketplace or from developers you trust, and disable the ones you don’t use. Leantime skips plugins that don’t support your version, and turns off plugins that keep crashing (see Plugin licenses and updates).
How do I stay up to date?
Section titled “How do I stay up to date?”Security fixes ship in regular releases, and only the latest release line gets them. The advisory that describes a fix is published two releases later, so people have time to update first. Waiting for the advisory means waiting too long.
- Get notified: on Leantime’s GitHub page, click Watch → Custom → Releases.
- Update as described in Upgrade Leantime, and keep PHP, your database and the server’s operating system up to date too.
- Published advisories are listed on Leantime’s security page on GitHub.
What should my backups include?
Section titled “What should my backups include?”- The database.
- The uploaded files (
userfilesandpublic/userfiles). - Your settings, with
LEAN_SESSION_PASSWORD:config/.envon your own server. With Docker, that’s the.envfile next todocker-compose.yml, the-evalues of yourdocker runcommand, or the secret files you mount.
Without the same LEAN_SESSION_PASSWORD, a restored server builds different calendar links and can’t read encrypted secrets. Backups hold all your data, so keep them somewhere safe, away from the server. See Backup and restore.
What does Leantime send to the internet?
Section titled “What does Leantime send to the internet?”Nothing that’s needed to run it. This is what Leantime itself sends out. Plugins can add their own connections, for example to sync calendars.
- Email: invitations, password resets and notification emails go to the mail server you set up (see Email configuration), or to the server’s own mail system. Each email carries the recipient’s address, a subject and the message, which can include project and to-do names and the text of comments.
- The daily usage summary goes to
telemetry.leantime.io: counts and version information, no names or content. See Telemetry for what’s in it. - Leantime news: Leantime loads its news from
leantime.ioto show it in the app. - Marketplace plugins talk to
marketplace.leantime.io:- When you install or update a plugin, Leantime sends the license key, your installation’s ID (the same random ID the usage summary uses), your Leantime version, your number of active users (see What counts as a user?), and the PHP, OpenSSL and operating system versions of your server. After the install it reports whether it worked, with the error message if it didn’t.
- Once a day, and when you enable a plugin, Leantime checks its license. When you disable a plugin, Leantime tells the marketplace. Both send the license key, your installation’s ID, your Leantime version, your number of active users and a fingerprint of the plugin file.
- Once a day, and when you click Check for updates, Leantime asks for newer versions. It sends the names of your marketplace plugins and your Leantime version.
- When you open Leantime Apps, the list of plugins loads from the marketplace.
- Project integrations, only if someone connects a project to Slack, Discord, Mattermost, Telegram or Zulip: each update goes to that service with the project’s name, what changed and who changed it, the to-do’s title and status, and a link. Telegram messages also show the priority, the assigned person and the due date. See Project integrations.
- Personal webhooks, only if someone adds one under My Profile → Webhooks: their notifications go to the address they entered (see Notifications).
- Phone notifications, only if you turn them on: notifications for the mobile app go through Leantime’s relay at
accounts.leantime.io(see Set up the mobile app). - Updating from the command line:
php bin/leantime system:updatedownloads the new release from GitHub.
If your server has to stay offline or private, turn these off:
LEAN_ALLOW_TELEMETRY = false # the daily usage summaryLEAN_NEWS_ENABLED = false # Leantime news in the appThese two settings don’t stop project integrations, personal webhooks or phone notifications. Those only send when someone sets them up, and you turn them off where they were set up.
Installing and updating marketplace plugins needs a connection to marketplace.leantime.io. The daily license check doesn’t: if Leantime can’t reach the marketplace, it skips the check and the plugin stays on (see When does Leantime check licenses?).
Found a security issue?
Section titled “Found a security issue?”Report it privately, as described in Report a security issue.
Related
Section titled “Related”Was this page helpful?
Thanks, glad it helped.
Thanks for telling us. What was missing?
