Skip to content

Report rejected authentication to the client with HTTP 401 - #33

Open
NikolaiShipilov wants to merge 3 commits into
mainfrom
feature/report-auth-rejection
Open

NikolaiShipilov wants to merge 3 commits into
mainfrom
feature/report-auth-rejection

Conversation

@NikolaiShipilov

@NikolaiShipilov NikolaiShipilov commented Nov 18, 2026 •

Copy link
Copy Markdown
Collaborator

Brief

When the server rejects authentication it now replies with HTTP 401 instead of silently dropping the connection, and the client passes that reply to its handshake failure callback. This lets callers tell rejected credentials apart from other connection failures.

Description

  • On rejected authentication the server replies 401 Unauthorized to the upgrade request and closes the connection gracefully, within a 5 s timeout
  • The client's handshake failure callback also receives the server's HTTP reply when the server declined the upgrade (websocket::error::upgrade_declined), or nullptr when no reply was received
  • Add the missing changelog entries for v1.0.16 to v1.0.23
  • Bump version to 1.0.25

@NikolaiShipilov
NikolaiShipilov force-pushed the feature/report-auth-rejection branch 6 times, most recently from 0f970d8 to 340962a Compare November 19, 2026 13:27
@NikolaiShipilov NikolaiShipilov changed the title Feature/report auth rejection Report rejected authentication to the client with HTTP 401 Nov 19, 2026
@NikolaiShipilov NikolaiShipilov self-assigned this Nov 19, 2026
@NikolaiShipilov NikolaiShipilov added the enhancement New feature or request label Nov 19, 2026
@NikolaiShipilov
NikolaiShipilov force-pushed the feature/report-auth-rejection branch from 340962a to ece8f21 Compare November 24, 2026 10:00

@JakaMohorko JakaMohorko left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lgtm. 1 minor comment on error code handling.

Comment thread src/client.cpp Resolved
The server used to drop the connection silently, so clients could not
tell rejected credentials from other failures. It now answers with
401 Unauthorized and closes the connection gracefully, bounded by a
5 s timeout.
@NikolaiShipilov
NikolaiShipilov force-pushed the feature/report-auth-rejection branch from 01f4c51 to ab9638f Compare November 25, 2026 09:16
When the server declines the websocket upgrade (any status other than
101), the client now reports its HTTP reply along with the error, so the
caller can tell e.g. a rejected authentication (401) from other failures.
For any other handshake error the callback gets nullptr.
@NikolaiShipilov
NikolaiShipilov force-pushed the feature/report-auth-rejection branch from ab9638f to 108e5d9 Compare November 25, 2026 09:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants