Repository navigation
fix(broker): write one denied entry when a reload denies a login - #222
Merged
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
deniedentries (causenot_allowed) for one request: one by the reload check instillAllowedLogin, and one by the caller (handOutLoginorpreapproveLogin).Now
stillAllowedLoginreturns(ok, answered). A new helperloginStillSamerunssameLoginand thenstillAllowedLogin. The caller writes its own entry and answers only when the reload check has not answered. Who is denied does not change:okis 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
deniedentry for the request, not two.Changes behavior for existing callers: no
Tests
New test
TestLoginReloadDenyOneEntryininternal/broker/reloaddeny_test.go. A reload runs during the fetch after the tap, for a login (handOutLogin) and for a login pre-approval (preapproveLogin):sameLogindenies);stillAllowedLogindenies).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 ofstillAllowedLoginis changed on purpose toanswered=true, the two "clients changed" cases fail (status 200, want 403), so the tests reach that branch.go test -race ./...,go vet ./...andgolangci-lint run --build-tags e2epass locally.Checklist
feat:,fix:,docs:...).Progress
🤖 Generated with Claude Code