• Web server: browser sessions owned by the server (one sign-in for webv

    From Rob Swindell@VERT to GitLab issue in main/sbbs on Sun Nov 22 12:32:32 2026
    open https://gitlab.synchro.net/main/sbbs/-/work_items/1398
    2026-11-22 12:32:32 -0800

    ## Summary

    Add a browser session to the Web Server itself: a sign-in that the server owns, a session cookie it issues and checks, and the signed-in user made available to every request (static files, file areas, server-side JavaScript and CGI). The web applications that now each keep their own sign-in (webv4, WebMail, and optionally DokuWiki) could then use one sign-in and one sign-out, with one set of session rules.

    ## Today

    The Web Server and the applications it serves use four unrelated ways to sign in (not counting the legacy web UI):

    | | How the user signs in | Session |
    |---|---|---|
    | Web Server: `webctrl.ini` `AccessRequirements`, and restricted file areas under `FileVPathPrefix` (listed by `webfileindex.ssjs`) | HTTP Basic or Digest (the browser's own password prompt) | None: the credentials are sent with every request |
    | webv4 | Its own form | `synchronet` cookie `<usernum>,<key>`; the key is kept in plain text in `data/user/####.web`; one session per user (signing in elsewhere ends the others); no expiry while the cookie lasts; every request calls `login()` with the password read from the user record |
    | WebMail | Its own form, or from a webv4 session (`webv4_login`, `webv4_logout`, `webv4_only`, #1395) | `webmail` cookie; keys kept only as SHA-256 hashes in the user's `webmail.sessions.json`; several sessions per user; idle and absolute expiry; ended by a password change |
    | DokuWiki (not a stock component, but used on Vertrauen's wiki) | DokuWiki's own form, through the `authsbbs` auth plugin | DokuWiki's PHP session |

    Consequences:

    - A user can be asked to sign in up to four times, and signing out of one leaves the others signed in. #1395 tied webv4 and WebMail together by hand; each further application would need the same.
    - A webv4 or WebMail sign-in does not open a restricted file area or a location protected by `AccessRequirements`: those check only HTTP Basic/Digest.
    - The session rules differ widely, and the weakest (webv4's plain-text key with no expiry) sets the protection of anything that trusts it (WebMail with `webv4_login`).
    - The `authsbbs` DokuWiki plugin reads `user.tab` and compares the password itself, so a failed wiki sign-in is not counted by the BBS (no failed-login logging, no temporary ban) and the wiki accepts only the exact alias, not the forms the BBS's own login accepts (for example "digitalman" for "Digital Man").

    ## Proposal

    The Web Server keeps browser sessions, as Apache httpd does with `mod_auth_form` and `mod_session`, and as the "forward auth" setups in front of nginx, Traefik and Caddy do:

    1. **Sign-in and sign-out owned by the server.** A sign-in form (and a script method, for example `http_request.login(name, password, keep)`) checks the password the way the other servers do (same name lookup, same failed-login counting and filtering) and issues a session cookie: random key, `HttpOnly`, `Secure` when the request is HTTPS, `SameSite=Lax`, scoped to the host. A sign-out method ends it. A new session is issued at every sign-in (no session fixation), and the sign-in form needs protection against cross-site request forgery.
    2. **Sessions kept on the server.** Only a hash of each key is stored (as WebMail's `session.js` does now); several sessions per user; idle and absolute expiry; a "keep me signed in" lifetime; every session of a user ends when the password changes; a list of a user's sessions, so a user (or sysop) can end them. WebMail's `webmail/lib/session.js` is close to the specification needed.
    3. **The user resolved before anything else runs.** For each request with a valid session cookie, the server sets the request's user before checking `webctrl.ini` access rules or file-area access and before running any script, so:
    - `AccessRequirements` and restricted file areas honor a browser session, not only HTTP Basic/Digest;
    - server-side JavaScript gets `user` without handling a cookie itself;
    - CGI programs get the standard `REMOTE_USER` (and `AUTH_TYPE`), which is how external applications such as DokuWiki can trust the server's sign-in.
    4. **HTTP Basic and Digest stay**, for clients that are not browsers (download tools, scripts).

    Then, each as its own step:

    - **WebMail** uses the server session instead of its own cookie. `webv4_login`, `webv4_logout` and `webv4_only` become unnecessary on a host where both use it.
    - **webv4** uses the server session instead of the `synchronet` cookie and the `data/user/####.web` key, which also removes the per-request `login()` with the stored password. The old cookie should be honored for a transition period, since sysops' webv4 mods and scripts assume it.
    - **DokuWiki**: the `authsbbs` plugin implements `trustExternal()` (DokuWiki's hook for accepting a user the web server has already authenticated) and takes the user from `REMOTE_USER`. The wiki then never sees a password, its sign-ins are counted by the BBS, and every alias form the BBS accepts works. The name passed to DokuWiki must be normalized as `authsbbs` normalizes it now, so existing page history and ACLs (`@admin`, per-user rules) still match.

    ## Questions to settle

    - **Host names.** Cookies are per host, and the wiki (wiki.synchro.net) and webv4 (web.synchro.net) are different hosts. Sharing one session across them needs a cookie for the parent domain, which every application on every subdomain would then receive. Options: sessions per host only (the default), an explicit setting for a parent-domain cookie, or a sign-in hand-off between hosts by redirect.
    - **Shared fate.** With one session for a whole host, a cross-site scripting or request-forgery bug in any application there can act as the user everywhere on it, mail included. The server's defaults should follow WebMail's stricter rules (HTTPS-only option, idle expiry, `SameSite`), not webv4's.
    - **Configuration.** Opt-in at first: per host or per directory (`webctrl.ini`), with the session lifetimes in `sbbs.ini` `[Web]` (and SCFG).
    - **Storage.** Where the session table lives (per user under `data/user/####/`, as WebMail's is, or one file per server), and how it behaves when several BBS hosts share the data directory.

    ## Related

    - #1395: webv4 and WebMail sign-in and sign-out tied together by hand.
    - #1206: the web server never supported TLS-PSK authentication (dropped from the default `Authentication` list); HTTP Basic and Digest are its only sign-in methods.
    - Prior art: Apache httpd `mod_auth_form` + `mod_session` (`mod_session_cookie`, `mod_session_crypto`, `mod_session_dbd`), `mod_auth_tkt`, `mod_auth_openidc`; nginx `auth_request`, Traefik ForwardAuth and Caddy `forward_auth` with oauth2-proxy, Authelia or Authentik; IIS forms authentication in integrated mode.

    - *Authored by Claude (Claude Code), on behalf of @rswindell*

    ---
    þ Synchronet þ Vertrauen þ Home of Synchronet þ [vert/cvs/bbs].synchro.net
  • From Rob Swindell@VERT to GitLab note in main/sbbs on Sun Nov 22 12:36:18 2026
    https://gitlab.synchro.net/main/sbbs/-/work_items/1398#note_11282

    ## DokuWiki integration plan

    Most of the server side exists already: when a request is authenticated, the Web Server gives CGI programs `REMOTE_USER` (the user's alias) and `AUTH_TYPE` (`websrvr.cpp`, where the CGI environment is built), and DokuWiki's PHP runs as CGI (`php-cgi` in `ctrl/web_handler.ini`). Today only HTTP Basic/Digest sets them, and those can only be required for a whole location, which would make every wiki reader sign in. With the browser session proposed here, a valid session cookie would set them too, and an anonymous reader would simply have no `REMOTE_USER`.

    ### Web Server

    - A sign-in page and a sign-out address, served by the Web Server on any host, that take a "return to" address, so an application can send a user there and get them back.
    - The session cookie must reach the wiki's host (wiki.synchro.net on Vertrauen): either the user signs in on that host, or the parent-domain cookie option from "Questions to settle" is used.

    ### authsbbs plugin (`main/extra/authsbbs`)

    1. **Trust the server.** Set `cando['external'] = true` and implement `trustExternal()`: when `REMOTE_USER` is set, look the user up in `user.tab` and fill in DokuWiki's user information (name, e-mail, groups) without any password; when it is not, the visitor is anonymous. DokuWiki calls `trustExternal()` on every request, so a sign-out at the server ends the wiki sign-in at once.
    2. **Drop `checkPass()`.** The plugin now reads the password column of `user.tab` and compares it in PHP. After this it never reads a password, which also keeps it working if passwords move out of `user.tab` (the hashed-password storage design, `data/user/pass.tab`).
    3. **Send sign-in and sign-out to the server.** DokuWiki's "Log In" action redirects to the server's sign-in page with a return address, and `logOff()` to the server's sign-out, through two new plugin settings (for example `login_url` and `logout_url`).
    4. **Keep everything else.** Groups still come from `user.tab` as now: `admin` for security level 90 or more or the configured flag (`adminFlag`), `readonly` for the `P` restriction, `guest` for `G`; the user list and counts are unchanged.

    ### User names

    `REMOTE_USER` is the account's own alias (for example "Digital Man") however the user typed it when signing in, so every name form the BBS accepts works for the wiki too. The plugin keeps reporting names case-insensitively, so DokuWiki records "digital man", the form most existing wiki history already uses; ACL rules naming users keep matching. Older history entries under another spelling (Vertrauen's wiki has entries for both "digital man" and "digitalman") stay as they are.

    ### Result

    - Every alias form the BBS accepts can be used to sign in to the wiki.
    - Wiki sign-ins are counted by the BBS: failed-login logging and temporary bans apply.
    - The wiki never sees or stores a password.
    - One sign-in and one sign-out cover the wiki, webv4 and WebMail on hosts that share the session.

    Until the browser session exists, the only server-side route is requiring HTTP authentication for the whole wiki location, which would make every reader sign in, so this waits for the session work.

    - *Authored by Claude (Claude Code), on behalf of @rswindell*

    ---
    þ Synchronet þ Vertrauen þ Home of Synchronet þ [vert/cvs/bbs].synchro.net
  • From Rob Swindell@VERT to GitLab note in main/sbbs on Sun Nov 22 12:38:40 2026
    https://gitlab.synchro.net/main/sbbs/-/work_items/1398#note_11283

    ## Two more points to settle

    ### Concurrent sessions per user

    The proposal lets a user have several sessions at once (a phone and a desktop both signed in), as WebMail does now (at most 30; creating one more drops the least recently used). Each device's sign-out ends only its own session; a password change, or a "sign out everywhere", ends all of them.

    That differs from webv4 today, which keeps a single key per user in `data/user/####.web`: signing in on a second device replaces the key, which quietly signs out the first. Moving webv4 onto server sessions therefore also means:

    - **Per-session state.** webv4 keeps `ip_address`, `session_start`, `csrf_token` and the user's current activity (`action`, `xtrn`, read by its who's-online and node list displays) in that same per-user file. With several sessions these would overwrite each other. The CSRF token in particular must belong to each session, or one device's page fails the other's check. The activity can stay per user ("last seen doing").
    - **Logon records.** webv4 adds a logon list entry when a session starts (or after its `timeout` passes). With several sessions that is one entry per device.

    Concurrent use is not new outside the Terminal Server: WebMail, HTTP Basic/Digest, FTP and the mail servers already allow a user to be connected from several places at once. On the Terminal Server, being on more than one node at a time needs the `G` exemption (Multiple Nodes). Whether web sessions should follow that rule (one session per user unless the user has the `G` exemption, a second sign-in then either refused or ending the first) is a choice to make; the proposed default is several sessions per user, as WebMail has, perhaps with a setting for a lower limit.

    ### Sessions survive recycles and restarts

    Sessions are kept on disk, not only in the server's memory, so a Web Server recycle or restart (or a restart of the whole BBS) does not sign anyone out: the next request with a valid cookie is recognized as before. Expiry is by the clock (idle time and absolute lifetime), so time that passes while the server is down still counts. This is how WebMail's sessions (`webmail.sessions.json`) and webv4's keys (`data/user/####.web`) already behave; the server may cache sessions in memory, but the files are what count.

    Since only a hash of each session key is stored, the session files cannot be used to forge a cookie. A sysop who wants every user signed out (after a suspected compromise, say) removes the session files, or uses a "sign out every user" control, to be added with the feature.

    - *Authored by Claude (Claude Code), on behalf of @rswindell*

    ---
    þ Synchronet þ Vertrauen þ Home of Synchronet þ [vert/cvs/bbs].synchro.net
  • From Rob Swindell@VERT to GitLab note in main/sbbs on Sun Nov 22 12:39:47 2026
    https://gitlab.synchro.net/main/sbbs/-/work_items/1398#note_11284

    ## Session limits: configurable, possibly per user

    The number of sessions a user may have at once, and the session lifetimes, should be configurable rather than fixed (WebMail's 30 sessions per user is a constant in its code today). Up for discussion is whether a limit can also differ by user, for example by security level or an access requirement string (ARS), as other per-user limits in Synchronet do. For example:

    - a system-wide default limit (and idle and absolute lifetimes, and the "keep me signed in" lifetime) in `sbbs.ini` `[Web]`, editable in SCFG;
    - optionally, overrides selected by ARS (say, sysops or a trusted level allowed more sessions or longer lifetimes, guests or new users fewer), with the first matching rule winning;
    - a limit of 1 giving today's webv4 behavior, and the `G` (Multiple Nodes) exemption possibly lifting a limit, as it does on the Terminal Server.

    To settle: where per-user rules are configured (the security level definitions in SCFG, or a list of ARS rules in an .ini file), and what a sign-in beyond the limit does: end the least recently used session (as WebMail does) or refuse the new sign-in.

    - *Authored by Claude (Claude Code), on behalf of @rswindell*

    ---
    þ Synchronet þ Vertrauen þ Home of Synchronet þ [vert/cvs/bbs].synchro.net
  • From Rob Swindell@VERT to GitLab note in main/sbbs on Sun Nov 22 13:35:39 2026
    https://gitlab.synchro.net/main/sbbs/-/work_items/1398#note_11285

    ## SWAG (SPAM and SWAPI) as a client of the server session

    echicken's SWAG projects, SPAM (swag/spam, a React front end) and SWAPI (swag/swapi, the Synchronet Web API it calls), are the planned successor to webv4, so the browser session should serve them too.

    SWAPI's sign-in today (src/lib/jwt.ts, src/lib/auth.ts, src/lib/http-request.ts):

    - A stateless HS256 JWT, sent in a `swapiToken` cookie or an `Authorization: Bearer` header. The signing key is the system password plus the user's password, so a password change voids every token.
    - Tokens last `session_ttl` seconds (one hour by default) and are reissued on use.
    - Sign-out only clears the cookie: a token cannot be revoked on the server before it expires (marked as a to-do in its `logout()`).
    - Anonymous visitors are signed in as a `webguest` user.
    - The cookie cannot be `HttpOnly` or carry `SameSite`, because the Web Server's `set_cookie()` takes only name, value, expiry, domain, path and `secure`. (WebMail writes its own `Set-Cookie` header to get those.)

    With server-owned sessions, SWAPI would not need its own token: the request's `user` would already be set (or be the anonymous/guest user), sign-in and sign-out would go through the server, and revocation, `HttpOnly`/`SameSite`, expiry and the per-user limits discussed above would come with it. A `Bearer`-style token for non-browser API clients may still be worth keeping, either SWAPI's own or a server-issued equivalent.

    Separately from this issue, `set_cookie()` should gain `HttpOnly` and `SameSite` options, so scripts do not have to build `Set-Cookie` headers by hand to get them.

    - *Authored by Claude (Claude Code), on behalf of @rswindell*

    ---
    þ Synchronet þ Vertrauen þ Home of Synchronet þ [vert/cvs/bbs].synchro.net