Skip to content

fix(broker): write one denied entry when a reload denies a login - #222

Merged
groupsky merged 1 commit into
mainfrom
hq-job/nodkey-220-build/r-20261119-110019-9b4f
Nov 19, 2026
Merged

groupsky merged 1 commit into
mainfrom
hq-job/nodkey-220-build/r-20261119-110019-9b4f

Conversation

@groupsky

@groupsky groupsky commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

What and why

Fixes #220

When a reload took away the client or its pin while a login request or a login pre-approval waited for the fetch after the tap, the broker wrote two denied entries (cause not_allowed) for one request: one by the reload check in stillAllowedLogin, and one by the caller (handOutLogin or preapproveLogin).

Now stillAllowedLogin returns (ok, answered). A new helper loginStillSame runs sameLogin and then stillAllowedLogin. The caller writes its own entry and answers only when the reload check has not answered. Who is denied does not change: ok is true only when both checks pass, as before. The login values are still cleared before the answer on every path.

Behavior for callers

The answer to the client does not change (403). The audit log has one denied entry for the request, not two.

Changes behavior for existing callers: no

Tests

New test TestLoginReloadDenyOneEntry in internal/broker/reloaddeny_test.go. A reload runs during the fetch after the tap, for a login (handOutLogin) and for a login pre-approval (preapproveLogin):

  • the pin is taken away (the reload check denies);
  • the rule of the item changed (sameLogin denies);
  • the clients of the section changed (the rule check in stillAllowedLogin denies).

Each case checks the status 403, the entries of the request are exactly request decision:approve_once denied:not_allowed, no login is kept, no grant starts, and the values are cleared.

Without the fix, the two "pin is taken away" cases fail with denied:not_allowed denied:not_allowed. When the last return of stillAllowedLogin is changed on purpose to answered=true, the two "clients changed" cases fail (status 200, want 403), so the tests reach that branch.

go test -race ./..., go vet ./... and golangci-lint run --build-tags e2e pass locally.

Checklist

  • The title follows Conventional Commits (feat:, fix:, docs: ...).
  • Tests cover the deny paths, not only the happy path.
  • The docs are updated: no message, check or path of a value changes, so DESIGN.md and THREAT-MODEL.md stay as they are.
  • The security review is done (AGENTS.md). It found one low gap in the tests (the clients branch was not tested); fixed with the "clients changed" cases. No finding is open.
  • No private data: no real host name, address, token, key or private name.

Progress

🤖 Generated with Claude Code

When a reload took away the client or its pin while a login or a login
pre-approval waited for the fetch after the tap, the reload check wrote
a denied entry and answered, and then the caller wrote a second one.
stillAllowedLogin now says whether it has answered, and the caller
writes its own entry only when it has not. Who is denied does not
change.

Fixes #220

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@groupsky
groupsky marked this pull request as ready for review November 19, 2026 09:09
@groupsky
groupsky merged commit 5ee093c into main Nov 19, 2026
9 checks passed
@groupsky
groupsky deleted the hq-job/nodkey-220-build/r-20261119-110019-9b4f branch November 19, 2026 09:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(broker): a reload deny of a login writes two denied entries

1 participant