Commit Graph
15 Commits
Author SHA1 Message Date
Lauri Ojansivu c99aa7f845 Admin Panel / Problems / Password length, and a changed password signs every session out.
PASSWORD_MIN_LENGTH (default 8) is now the length below which a sign-in
is REPORTED, in the new Admin Panel / Problems / Password length, and
PASSWORD_MIN_LENGTH_ENFORCE (off by default) is what makes it a rule: a
shorter new password is refused, and an account that signs in with an
older shorter one sees only "Change your password" until it has a long
enough one. Signing in is never refused, enforced or not, so nobody is
locked out by a minimum set after their password. LDAP, OAuth2, OIDC,
SAML, CAS and Sandstorm accounts are neither reported nor asked: their
password is their provider's. An administrator's Set password no longer
applies WeKan's policy to such an account.

Meteor sends a password hashed, so only the browser knows its length: it
notes it on the sign-in form and, after a sign-in that worked, says "it
was short" - never the password or its length.

The page has both settings and a table, one row per account: username,
first and last short-password login, the latest IPv4 and IPv6 address
with the country's flag and city when a CDN says where it is, the count,
and when it was fixed, with the Too short (default) / Fixed / All filter.
Fixed is a changed password not seen short since; a short one seen
again reopens the row.

Changing one's own password - Member Settings, the forced change, a
reset link - now signs EVERY session of the account out, the one that
changed it too, and only the new password signs in again. The browser
goes to the sign-in page as soon as it is signed out, since the server
closes the connection before the answer can arrive.

Documented in docs/Features/Admin-Panel/Problems/Password-length.md, the
settings on every platform. The new strings are in every locale in
English for now. Tests: passwordPolicy, passwordChangeRequired and
shortPasswordLogins (node); password-min-length-signup-login,
password-length-report and password-change-other-sessions (Playwright,
Chromium and WebKit), which change each setting on the page and check
what it does, and that sign-up with no mail server registers and signs
the user in.

Thanks to xet7 !
2026-10-31 14:54:22 +02:00
Lauri Ojansivu 41173f0f6b Sign a browser session out after it has been idle for LOGOUT_IDLE_MINUTES.
LOGOUT_WITH_TIMER ends a login at a deadline however busy its user is;
nothing ended a session somebody walked away from. LOGOUT_IDLE_MINUTES
(Admin Panel / People / Login, every platform; empty or 0 is off) does:
the browser reports a key press, click, touch or scroll at most once a
minute, the server keeps the time per login token in idleSessions, and
once a minute every token idle past the limit is removed, which signs its
connections out. A tab that reconnects and resumes its login by itself -
a laptop waking up - is not activity and does not extend the session.
REST API tokens have no session record and are never removed. The time
is kept beside the user rather than on the token, because updating one
element of the token array needs the positional $ operator, which not
every database WeKan runs on supports.

Thanks to xet7 !
2026-10-31 00:08:20 +02:00
Lauri Ojansivu d7abe9910a Password policy for new passwords, and compulsory two-factor authentication.
New passwords: PASSWORD_MIN_LENGTH (default 8) and PASSWORD_CHECK_PWNED
(off by default), in Admin Panel / People / Login and on every platform.
The browser sends a password to Meteor hashed, so the server checks every
password that reaches it as text - Admin Panel Set password and Add user,
POST /users/register - and the sign-up, Change Password, reset and
enrolment forms check in the browser. Signing in is never checked, so an
existing shorter password keeps working until it is changed. A breached
password is found with Have I Been Pwned's k-anonymity range API: only 5
hex digits of the SHA-1 leave WeKan, and an unreachable service never
refuses a password.

REQUIRE_2FA: off (default), admins or all. It covers accounts that sign in
with a WeKan password; LDAP, OAuth2, SAML, CAS and Sandstorm accounts sign
in through an identity provider and are not asked. Such an account can
still sign in, sees only the 2FA set-up until it has 2FA, and until then
the server refuses every method and publication but signing in and
enrolling, HTTP routes do not accept its login and the REST API gives it
no token. Once required, 2FA cannot be switched off.

