Repository navigation
Conversation
… open Error() appended "check the client key and that the local clock is in sync" to every 401, even when the server's message already named a different cause. Drop it when the message names one (unknown actor, clock skew, signing headers, password login), name the key alone for "Invalid signature for user or client" (the clock is checked first), and keep the general hint for any other message or none. Fixes #156 Signed-off-by: Tim Smith <tsmith84@proton.me>
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.
ErrorResponse.Error()appended " (check the client key and that the local clock is in sync)" to every 401. The server's message usually names the cause already, and the hint could contradict it.Change
Error()now picks the hint fromServerMessage()(unauthorizedHintinerrors.go):Failed to authenticate as 'x'. Ensure that your node_name and client key are correct.Invalid signature for user or client 'x'(check that the client key is the one the server has for this client)Failed to authenticate as x. Synchronize the clock on your host.Original request time stamp too far in the future or past./invalid X-Ops-Timestampmissing required authentication header(s) ...,bad header(s) ...,auth: missing X-Ops-... headerFailed to authenticate: Username and password incorrectA message names its cause when it mentions "client key", "clock", "time stamp"/"timestamp", "header" or "password". A bad signature leaves only the key: both servers check the clock before the signature.
Why this design
Error()as-is lose no guidance where the server gave none.Messages,ServerMessage()anderrors.Is(err, ErrUnauthorized)are unchanged.Wording checked against erchef (
oc_chef_wm_base:verify_request_message,chef_wm_malformed:malformed_request_message) and cinc-server-ngserver/auth.go,internal/auth.Test plan
TestErrorResponse_401HintMatchesCausecovers each row above (failed before the fix)go test -race -count=2 ./...in the root andintegration/golangci-lint run ./...(v2.15.0) clean in both modulesFixes #156