Skip to content

Latest commit

 

History

History
262 lines (209 loc) · 14.5 KB

configuration.md

File metadata and controls

262 lines (209 loc) · 14.5 KB

Configuration Guide

All configuration the application actually reads, verified against .env, .env.example, .env.test, compose.yml and config/services.yaml.

How configuration is loaded

Two layers, two owners:

  1. Symfony (application) — symfony/dotenv loads .env → .env.local → .env.$APP_ENV → .env.$APP_ENV.local (later files win; real environment variables win over all files). Committed defaults live in .env; put local overrides in the uncommitted .env.local.
  2. Docker Compose (infrastructure) — compose.yml interpolates variables like ${HTTP_PORT:-8765} from the shell environment or the .env file. .env.example documents this layer.

Application

Defined as parameters in config/services.yaml, defaults in .env:

Variable Default Purpose
APP_ENV dev Symfony environment (dev, prod, test)
APP_DEBUG derived from APP_ENV Debug mode
APP_SECRET change it Symfony kernel secret
APP_ENCRYPTION_KEY falls back to APP_SECRET Key for encrypting Jira OAuth tokens at rest (generate: openssl rand -base64 32)
APP_TITLE Netresearch TimeTracker Title shown in the UI
APP_LOCALE en Default locale
APP_LOGO_URL /images/logo-netresearch.svg Logo shown in the UI
APP_HEADER_URL empty Optional link target for the header/logo
APP_SHOW_BILLABLE_FIELD_IN_EXPORT false Include the billable column in exports
REQUIRE_TWO_FACTOR false Org-wide mandatory 2FA: every user must enrol a second factor (authenticator app or passkey) before they can use the app. A user whose only factor is a passkey must sign in with it; the password login is refused. See Variables compose.yml does not forward
MCP_ALLOWED_HOSTS localhost,127.0.0.1,[::1] when missing Comma-separated host names (no port, no spaces) the MCP endpoint /mcp accepts; list the public domain to use MCP there. See Variables compose.yml does not forward

Variables compose.yml does not forward

The bundled compose.yml does not forward REQUIRE_TWO_FACTOR, WEBAUTHN_RP_ID, WEBAUTHN_ALLOWED_ORIGINS and MCP_ALLOWED_HOSTS to the production app service. Setting one of them in the Compose .env or in the shell has no effect there. When they are missing from the container, the defaults in config/services.yaml apply: no mandatory 2FA, RP ID localhost, no passkey origin (every passkey is rejected), and MCP on local host names only.

Set them on the app service in compose.override.yml:

services:
  app:
    environment:
      REQUIRE_TWO_FACTOR: "true"
      WEBAUTHN_RP_ID: tt.example.com
      WEBAUTHN_ALLOWED_ORIGINS: https://tt.example.com
      MCP_ALLOWED_HOSTS: tt.example.com

env_file: works too. An environment: entry overrides the same variable from env_file:, and an entry without a value (- WEBAUTHN_RP_ID) removes it when Compose has no value for it.

Passkeys (WebAuthn)

Variable Default (.env; production image: see below) Purpose
WEBAUTHN_RP_ID localhost Relying party ID: a domain without scheme and port. Every passkey is bound to it, so changing it makes the registered passkeys unusable
WEBAUTHN_ALLOWED_ORIGINS http://localhost Comma-separated list of the full origins (scheme, host and, if not the default, port; no path) a passkey may be registered or used on. Whitespace around entries and empty entries are ignored. Subdomains and wildcards are not matched; an empty list rejects every passkey

Both are read at container runtime. Recreate the container after a change (docker compose --profile prod up -d --force-recreate app); a restart keeps the old environment. The bundled compose.yml does not forward them; see Variables compose.yml does not forward. Without them the production image uses the RP ID localhost and no origin, so every passkey is rejected. An entry that is not a valid URL, such as https:// without a host, fails every request, not only passkeys.

When upgrading from a release that took a single origin, remove a persisted var/cache (the app-cache volume) before adding a second one. The compiled container in it treats the whole value as one origin, which matches none:

docker compose --profile prod down
docker volume rm <project>_app-cache   # e.g. timetracker_app-cache
docker compose --profile prod up -d

Several origins with one RP ID