The new interface strings are pending translation.

Thanks to xet7 !
2026-10-31 00:07:58 +02:00
Lauri Ojansivu 4993242c5f Strict-Transport-Security on every response of an HTTPS site.
WeKan sent no HSTS header, so a link typed as plain HTTP or a downgrade on
a hostile network could strip TLS from the next visit unless the reverse
proxy added it. It is now sent whenever ROOT_URL is https: 180 days, this
host only. HSTS_MAX_AGE, HSTS_INCLUDE_SUBDOMAINS and HSTS_PRELOAD (Admin
Panel / People / Login, every platform) change it; 0 stops it, and preload
is sent only with includeSubDomains and at least a year. Every response
also carries X-Content-Type-Options: nosniff and
Referrer-Policy: strict-origin-when-cross-origin.

Thanks to xet7 !
2026-10-30 23:50:02 +02:00
Lauri Ojansivu 2799eb900f Admin Panel / Attachments / Retention: readable labels, and the default shown.
The Retention page (#6789) showed only the variable names
(ATTACHMENTS_RETENTION_DAYS, ...), the raw choices uploaded and
card-inactive, and Default () with nothing between the brackets
whenever the variable was set but empty - which is what a Helm chart or
a docker-compose file listing the variable does.

Catalog fields (models/lib/authConfigCatalog.js) can name a labelKey, a
helpKey and choiceLabelKeys: the form shows the translated label with
the variable name beside it, a help line, and the choices by name.
Fields without them look as before. An empty variable is unset for the
value shown, as the retention code itself reads it, so the default is
shown again; yes/no defaults are translated. The five retention fields
use them; seven new strings in every language (low confidence for the
rarest and constructed ones). From the reporter's patch.

Thanks to Raymond-Voogt and xet7 !

Fixes #6819.
2026-10-27 16:24:58 +02:00
Lauri Ojansivu 718fdb5dac Newest features' settings: on every release platform and in the Admin Panel, and kept that way.
An audit of every environment variable the code reads found 30 that are new
since v12.00. Eleven were already Admin Panel settings and on every platform
the release workflows build. Of the rest:

Now Admin Panel settings, through models/lib/authConfigCatalog.js (a value
there wins, an empty field falls back to the variable):
- Email to card limits, beside its own Admin Panel settings:
  INBOUND_IMAP_POLL_SECONDS, INBOUND_EMAIL_PER_ADDRESS_PER_HOUR,
  INBOUND_EMAIL_MAX_BYTES, INBOUND_EMAIL_MAX_ATTACHMENT_BYTES and
  EMAIL_VIEW_SENDS_PER_HOUR. They were module-level constants, read before
  the Admin Panel values loaded; they are read when used now.
  createRateLimiter takes a limit function, and a changed poll interval
  restarts the IMAP poller.
- ACCOUNTS_COOKIE_REFRESH_RATE_LIMIT in People / Login, like the login
  expiry beside it, applied from the next start.
- Windows SSO (WINDOWS_SSO_ENABLED, _DOMAINS, _ACTIVE_DIRECTORY,
  _MERGE_EXISTING_USERS) in People / Login. It was already read through
  authEnv but had no form. Being Windows-only, its catalog section names
  start-wekan.bat as its one platform.

Listed on every platform (Dockerfile, the docker-compose files, start-wekan.sh
and .bat, the snap config and help), where none of these had been: the
variables above, INBOUND_EMAIL_WEBHOOK_SECRET (its own Admin Panel page
already has it), and the per-process switches that stay environment only -
INBOUND_IMAP_DISABLED (one pod of a multi-pod deployment), WEKAN_DISK_MONITOR,
WEKAN_DISK_WATCH_PATHS, WEKAN_RAM_MONITOR and WEKAN_IMPORT_RUN_STALE_MS.
Left unlisted on purpose: NEXTCLOUD_EXAPP, NEXTCLOUD_URL and
WEKAN_NEXTCLOUD_PROXY_KEY (set by Nextcloud's AppAPI), SANDSTORM_MAILDIR (set
by Sandstorm). DEFAULT_AVATAR_URL keeps no Admin Panel UI, as decided in #824.

tests/envVarCoverage.test.cjs keeps it so. It fails for a variable that is in
no Admin Panel catalog, OWN_PANE or ENV_ONLY with its reason; the variables
read before v12.00 are a frozen LEGACY list that can only shrink. An
environment-only or own-page setting a user sets must be on every platform,
and stale entries fail. tests/authConfigCatalog.test.cjs honours a section's
platform list. tests/adminPanelNewSettings.test.cjs pins the reads and the
forms. tests/cookieRefreshRateLimit.test.cjs's guard now expects the Admin
Panel value, and says why. tests/playwright/specs/admin-new-env-settings.e2e.js
opens the forms.

Thanks to xet7 !
2026-10-20 13:50:10 +03:00
Lauri Ojansivu 06b7ce994a Backup status: every run recorded, failures and overdue backups shown, old local backups pruned - in Admin Panel too.
The result of an Admin Panel backup lived only in the memory of the server
process that ran it. After a restart, or on another pod of a multi-pod
deployment, the Backup pane said "idle", so nobody could see whether last
night's backup had worked. There was no history, no warning when a scheduled
backup failed or did not run, and local backups were never cleaned up.

- Every run, scheduled or "Backup now", is recorded in backupRuns: start and
  end, who or the schedule, scope, storage, status, size, duration and error.
  Records are kept 400 days. A run still "running" after 24 hours counts as
  failed, and a scheduled run skipped for another backup is recorded as failed.
- Admin Panel / Problems / Backup shows the last success (overdue when its
  period has passed), the last failure with its error, the next run and the
  last 30 runs. The same status is above the schedule in Attachments / Backup.
- Problems / Summary lists "Backup failed" and "Backup overdue". /metrics adds
  wekan_backup_last_success_timestamp_seconds,
  wekan_backup_last_run_timestamp_seconds, wekan_backup_last_run_success and
  wekan_backup_overdue for alerting.
- BACKUP_KEEP_DAYS: after a successful backup, local backups of the same scope
  older than N days are deleted. The newest is always kept, and only a
  directory inside the backup root holding a backup.zip is removed.

From the patch by Raymond-Voogt, and in Admin Panel as well:
- BACKUP_KEEP_DAYS is the catalog's backup section
  (models/lib/authConfigCatalog.js), overridable beside the schedule in
  Admin Panel / Attachments / Backup and resolved through authEnv at every
  backup.
- It is listed on every platform: the compose files, start-wekan.sh and .bat,
  the snap config and help, and the Dockerfile, which the patch's version
  had missed. Its platform hunks, written before #6789, were re-applied by
  hand.

tests/backupRuns.test.cjs (21): the run records, overdue and pruning against a
real directory, and the Admin Panel override, including that nothing reads the
variable around it. tests/authConfigCatalog.test.cjs checks every platform.
admin-attachment-retention.e2e.js checks the Backup pane shows the field.

Thanks to Raymond-Voogt and xet7 !

Fixes #6790.
2026-10-20 13:30:00 +03:00
Lauri Ojansivu dcf91e4471 Attachment retention: delete card attachments after N days, purge deleted ones after M days - in Admin Panel too.
Organisations that must not keep files forever (storage limits, GDPR data
minimisation) had only scripts working on MongoDB directly, which leave card
references behind, do not know which storage holds a file, and break on
upgrades. Soft-deleted attachments were also kept forever.

A nightly job (server/attachmentRetention.js, rules in
models/lib/attachmentRetention.js), off unless configured:
- ATTACHMENTS_RETENTION_DAYS soft-deletes card attachments older than N days
  through the card's own Delete (cover unset, activity, card history Restore).
- ATTACHMENTS_RETENTION_MODE: uploaded (default), or card-inactive, which also
  requires the card to have had no activity for as long.
- ATTACHMENTS_PURGE_DELETED_AFTER_DAYS removes attachments soft-deleted at
  least M days ago for good, file included, through Attachments.removeAsync
  so every storage backend is cleaned. The write re-checks deletedAt, so one
  restored meanwhile stays.
- ATTACHMENTS_RETENTION_DRY_RUN only logs; ATTACHMENTS_RETENTION_MAX_PER_RUN
  caps each step per night.
Never touched: attachments without a card, template boards and cards, and
attachments with an unknown upload date.

From the patch by Raymond-Voogt, and in Admin Panel as well:
- The five settings are a section of models/lib/authConfigCatalog.js.
  Admin Panel / Attachments / Retention (/admin/attachments/retention) draws
  the shared override form on it: a value there wins, an empty field falls
  back to the variable, and the source in effect is shown.
- The job resolves them through authEnv on every run, so a change needs no
  restart.
- The new menu label attachment-retention is translated in all 246 locales.
- The catalog's platform test then found that the patch had missed the
  Dockerfile and the snap help; both list all five now, beside
  docker-compose, start-wekan and the snap config.

tests/attachmentRetention.test.cjs (14) covers the rules and the Admin Panel
wiring; negative: the job never reads the environment around the Admin Panel.
tests/authConfigCatalog.test.cjs checks every platform lists each variable.
tests/playwright/specs/admin-attachment-retention.e2e.js opens the pane, and
checks that an ordinary user cannot.

Thanks to Raymond-Voogt and xet7 !

Fixes #6789.
2026-10-20 13:28:17 +03:00
Lauri Ojansivu b933a69cd4 People shows everyone's Last active; inactive users can be disabled; LDAP sync honours its search filter.
Admin Panel / People showed "Last active" as "-" for every user but the
administrator: the people publication did not carry lastConnectionDate.

USERS_DISABLE_INACTIVE_AFTER_DAYS disables, once a night, accounts that have
not used WeKan for that many days, and revokes their logins. Admins are
never disabled. An account with no recorded activity starts its count on the
first run rather than from createdAt, and re-enabling an account restarts it.
The setting is in Admin Panel / People / Login as well as in the
environment, and the job resolves it every night, so a change there needs no
restart. Every platform's settings file lists it.

LDAP background sync looked a user up by id without LDAP_USER_SEARCH_FILTER,
so an account the filter excludes - one disabled in Active Directory - could
not log in but was still "found". It was never disabled, and a manual
disable was undone on the next run. The filter is now ANDed into the lookup.
An account disabled for inactivity is not re-enabled by the sync.

From the patch by Raymond-Voogt, with the setting moved into the Admin
Panel's login settings. Tests: tests/inactiveUsers.test.cjs,
tests/ldapBackgroundSync.test.cjs, tests/ldapUserIdFilter.test.cjs,
tests/authConfigCatalog.test.cjs and
tests/playwright/specs/inactive-users-last-active.e2e.js.

Thanks to Raymond-Voogt and xet7 !

Fixes #6783,
Fixes #6784,
Fixes #6785.
2026-10-19 17:35:51 +03:00
Lauri Ojansivu ad51a03731 Log in by full-page redirect by default with OAuth2/OIDC, Google & co, SAML and CAS.
Every login that chooses between a popup and a redirect opened a popup by
default. Google's sign-in pages, and other identity providers', can send
Cross-Origin-Opener-Policy, which makes Meteor's popup look closed at
once: the login was tried before the provider answered, and the user
was back on the sign-in page with no error. Popups are also blocked in
iframes and on some phones. The full-page redirect has no popup to lose.

- OAUTH2_LOGIN_STYLE (OAuth2/OIDC): redirect unless it says popup, in the
  server, the Admin Panel catalog and the samples.
- OAUTH_PROVIDERS_LOGIN_STYLE (Google, GitHub, Facebook, X, Meteor
  Developer, Weibo, Meetup): redirect by default, in the code, Dockerfile,
  snap, Sandstorm package and samples.
- SAML: both identity-provider profiles log in by redirect;
  SAML_LOGIN_FLOW=popup still chooses the popup, and the client no longer
  falls back to a popup while the configuration loads.
- CAS: redirects unless "popup": true. Its redirect could never finish:
  nothing called Meteor.initCas, which the package now does at startup.
  The sign-in page also passed username and password as loginWithCas's
  options and callback, so its callback never ran, and the CAS redirect
  page echoed the request address into HTML unescaped.

A redirect login's error now reaches the reloaded sign-in page, from
accounts-oauth's page-load hook and the SAML and CAS events, instead of
the page coming back silently.

Verified against a freshly built and prepared bundle with the local
identity-provider suite and no login style set: OIDC, SAML, CAS and all
seven Meteor providers log in by redirect, and each refusal is shown on
the sign-in page (31 of 31 with Chromium). Its LDAP wrong-password case
expected wording that changed in 679a8b3499 and is corrected.

Thanks to xet7 !
2026-10-08 15:18:59 +03:00
Lauri Ojansivu dfcd115ff3 Let accounts created by an OAuth2/OIDC login join a default organization.
Organizations could gain new users automatically by email domain, but users
who register through one identity provider - the reporter's Nextcloud -
often share no domain, so they could not be grouped. OAUTH2_DEFAULT_ORGANIZATION,
or its field under Admin Panel / People / OAuth2, names an existing
organization (by short name, display name or id) that every account created
by an OAuth2/OIDC login joins, beside the domain rule. A name that matches no
organization creates none: the login goes on and the server log says so.

Listed on every platform, with snap help lines for it and for
DEFAULT_AVATAR_URL and OAUTH_PROVIDERS_ALLOWED_EMAIL_DOMAINS, which lacked
them.

Thanks to vasyugan and xet7 !

Fixes #5339.
2026-10-08 11:58:16 +03:00
Lauri Ojansivu c1d1a04790 Implement automatic logout with LOGOUT_WITH_TIMER and the LOGOUT_* settings.
The snap, Docker, docker-compose and start scripts have offered
LOGOUT_WITH_TIMER, LOGOUT_IN, LOGOUT_ON_HOURS and LOGOUT_ON_MINUTES since
2018, but the code that read them was removed with the job queue it ran on,
so they did nothing. Per the maintainer decision of 2026-10-08 they work
again. A login ends LOGOUT_IN days after it was made, or at
LOGOUT_ON_HOURS:LOGOUT_ON_MINUTES server time (the next such time, or on the
day LOGOUT_IN days later). Once a minute the server removes the expired
login tokens in one query, and Meteor signs out the browsers that used them.
The four settings are overridable in Admin Panel / People / Login like the
other login variables, with hours and minutes bounded. An unusable
combination signs nobody out and the server log says why.

tests/logoutTimer.test.cjs checks the one-query cutoff against the
per-login deadline over two years of logins in three time zones, two of them
with daylight saving time.

Thanks to xet7 !
2026-10-08 11:03:50 +03:00
Lauri Ojansivu a7628504f1 Make header login settings environment-only.
With HEADER_LOGIN_ID and HEADER_LOGIN_TRUSTED_IPS set, a proxy at a trusted
address signs in as anyone it names. Since the 2026-10-05 Admin Panel work a
site administrator could switch that on from People / Header login, so a
stolen administrator session was enough to open every account. Per the
maintainer decision of 2026-10-08 the six HEADER_LOGIN_* settings now come
from the environment only: a value stored in the Admin Panel is ignored, the
pane shows the values in effect read-only with no Save button, and a save sent
by hand is refused and recorded in Admin Panel / Problems as ProxyBleed
(authn.header-login-env-only). Every other login section stays overridable.

New text is added in English only, pending Transifex.

Thanks to xet7 !
2026-10-08 10:41:59 +03:00
Lauri Ojansivu 0314406656 Read login secrets from *_FILE, and let the Admin Panel override DEFAULT_AUTHENTICATION_METHOD.
LDAP_AUTHENTIFICATION_PASSWORD_FILE and OAUTH2_SECRET_FILE were listed in the
Dockerfile, snap, docker-compose and start-wekan since #5724, but no code read
them, so a password could only be an environment variable. WeKan now reads the
file itself, at each login (a rotated secret applies at once), so the password
is never in the environment - the point of Docker / Kubernetes secrets. The
order is the Admin Panel, the variable, then its file; one trailing line break
is dropped. The application code is the same on every platform, so it works in
Docker, the snap (files under /var/snap/wekan/common), bundles, AppImage,
Flatpak, Mac and Windows. Admin Panel / People shows when the password comes
from the file and when the file cannot be read, never the path or content.
The path itself is an environment variable only: settable in the Admin Panel
next to the LDAP host or the OAuth2 token endpoint, it would let the server
read any file and send it there as the password.

DEFAULT_AUTHENTICATION_METHOD is a field of the Login pane's settings form.
Choosing a method overrides the variable; Default gives it back. Before, the
variable rewrote the stored method at every start, so an administrator's
choice was lost on restart. The published method is now the override, else the
variable, else password. On upgrade, a method chosen with the old dropdown
while no variable was set becomes the override, once, so it is not lost. The
old dropdown is removed: two controls for one setting on one page.

The snap key for the LDAP password file was spelled
ldap-authentification-password-file, unlike its siblings and its help text;
it is ldap-authentication-password-file now (it had no effect before).
MAIL_SERVICE_PASSWORD_FILE, MONGO_PASSWORD_FILE and S3_SECRET_FILE are still
not read by WeKan; secrets/README.md says so.

Thanks to Roemer, CrashOverride-lab, ww-daniel-mora and xet7 !
2026-10-05 21:11:12 +03:00
Lauri Ojansivu eb49a4b1b6 Override every login environment variable in Admin Panel / People.
Each login method has its own section: LDAP, OAuth2 (OpenID Connect and
Oracle OIM), CAS and Header login are new or complete, and the Login pane
gets PASSWORD_LOGIN_ENABLED and ACCOUNTS_COMMON_LOGIN_EXPIRATION_IN_DAYS.
models/lib/authConfigCatalog.js lists all 103 variables; server/lib/
authConfig.js resolves each one at run time (Admin Panel value first, then
the environment variable) for the app and, through
globalThis.__wekanAuthEnv, for the wekan-ldap, wekan-oidc and
wekan-accounts-cas packages. OAuth2 and CAS service configurations and LDAP
background sync are reapplied when their settings are saved.

Passwords and client secrets (LDAP_AUTHENTIFICATION_PASSWORD, OAUTH2_SECRET)
never reach the browser: the page learns only whether one is set and where
it comes from. Other values have credentials written inside a URL masked on
the server, and a URL field refuses them.

Fixed on the way:
- The Admin Panel LDAP overrides never applied. The bridge read Settings with
  a server-side findOne(), which Meteor 3 refuses; the error was swallowed and
  the environment used. The settings are now held in an observed cache.
- LDAP Test connection never existed on the server (testConnection.js was not
  imported) and used the synchronous Meteor.user().
- PROPAGATE_OIDC_DATA=false turned the feature on.
- CAS read only the misspelled CASE_VALIDATE_URL; CAS_VALIDATE_URL now works
  and the old name still does.
- snap help named three group-filter keys snap set does not know.

Every catalog variable is now listed in the Dockerfile, the docker-compose
files, snap config and help, and start-wekan.sh/.bat; 14 were missing.
tests/authConfigCatalog.test.cjs pins resolution, secrets, input validation,
platform coverage, and - across the whole tree - that no code reads a login
variable outside the catalog or straight from process.env, and that no
server code calls the synchronous Settings.findOne() or Meteor.user().
tests/playwright/specs/admin-login-env-overrides.e2e.js drives the pages.

Thanks to xet7 !
2026-10-05 19:48:48 +03:00