open
https://gitlab.synchro.net/main/sbbs/-/work_items/1425
2026-11-24 19:59:09 -0800
## Summary
Let the Web Server act as an OpenID Connect (OIDC) identity provider, built on the server-owned browser session proposed in #1398, so that web applications the Synchronet Web Server does **not** serve can use a Synchronet sign-in. The first target is the GitLab web UI (gitlab.synchro.net on Vertrauen); the same endpoints would also serve DokuWiki, SWAG/SPAM and applications on other host names.
## Why #1398 alone does not reach GitLab
#1398 makes the session available to what the Web Server itself serves: static files, file areas, server-side JavaScript, and CGI programs through `REMOTE_USER`. GitLab is outside that:
- It runs behind its own bundled nginx, on a different host name (and, on Vertrauen, a different IP address), so its requests never pass through the Synchronet Web Server.
- It has no trusted-header sign-in (no `REMOTE_USER` equivalent). A forward-auth check in front of its nginx (`auth_request`) could only block requests; it could not sign a user in to GitLab.
- The ways it accepts an outside sign-in are LDAP, SAML and OmniAuth providers such as OpenID Connect. LDAP would need an LDAP server in Synchronet and would only check the same password a second time, not give one sign-in. OIDC is the closest fit.
## Proposal
Add OIDC provider endpoints to the Web Server, next to the #1398 sign-in and sign-out pages:
- discovery: `/.well-known/openid-configuration`
- authorization endpoint (authorization code flow, with PKCE)
- token endpoint
- userinfo endpoint
- signing keys (JWKS), if ID tokens are signed with RS256 or ES256
At the authorization endpoint, a request with a valid #1398 session cookie is answered at once with a redirect back to the application; without one, the user is sent to the server's sign-in page and returned afterwards. So a user already signed in to the BBS web site signs in to GitLab with one click and no password, and `omniauth_auto_sign_in_with_provider` on the GitLab side can remove even that click.
This is the "sign-in hand-off between hosts by redirect" option from the "Host names" question in #1398, in a standard form. It may also answer that question for DokuWiki on wiki.synchro.net (through a DokuWiki OIDC plugin, as an alternative to `REMOTE_USER`), without a parent-domain cookie.
### Claims
- `sub`: a stable identifier that survives an alias change (the user number, or a value derived from it; not the alias).
- `preferred_username` / `name`: the alias and real name, normalized as in #1398 for DokuWiki.
- `email` and `email_verified`: see "Account linking" below.
- Optionally, groups from security level or flags, as the `authsbbs` DokuWiki plugin derives `admin`, `readonly` and `guest` now.
### Client registry
Each application is registered by the sysop: client ID, client secret, allowed redirect URIs, and optionally an access requirement string (ARS) a user must meet to sign in to that client. Configured in a `ctrl/` file and SCFG. The authorization endpoint accepts only exact registered redirect URIs.
## GitLab side
An `openid_connect` entry in `gitlab_rails['omniauth_providers']` in `gitlab.rb`, pointing at the discovery URL, with the client ID and secret.
- `after_sign_out_path` set to the server's sign-out address, so that signing out of GitLab ends the BBS session too.
- **No automatic linking by e-mail address.** BBS e-mail addresses are not verified, so linking on e-mail would let anyone who sets a matching address on a BBS account take over the GitLab account that has it. Existing GitLab users link their Synchronet identity from their GitLab profile instead. The provider should send `email_verified: false` unless an address really has been verified.
- Whether new GitLab accounts created through this sign-in are active at once or held for approval (`omniauth_block_auto_created_users`) is the GitLab admin's choice.
- Password sign-in should stay available, at least for administrators, so that a broken BBS or Web Server does not lock everyone out of GitLab.
- Git over HTTPS still uses personal access tokens or SSH keys; OIDC covers only the web UI.
## Limits
- **Sign-out is one-way.** GitLab keeps its own session once a user is in. A sign-out at the BBS, a password change, or a "sign out everywhere" from #1398 does not end an open GitLab session; it lasts until GitLab's own session expires. OIDC back-channel logout would close this gap if the client supports it (to be checked for GitLab CE).
- **Shared fate.** One BBS session then opens every registered application, as noted under "Shared fate" in #1398.
## Questions to settle
- ID token signing: HS256 with the client secret (no key management) or RS256/ES256 with published keys. Which algorithms GitLab's `openid_connect` strategy accepts needs checking.
- Whether refresh tokens are issued at all (GitLab's web sign-in does not need them).
- Consent: whether a user is asked to approve each client once, or registered clients are trusted silently (reasonable for applications the sysop registers).
- Where authorization codes are kept (short-lived; memory may do) and how this behaves when several BBS hosts share the data directory.
## Related
- #1398: server-owned browser sessions (prerequisite).
- #280: trusted reverse proxy for the Web Server.
- Prior art: Keycloak, Authelia, Authentik and Dex as OIDC providers; GitLab's own OmniAuth `openid_connect` provider.
- *Authored by Claude (Claude Code), on behalf of @rswindell*
---
þ Synchronet þ Vertrauen þ Home of Synchronet þ [vert/cvs/bbs].synchro.net