sta / sta/websocket-sharp

Not able to identify wrong username and password

Open
#318 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C#
Stars
6.1k
Forks
1.7k
PR merge metrics
No merged PRs in 30d

Description

My server is a spring boot application that uses spring security for handling authenticated conections.

The server responds with a 401 when bad credentials are sent, but the client is not able to show that to me, sending a generic error for my code.

I have looked to the code and saw this code on WebSocket.cs:

private void doHandshake ()
    {
      setClientStream ();
      var res = sendHandshakeRequest ();
      string msg;
      if (!checkHandshakeResponse (res, out msg))
        throw new WebSocketException (CloseStatusCode.ProtocolError, msg);

      if (_protocolsRequested)
        _protocol = res.Headers["Sec-WebSocket-Protocol"];

      if (_extensionsRequested)
        processSecWebSocketExtensionsServerHeader (res.Headers["Sec-WebSocket-Extensions"]);

      processCookies (res.Cookies);
    }

The 'res' variable has the information about bad credentials, but it nos used when throwing the WebSocketException. It is possible to add a new option to CloseStatusCode for bad credentials?

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in WebSocket.cs at doHandshake, then trace sendHandshakeRequest and checkHandshakeResponse to see how the handshake response is represented before CloseStatusCode.ProtocolError is raised. Review the available CloseStatusCode values and the response information from the Spring Security server. Done means the client can distinguish bad credentials from the current generic handshake error.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, spring, spring-boot
Domain
authentication, networking
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.