To use the same passkeys on a second domain, for example while moving an installation, keep WEBAUTHN_RP_ID and add the new origin:

WEBAUTHN_RP_ID=tt.example.com
WEBAUTHN_ALLOWED_ORIGINS=https://tt.example.com,https://tt.example.org

TimeTracker publishes the list at /.well-known/webauthn (Related Origin Requests). A browser on https://tt.example.org fetches it from the RP ID's host, so https://tt.example.com/.well-known/webauthn must keep answering with status 200, without a redirect and without a login, for as long as those passkeys are used. The browser has to support Related Origin Requests.

Database

Variable Default (.env) Purpose
DATABASE_URL mysql://timetracker:timetracker@db:3306/timetracker?serverVersion=mariadb-12.3.3 Doctrine DBAL connection (config/packages/doctrine.yaml)

The test environment (.env.test) points at the dedicated db_unittest container: mysql://unittest:unittest@db_unittest:3306/unittest?serverVersion=mariadb-12.3.3&charset=utf8mb4 (no host port is published for it).

Authentication (LDAP + local accounts)

Each account authenticates against exactly one source (ADR-018 D1): a user with a stored password hash is a local account (verified against the hash; LDAP is never consulted for it), any other user is an LDAP account. LDAP is optional — leaving LDAP_HOST empty puts the instance in local-only mode and only password accounts can log in.

Bootstrap a local admin (also the LDAP-outage escape hatch / password reset):

bin/console app:user:create <username> --type=ADMIN

Login attempts are throttled to 5 per username+IP.

LDAP

Defaults in .env target the bundled ldap-dev container:

Variable Default Purpose
LDAP_HOST ldap-dev LDAP server host (empty = local-only mode)
LDAP_PORT 389 Port (636 for LDAPS)
LDAP_READUSER cn=readuser,dc=dev,dc=local Read/bind user DN
LDAP_READPASS readuser Read/bind user password
LDAP_BASEDN dc=dev,dc=local Search base DN
LDAP_USERNAMEFIELD uid Username attribute (sAMAccountName for Active Directory)
LDAP_USESSL false Use SSL (legacy LDAPS)
LDAP_CREATE_USER true Auto-create TimeTracker users after successful LDAP authentication

Jira / ticket systems (admin UI, not env vars)

Jira integration is not configured through environment variables. Each ticket system is a database record (ticket_systems table, entity src/Entity/TicketSystem.php) managed in the admin UI (Administration → Ticket systems, requires ROLE_ADMIN):

Field Meaning
Name Unique display name
Type JIRA, OTRS or FRESHDESK (src/Enum/TicketSystemType.php); only Jira has an integration, OTRS and Freshdesk are used for ticket links only
Deployment type Jira only: SERVER (Server / Data Center, OAuth 1.0a) or CLOUD (OAuth 2.0); decides which credentials below are used
URL Jira: base URL (Server) or site URL (Cloud), required. OTRS/Freshdesk: informational only
Ticket URL Per-ticket link pattern; %s becomes the ticket key or number
Time booking Jira only: whether worklogs are pushed to Jira
OAuth consumer key + Private key (PEM) SERVER: the consumer key of the incoming application link and the RSA private key in PKCS#8 PEM. The key is stored in the oauth_consumer_secret column, which the Server stack reads as the private key
OAuth 2.0 client ID / client secret CLOUD: the 3LO app's credentials; the dialog also shows the callback URL to register and, once resolved at the first authorization, the Atlassian cloudId
Sync default activity Jira only: activity for worklogs the scheduled sync imports; empty turns the unattended import off

The dialog shows only the fields the chosen type and deployment type use. Show all fields also reveals the login, password, public_key and private_key columns, which no live code path reads, marked as not used. Secrets are write-only: a blank field keeps the stored value, and with Show all fields each secret of a stored system offers Clear stored value (clearSecrets in the save payload).

Deployment type is SERVER or CLOUD (src/Enum/DeploymentType.php). Secret fields are never sent back to the browser (TicketSystem::SECRET_KEYS). Per-user Jira access tokens are encrypted at rest with APP_ENCRYPTION_KEY; migrate plaintext tokens with bin/console tt:encrypt-jira-tokens (src/Command/EncryptJiraTokensCommand.php).

Setting up Jira Cloud (OAuth 2.0 / 3LO)

  1. In the Atlassian developer console, create an OAuth 2.0 (3LO) app.
  2. Add the Jira platform REST API with the scopes read:jira-work and write:jira-work (offline_access for refresh tokens is requested automatically at authorize time).
  3. Register the callback URL — exactly https://<your-timetracker>/jiraoauthcallback, no query string (the ticket system id travels inside the encrypted state parameter).
  4. In Administration → Ticket systems, set type JIRA, deployment type CLOUD, the site URL (https://<site>.atlassian.net), and the app's Client ID / Client Secret. The dialog shows the callback URL to register in step 3.
  5. Each user authorizes once via Settings → Synchronization → Connect Jira (or the notice shown when a save could not reach Jira); the Atlassian cloudId is resolved and stored automatically, access tokens refresh themselves (rotating refresh tokens).

Tracking external tickets in an internal Jira project

A project can mirror worklogs for tickets from a customer's ticket system into your own Jira: set Internal Jira project key and Internal Jira ticket system on the project (admin UI; fields internal_jira_project_key / internal_jira_ticket_system on src/Entity/Project.php). When a user books time on an external ticket, the app searches the internal project for an issue whose summary references that ticket and creates one if none exists, then books the worklog there (src/EventSubscriber/EntryEventSubscriber.php).

Error tracking (Sentry)

Variable Default Purpose
SENTRY_DSN empty (disabled) DSN for sentry/sentry-symfony; set to enable error reporting. Disabled in tests via config/packages/test/sentry.yaml

Docker Compose level

Read by compose.yml (template: .env.example):

Variable Default Purpose
COMPOSE_PROFILES dev Which services start: dev, prod, tools, test, e2e
HTTP_PORT 8765 Host port of the dev/prod web server
E2E_HTTP_PORT 8766 Host port of the e2e web server
DB_ROOT_PASSWORD, DB_USER, DB_PASSWORD, DB_NAME global123 / timetracker / timetracker / timetracker Main database credentials
UNITTEST_DB_ROOT_PASSWORD, UNITTEST_DB_USER, UNITTEST_DB_PASSWORD, UNITTEST_DB_NAME global123 / unittest / unittest / unittest Test database (db_unittest) credentials
E2E_DB_ROOT_PASSWORD, E2E_DB_USER, E2E_DB_PASSWORD, E2E_DB_NAME global123 / timetracker / timetracker / timetracker E2E database (db-e2e) credentials
LDAP_ADMIN_PASSWORD admin123 Dev LDAP directory admin password
LDAP_READONLY_USER_USERNAME / LDAP_READONLY_USER_PASSWORD readuser / readuser Dev LDAP read-only bind user
TRUSTED_PROXY_ALL empty Set to 1, true, yes or on to trust X-Forwarded-* headers from the direct peer (public/index.php)
TRUSTED_PROXY_LIST empty JSON array of trusted proxy IPs/ranges, e.g. ["10.0.0.0/8"] (public/index.php)
COVERAGE_ENABLED / XDEBUG_MODE 0 / off E2E backend coverage collection (see testing.md)

Note: .env.example still lists the test DB credentials as TEST_DB_*, but compose.yml reads them as UNITTEST_DB_* (the defaults are identical either way).

Test-only variables

Variable Where Purpose
APP_FROZEN_TIME app-e2e service in compose.yml (2024-01-15 12:00:00) Freezes the application clock (src/Service/ClockFactory.php) so e2e tests are deterministic against sql/testdata.sql
KERNEL_CLASS, SYMFONY_DEPRECATIONS_HELPER, … .env.test, phpunit.xml.dist Standard Symfony test harness settings
VAR_DUMPER_SERVER config/packages/dev/debug.yaml Target of the dev-only server:dump var-dumper server

Console commands

The application ships exactly two own commands (src/Command/):

bin/console tt:encrypt-jira-tokens   # encrypt plaintext Jira OAuth tokens at rest (idempotent)
bin/console tt:sync-subtickets       # update project subtickets from Jira

For inspecting configuration use the standard Symfony tooling: bin/console debug:config, bin/console debug:container --env-vars, bin/console debug:router.