mirror of
https://github.com/D-Modem/login.git
synced 2026-11-28 20:38:06 -08:00
The program is dmodem-login (like dmodemd and dmodem-ari), the Go module github.com/D-Modem/login, the site d-modem.github.io/login. Its files, units, sockets, PAM service, pppd plugin, environment (DMODEM_LOGIN_*) and nftables tables follow. An old installation keeps working: - make install puts a modemmenu link to dmodem-login, and a modemmenu.so link to the plugin, which also takes its old modemmenu-socket option - the default configuration, users file, state_dir and PAM service fall back to modemmenu's when only those are there (config.Legacy) docs/rename.md (Simplified Technical English) lists the new names and what an old installation must change (the -serve socket, the units, the /etc/modemmenu files, the old nftables tables). CI's bbs job moves a bbs that still imports github.com/D-Modem/menu to the new path. The pppd plugin builds clean with -Wall -Wextra on GCC and Clang. COMMERCIAL-LICENSE.md and CONTRIBUTING.md (legal text) are not changed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01B82eRTD8BSptdpaUWGcs65
141 lines
7.0 KiB
Markdown
141 lines
7.0 KiB
Markdown
# Authentication
|
|
|
|
This page tells how dmodem-login checks the name and password of a caller, and how a caller can change the password.
|
|
|
|
## Authentication
|
|
|
|
|
|
`[general] auth` lists the backends. dmodem-login asks them in that
|
|
sequence. If a backend does not know the user, dmodem-login asks the next
|
|
backend. If a backend knows the user and the password is wrong, the
|
|
attempt ends there. If a backend does not operate (LDAP is not
|
|
available, or there is an SQL error), dmodem-login records this in the log
|
|
and skips the backend.
|
|
|
|
- **file**: `user:password` lines. The password is one of these:
|
|
a bcrypt hash (`dmodem-login -hash` prints one), `{SHA256}`/`{SHA512}`
|
|
(hex or base64), `{SSHA256}`/`{SSHA512}` (salted, base64) or
|
|
`{PLAIN}text`. dmodem-login reads the file at each login.
|
|
- **ldap**: a bind as the user. The bind goes to `bind_dn` with `{user}`
|
|
in it, or to the entry that `search_filter` finds under `search_base`.
|
|
dmodem-login supports ldaps://, StartTLS and a private CA. Put a group
|
|
check in the filter (`memberOf=...`). dmodem-login escapes the values for
|
|
DNs and filters.
|
|
- **sql**: `query` gets the user (and, as an option, the password) as
|
|
arguments. It returns the stored password, and dmodem-login checks it in
|
|
the same way as for the file. Alternatively, with `hash = none`, a row
|
|
in the result means that the login is correct. Use this for a database
|
|
that checks passwords itself (`crypt()` in PostgreSQL).
|
|
- **system** (or **pam**): the accounts of the machine, through PAM.
|
|
Refer to the section below.
|
|
|
|
User names must agree with `user_pattern` (by default, letters, digits
|
|
and `._@-`). After a wrong login, dmodem-login waits `fail_delay` seconds.
|
|
A login with an unknown user takes the same time as a login with a known
|
|
user. dmodem-login hangs up the call after `attempts` tries or after
|
|
`login_timeout`.
|
|
|
|
## System accounts (PAM)
|
|
|
|
|
|
`auth = system` runs the auth and account stacks of the PAM service
|
|
`pam_service` (by default, `dmodem-login`). Thus local accounts operate, and
|
|
all other items that PAM has a configuration for (sssd, Kerberos, OTP
|
|
modules). PAM does its own checks for expired and locked accounts. This
|
|
backend must have a build with PAM (refer to
|
|
[Building](building.md)). To configure it, do these steps:
|
|
|
|
1. Install the PAM service. `make install` puts
|
|
[dmodem-login.pam.sample](../samples/dmodem-login.pam.sample) in `/etc/pam.d/dmodem-login`.
|
|
The sample uses `common-auth`, `common-account` and, for password
|
|
changes, `common-password` of the distribution.
|
|
2. For local accounts, run Asterisk (and thus dmodem-login) as root.
|
|
`pam_unix` checks the passwords of other users only for root.
|
|
3. Add `system` to `[general] auth`. Then set these options in
|
|
`[system]`:
|
|
|
|
| option | default | |
|
|
|---|---|---|
|
|
| `pam_service` | `dmodem-login` | the file in `/etc/pam.d` |
|
|
| `min_uid` | `1000` | accounts below this value (system accounts) cannot log in |
|
|
| `allow_root` | `no` | `yes` lets root log in |
|
|
| `groups` | | only members of these groups can log in (membership or primary group) |
|
|
|
|
If these rules refuse an account, the account is "unknown" to this
|
|
backend. dmodem-login asks the next backend and records the reason in the
|
|
log. With `run_as = {user}`, a selection (for example, the shell) runs
|
|
as the account of the caller.
|
|
|
|
## Changing passwords
|
|
|
|
|
|
A `mode = passwd` item lets callers change their own password. The
|
|
item does not have a command. By default, it goes back to the menu
|
|
(`after = menu`). The caller does these steps:
|
|
|
|
1. Type the current password.
|
|
2. Type the new password two times. The new password must have a minimum
|
|
of `min_password` characters of the item (8 by default). It must be
|
|
different from the current password. The caller has three tries.
|
|
|
|
dmodem-login checks the current password against the backends again. This
|
|
check also finds the backend that holds the account. A login by caller
|
|
ID or by an upstream menu does not give this information. The password
|
|
changes in that backend:
|
|
|
|
| backend | how |
|
|
|---|---|
|
|
| file | dmodem-login writes the line of the user again in the same location, under the lock of the file. It keeps a note after the hash. The password is bcrypt, or text with `hash = plain` |
|
|
| sql | `[sql] update_query` with `update_args` (`user`, `password`, `old_password`, in the sequence of its placeholders). `update_hash = bcrypt` stores a bcrypt hash. `none` stores the password as the caller typed it, for a query that makes the hash itself. Without `update_query`, you cannot change SQL passwords here |
|
|
| ldap | dmodem-login binds as the user, thus the password policy and hash of the server apply. It uses the Password Modify extended operation (RFC 3062, for OpenLDAP, 389 DS and most other servers). With `[ldap] password_change = ad`, it uses the method of Active Directory: it deletes the old value of `unicodePwd` and adds the new value. AD accepts this only on `ldaps://` or `starttls` |
|
|
| system | the password stack of `pam_service` in PAM. The caller sees the messages of PAM (for example, the reasons from a quality module) |
|
|
|
|
If the policy of the server or of PAM refuses the new password, the
|
|
old password stays. After a change, the selections get the new password
|
|
in `MODEM_PASSWORD`. Guests have no password to change. The log records
|
|
which user changed the password and in which backend. It never records
|
|
the password.
|
|
|
|
When it runs as root, `pam_unix` does no quality checks. Its `minlen`
|
|
and similar options do not apply to root. For a policy, put
|
|
`pam_pwquality` before `pam_unix` with `enforce_for_root`, as
|
|
[dmodem-login.pam.sample](../samples/dmodem-login.pam.sample) shows.
|
|
|
|
## The same password elsewhere: the auth socket
|
|
|
|
|
|
Callers who log in here are already logged in when they get to the
|
|
BBS. The same persons can also log in to the BBS in a different way
|
|
(telnet, SSH, the web forum of the BBS). They can use the same password,
|
|
because the BBS asks the backends of dmodem-login through a unix socket.
|
|
|
|
```
|
|
[authd]
|
|
listen = /run/dmodem-login/auth.sock
|
|
socket_mode = 0660
|
|
socket_group = bbs
|
|
; and, closer: only these users' programs (by the peer's uid)
|
|
allow_users = bbs
|
|
```
|
|
|
|
`dmodem-login -serve` answers on this socket, and also serves its sessions.
|
|
`dmodem-login -authd` answers on this socket only
|
|
([dmodem-login-authd.service.sample](../samples/dmodem-login-authd.service.sample)).
|
|
Each connection has one request, with one JSON line in each direction:
|
|
|
|
```
|
|
{"user": "alice", "password": "..."}
|
|
{"ok": true, "auth": "ldap"} or {"ok": false, "error": "denied"}
|
|
```
|
|
|
|
dmodem-login asks the backends in the same way as at the login prompt, and
|
|
applies `user_pattern`. A refusal comes after `fail_delay`. dmodem-login
|
|
also refuses accounts that are locked in the users file (a signup that
|
|
the sysop did not unlock). If a caller changes a password from the menu
|
|
(`mode = passwd`), the socket immediately uses the new password. For the
|
|
configuration on the BBS side, refer to its `[dmodem-login] auth_socket`
|
|
(docs/wiki/Modem-Callers.md in the BBS repository).
|
|
|
|
Other programs can also use LDAP to check the same passwords. Refer to
|
|
[the LDAP provider](ldap-provider.md).
|