mirror of
https://github.com/profullstack/agentbbs.git
synced 2026-12-02 01:34:47 +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
|
|
@ -36,6 +36,12 @@ func (f *fakeStore) UserByName(name string) (store.User, bool, error) {
|
|||
u, ok := f.users[name]
|
||||
return u, ok, nil
|
||||
}
|
||||
func (f *fakeStore) UserByToken(token string) (string, bool, error) {
|
||||
if token == "alice-token" {
|
||||
return "alice", true, nil
|
||||
}
|
||||
return "", false, nil
|
||||
}
|
||||
func (f *fakeStore) EnsureNewsGroup(name, desc string) error {
|
||||
if _, ok := f.groups[name]; !ok {
|
||||
f.groups[name] = store.NewsGroup{Name: name, Description: desc, Posting: true}
|
||||
|
|
@ -169,3 +175,21 @@ func TestPostStampsFromAndNumbers(t *testing.T) {
|
|||
t.Fatalf("reconstructed body wrong: %q", body)
|
||||
}
|
||||
}
|
||||
|
||||
func TestAuthenticateRequiresTokenOnPublicListener(t *testing.T) {
|
||||
pub := &backend{st: newFakeStore(), host: "news.test", requireToken: true}
|
||||
if _, err := pub.Authenticate("alice", "anything"); err == nil {
|
||||
t.Fatal("public listener must reject a non-token password")
|
||||
}
|
||||
if _, err := pub.Authenticate("bob", "alice-token"); err == nil {
|
||||
t.Fatal("a token must only log in its own member")
|
||||
}
|
||||
b, err := pub.Authenticate("alice", "alice-token")
|
||||
if err != nil || !b.Authorized() {
|
||||
t.Fatalf("alice with her token must log in: %v", err)
|
||||
}
|
||||
loop := &backend{st: newFakeStore(), host: "news.test"}
|
||||
if _, err := loop.Authenticate("alice", "ignored"); err != nil {
|
||||
t.Fatalf("loopback keeps trusting the SSH-authenticated name: %v", err)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue