Files
wekan/docs/Features/Login-Page/WindowsSSO.md
T
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

88 lines
4.2 KiB
Markdown

# Windows single sign-on (Kerberos / NTLM)
[#5758](https://github.com/wekan/wekan/issues/5758).
Members who are already signed in to their Windows domain account can sign in
to WeKan with **Sign in with Windows**, without typing a password. The browser
proves who they are with Kerberos or NTLM ("Integrated Windows Authentication"),
through [node-expose-sspi](https://github.com/jlguenego/node-expose-sspi).
**Status:** built without a Windows domain to test against. The decisions it
makes (which accounts are allowed, which WeKan account they sign in to) are
tested; the handshake itself has not been run. Reports are welcome in #5758.
## Requirements
- WeKan running **on Windows**, as a member of the domain (the
[Windows bundle](../../Platforms/Propietary/OS/Windows/Offline.md) with
`start-wekan.bat`). On Linux, macOS, Docker and Snap this login is never
offered; use [Header login](Header-Login.md) behind IIS or
[LDAP](LDAP.md) instead.
- WeKan reached **directly**, without a reverse proxy in between. NTLM
authenticates the TCP connection, and a proxy that opens its own connections
to WeKan breaks the handshake. Kerberos through a proxy needs the proxy to
pass the `Authorization: Negotiate` header unchanged.
- **node-expose-sspi**, installed into the bundle. It is Windows-only, so it is
not a dependency of WeKan that every platform downloads:
```
cd C:\wekan\bundle\programs\server
npm install node-expose-sspi@0.1.60
```
WeKan looks for it in `bundle\programs\server` and in the bundle directory.
Without it, WeKan logs `Windows SSO: ... node-expose-sspi is not installed`
and does not show the button.
## Settings
In `start-wekan.bat`:
```
SET WINDOWS_SSO_ENABLED=true
SET WINDOWS_SSO_DOMAINS=CONTOSO
REM optional
SET WINDOWS_SSO_ACTIVE_DIRECTORY=true
SET WINDOWS_SSO_MERGE_EXISTING_USERS=false
```
Each setting below is also in **Admin Panel / People / Login**: a value set
there wins, an empty field falls back to the variable, and a change applies at
once.
| Variable | Meaning |
| --- | --- |
| `WINDOWS_SSO_ENABLED` | `true` turns it on (Windows only). |
| `WINDOWS_SSO_DOMAINS` | **Required.** The domains allowed to sign in, comma separated: short names (`CONTOSO`) or DNS names (`contoso.example.com`). Empty means **nobody**, so that accounts from a trusted domain are not let in by accident. |
| `WINDOWS_SSO_ACTIVE_DIRECTORY` | `true` reads the member's display name and e-mail address from Active Directory. |
| `WINDOWS_SSO_MERGE_EXISTING_USERS` | `true` signs a Windows account in to an existing WeKan account with the same username, or the same e-mail address. Off by default: a local `alice` is not necessarily the domain's alice. |
The browser has to be willing to send Windows credentials to WeKan's address:
add it to the **Local intranet** zone (Internet Options, or the
`Site to Zone Assignment List` group policy) for Edge and Chrome, and to
`network.negotiate-auth.trusted-uris` (and `network.automatic-ntlm-auth.trusted-uris`
for NTLM) in Firefox.
## How it works
1. The sign-in page shows **Sign in with Windows**, a link to `/sso/windows`.
2. There, WeKan answers with `401 WWW-Authenticate: Negotiate`, and the browser
answers with the Windows sign-in. node-expose-sspi checks it with Windows
itself (SSPI).
3. WeKan checks the domain against `WINDOWS_SSO_DOMAINS` (a machine account,
`NAME$`, is never accepted), then finds the member:
- the WeKan account this Windows account signed in to before
(`services.windowsSso.id`, e.g. `contoso\alice`);
- else, with `WINDOWS_SSO_MERGE_EXISTING_USERS=true`, the account with the
same username, or the same Active Directory e-mail address;
- else a new account, under the Windows username, or `alice-2`, `alice-3`
... when that is taken.
4. WeKan redirects to `/sign-in?windowsSso=<token>`. The token is random, kept
only as its SHA-256, valid for one minute and used once. The page signs in
with it through the ordinary login checks: a deactivated account, and an
account its member locked to [SQRL](SQRL.md) with `sqrlonly`, are refused
as with any other way of signing in.
If something goes wrong, the sign-in page says "Windows sign-in failed". Set
`DEBUG=true` to see the reason in WeKan's log.