Files
login/authd/authd.go
T
Claude 80d0fda167 Split the code into packages: cmd/modemmenu, internal/*, authd
All of modemmenu was one package main in the repository's root.  It is
now one module with the program and the pieces it is made of apart:

  cmd/modemmenu/     the program (the login, the menu, access, limits,
                     the selections, -serve, AutoPPP, drop files, the
                     auth socket's server)
  internal/config/   modemmenu.conf's sections and keys, {name} templates
  internal/term/     the caller's line, terminal detection, PETSCII
  internal/auth/     the backends and password changes
  internal/telnet/   the telnet client of mode = telnet items
  authd/             the auth socket's protocol and a client, for a BBS
                     to import (bbs's internal/menuauth is a copy of it)
  samples/           the .conf, .users, .pam and .service samples

make builds ./cmd/modemmenu and installs the samples from samples/; the
docs, confref and the site's reference follow.  The tests are where
their code is, none lost.  TestSampleHasEveryKey now reads the keys of
internal/ too (and the exported Get, Bool...: it would have found none).
.gitignore's "modemmenu" ignored cmd/modemmenu/ as well: it is
/modemmenu now.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01B82eRRbjf74j8oq9R3PXhA
2026-11-06 03:12:02 +00:00

30 lines
1021 B
Go

// Copyright (C) 2026 D-Modem Authors
// SPDX-License-Identifier: AGPL-3.0-only
// Package authd is modemmenu's auth socket ([authd] in modemmenu.conf),
// for the programs that ask it: modemmenu's backends (its users file,
// LDAP, SQL, the system's accounts by PAM) answer whether a password is a
// user's, so that a BBS's other logins (telnet, SSH, the web) take the
// same one as the dial-up line. One request a connection, a JSON line
// each way:
//
// {"user": "alice", "password": "..."}
// {"ok": true, "auth": "ldap"} or {"ok": false, "error": "denied"}
package authd
// Request is what a client sends.
type Request struct {
User string `json:"user"`
Password string `json:"password"`
}
// Reply is modemmenu's answer.
type Reply struct {
OK bool `json:"ok"`
Auth string `json:"auth,omitempty"` // the backend that took it
Error string `json:"error,omitempty"` // denied, refused, bad request
}
// MaxRequest is the longest request line modemmenu reads.
const MaxRequest = 4096