sta / sta/websocket-sharp

New Feature: Open a web socket by providing a jwt token for authentication

Open
#681 4 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

Hello everybody,
First of all I would like to say a big thank you to all of this repo developers out there.
Thank you for offering this repo to the open source community.

Having said that, I have used websocket-sharp myself for opening web socket connections from web clients to .NET console applications. While developing, the need arose for a web socket server that can authenticate users trying to open the websocket by providing a jwt token in the url e.g. wss://address/path?token=jwtToken. From what I can tell, the current implementation does not support such kind of authentication so I implemented it myself. I added an event that gets raised during the ws upgrade request, containing the token. Then, the event listener can get the token from the event, validate it and either proceed with the upgrade or close the connection.

You can find the relevant commit here:
https://github.com/kazepis/websocket-sharp/commit/0060bdb097f7af8650699692bf60c45d248ba6b6
I also upgraded everything to .NET 4.8 for MY needs. The massive diffs were produced because I have different formatting settings.
You can easily find the actual change by searching for the event public event EventHandler<HttpRequestEventArgs> OnWebSocketUpgradeRequest;

If this functionality addition is welcome in this repo I would happily make a "clean" pull request.
If yes, are there any contributing guidelines I should follow? So please let me know.

Best,
N.

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 by reviewing commit 0060bdb097f7af8650699692bf60c45d248ba6b6 and search the repository for OnWebSocketUpgradeRequest. Trace the WebSocket upgrade request flow and compare the proposed event behavior with the existing server API. Done means the project has an agreed JWT-token authentication extension with suitable validation and connection-handling tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
authentication, backend
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.