mirror of
https://github.com/profullstack/agentbbs.git
synced 2026-12-01 17:24:48 +00:00
feat(join): agent signup over ssh join@ + NNTPS token auth + llms.txt (#188)
* feat(join): non-interactive agent signup over ssh join@ (signup/verify/status) + llms.txt Agents, bots and scripts can now join without a terminal: ssh join@HOST signup <name> <email> --accept-terms ssh join@HOST verify <code> ssh join@HOST status Email verification and terms acceptance stay required. New guards for a scriptable door: 5 signups/code sends per IP per day (counted after name validation), and a code is burned after 5 wrong guesses across sessions. Welcome output now points at pfs.announce and earning on c0mpute (5% fee). setup.sh publishes /llms.txt describing the agent flow. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(news): NNTPS :563 requires a per-member token; ssh join@ token mints one The public listener ignored AUTHINFO PASS, so anyone who knew a member's name could read and post as them. Before inviting bots at scale, PASS must now be an API token minted for that same member. The loopback listener behind the SSH-authenticated news@ reader is unchanged. Agents get a news_token at verify; anyone can mint one with ssh join@HOST token. No external NNTPS logins in the last 14 days, so nobody is cut off. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
c6ffccdc87
commit
3bb2662bbe
9 changed files with 436 additions and 20 deletions
|
|
@ -30,6 +30,7 @@ import (
|
|||
// NewsStore is the slice of the store the NNTP backend needs.
|
||||
type NewsStore interface {
|
||||
UserByName(name string) (store.User, bool, error)
|
||||
UserByToken(token string) (string, bool, error)
|
||||
EnsureNewsGroup(name, description string) error
|
||||
NewsGroups() ([]store.NewsGroup, error)
|
||||
NewsGroup(name string) (store.NewsGroup, bool, error)
|
||||
|
|
@ -45,6 +46,11 @@ type backend struct {
|
|||
st NewsStore
|
||||
host string
|
||||
user string // BBS member name; "" until authenticated
|
||||
// requireToken makes AUTHINFO PASS a real credential: it must be an API
|
||||
// token minted for that member (ssh join@HOST token). Set on the public
|
||||
// NNTPS listener; the loopback listener behind the SSH-authenticated news@
|
||||
// reader keeps trusting the name it is given.
|
||||
requireToken bool
|
||||
}
|
||||
|
||||
func (b *backend) authed() bool { return b.user != "" }
|
||||
|
|
@ -53,12 +59,19 @@ func (b *backend) authed() bool { return b.user != "" }
|
|||
func (b *backend) Authorized() bool { return b.authed() }
|
||||
|
||||
// Authenticate approves a login iff the supplied user is an existing,
|
||||
// non-banned BBS member. The password is ignored (membership is the credential).
|
||||
func (b *backend) Authenticate(user, _ string) (nntpd.Backend, error) {
|
||||
// non-banned BBS member. On the public listener (requireToken) the password
|
||||
// must be an API token minted for that same member; on loopback it is ignored.
|
||||
func (b *backend) Authenticate(user, pass string) (nntpd.Backend, error) {
|
||||
name := strings.ToLower(strings.TrimSpace(user))
|
||||
if name == "" {
|
||||
return nil, nntpd.ErrAuthRejected
|
||||
}
|
||||
if b.requireToken {
|
||||
owner, ok, err := b.st.UserByToken(strings.TrimSpace(pass))
|
||||
if err != nil || !ok || owner != name {
|
||||
return nil, nntpd.ErrAuthRejected
|
||||
}
|
||||
}
|
||||
u, ok, err := b.st.UserByName(name)
|
||||
if err != nil {
|
||||
return nil, nntpd.ErrAuthRejected
|
||||
|
|
@ -66,7 +79,7 @@ func (b *backend) Authenticate(user, _ string) (nntpd.Backend, error) {
|
|||
if !ok || u.Banned {
|
||||
return nil, nntpd.ErrAuthRejected
|
||||
}
|
||||
return &backend{st: b.st, host: b.host, user: u.Name}, nil
|
||||
return &backend{st: b.st, host: b.host, user: u.Name, requireToken: b.requireToken}, nil
|
||||
}
|
||||
|
||||
// AllowPost reports whether POST is accepted: members only.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue