mirror of
https://github.com/profullstack/agentbbs.git
synced 2026-12-01 17:24:48 +00:00
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>
This commit is contained in:
parent
047fd8aa7d
commit
c8965ae93f
6 changed files with 93 additions and 20 deletions
|
|
@ -30,18 +30,20 @@ type GroupSpec struct{ Name, Description string }
|
|||
|
||||
// Server hosts the members-only NNTP network over the shared store.
|
||||
type Server struct {
|
||||
st NewsStore
|
||||
srv *nntpd.Server
|
||||
host string
|
||||
st NewsStore
|
||||
srv *nntpd.Server // loopback: trusts the SSH-authenticated news@ reader
|
||||
tlsSrv *nntpd.Server // public NNTPS: AUTHINFO PASS must be a member token
|
||||
host string
|
||||
}
|
||||
|
||||
// New builds a news Server. host is the public hostname used in Message-IDs and
|
||||
// stamped From addresses (e.g. "news.profullstack.com").
|
||||
func New(st NewsStore, host string) *Server {
|
||||
return &Server{
|
||||
st: st,
|
||||
srv: nntpd.NewServer(&backend{st: st, host: host}),
|
||||
host: host,
|
||||
st: st,
|
||||
srv: nntpd.NewServer(&backend{st: st, host: host}),
|
||||
tlsSrv: nntpd.NewServer(&backend{st: st, host: host, requireToken: true}),
|
||||
host: host,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -78,6 +80,10 @@ func ParseGroups(s string) []GroupSpec {
|
|||
// is immutable and AUTHINFO swaps only the per-session backend, so one Server is
|
||||
// safe to share across all connections.
|
||||
func (s *Server) Serve(ctx context.Context, ln net.Listener) error {
|
||||
return serve(ctx, ln, s.srv)
|
||||
}
|
||||
|
||||
func serve(ctx context.Context, ln net.Listener, srv *nntpd.Server) error {
|
||||
go func() { <-ctx.Done(); _ = ln.Close() }()
|
||||
for {
|
||||
conn, err := ln.Accept()
|
||||
|
|
@ -87,7 +93,7 @@ func (s *Server) Serve(ctx context.Context, ln net.Listener) error {
|
|||
}
|
||||
return err
|
||||
}
|
||||
go s.srv.Process(conn)
|
||||
go srv.Process(conn)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -116,7 +122,7 @@ func (s *Server) ServeTLS(ctx context.Context, addr, certFile, keyFile string) e
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return s.Serve(ctx, ln)
|
||||
return serve(ctx, ln, s.tlsSrv)
|
||||
}
|
||||
|
||||
// certKeeper loads a TLS keypair from disk and reloads it when either file's
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue