diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a411621..d89cf66 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -8,7 +8,7 @@ on: jobs: build: - runs-on: windows-2019 + runs-on: windows-2025 steps: - uses: actions/checkout@v2 diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml new file mode 100644 index 0000000..1b61e09 --- /dev/null +++ b/.github/workflows/codeql.yml @@ -0,0 +1,52 @@ +name: "CodeQL" + +on: + push: + branches: [ master, develop ] + pull_request: + branches: [ master ] + schedule: + - cron: '23 12 * * 1' + +jobs: + analyze: + name: Analyze + runs-on: windows-latest + permissions: + actions: read + contents: read + security-events: write + + strategy: + fail-fast: false + matrix: + language: [ 'csharp' ] + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Initialize CodeQL + uses: github/codeql-action/init@v3 + with: + languages: ${{ matrix.language }} + queries: security-and-quality + + - name: Setup MSBuild + uses: microsoft/setup-msbuild@v2 + + - name: Setup NuGet + uses: nuget/setup-nuget@v1 + with: + nuget-version: 'latest' + + - name: Restore dependencies + run: nuget restore pusher-dotnet-client.sln + + - name: Build + run: msbuild /p:deterministic=true /p:msbuildArchitecture=x64 /p:configuration=Release pusher-dotnet-client.sln + + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v3 + with: + category: "/language:${{matrix.language}}" \ No newline at end of file diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 88ceb3f..293b482 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -7,7 +7,7 @@ on: jobs: build: - runs-on: windows-2019 + runs-on: windows-2025 steps: - uses: actions/checkout@v2 diff --git a/AuthHost/App.config b/AuthHost/App.config index 78fc9b9..1c37715 100644 --- a/AuthHost/App.config +++ b/AuthHost/App.config @@ -1,6 +1,6 @@ - - - - - - + + + + + + diff --git a/AuthHost/AuthModule.cs b/AuthHost/AuthModule.cs index ba7ffd5..584fe6b 100644 --- a/AuthHost/AuthModule.cs +++ b/AuthHost/AuthModule.cs @@ -1,6 +1,7 @@ using System; using System.Threading.Tasks; using Nancy; +using Newtonsoft.Json; using PusherClient; using PusherClient.Tests.Utilities; using PusherServer; @@ -60,6 +61,50 @@ public AuthModule() return authData; }; + + // Add routes that ExampleApplication expects + Post["/pusher/auth"] = _ => + { + Console.WriteLine($"Processing auth request for '{Request.Form.channel_name}' channel, for socket ID '{Request.Form.socket_id}'"); + + string channelName = Request.Form.channel_name; + string socketId = Request.Form.socket_id; + + string authData = null; + + if (Channel.GetChannelType(channelName) == ChannelTypes.Presence) + { + var channelData = new PresenceChannelData + { + user_id = socketId, + user_info = new { Name = "DefaultUser" } + }; + + authData = provider.Authenticate(channelName, socketId, channelData).ToJson(); + } + else + { + authData = provider.Authenticate(channelName, socketId).ToJson(); + } + + return authData; + }; + + Post["/pusher/auth-user"] = _ => + { + Console.WriteLine($"Processing user auth request for socket ID '{Request.Form.socket_id}'"); + + string socketId = Request.Form.socket_id; + + // For user authentication, return a simple user auth response + var userAuthResponse = new + { + auth = $"{PusherApplicationKey}:{socketId}", + user_data = JsonConvert.SerializeObject(new { id = socketId, name = "DefaultUser" }) + }; + + return JsonConvert.SerializeObject(userAuthResponse); + }; } private async Task SendSecretMessageAsync() @@ -82,4 +127,4 @@ private async Task SendSecretMessageAsync() Console.WriteLine(secretMessage); } } -} \ No newline at end of file +} diff --git a/CHANGELOG.md b/CHANGELOG.md index 683b964..c007432 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,7 @@ -# Changelog +# Changelog + +## +* [CHANGED] Force TLS 1.2 by default. ## 2.3.0-beta * [Added] Introduce user features diff --git a/PusherClient/Connection.cs b/PusherClient/Connection.cs index 4ea5480..752674c 100644 --- a/PusherClient/Connection.cs +++ b/PusherClient/Connection.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Security.Authentication; using System.Threading; using System.Threading.Tasks; using Newtonsoft.Json; @@ -50,7 +51,8 @@ public async Task ConnectAsync() ChangeState(ConnectionState.Connecting); - _websocket = new WebSocket(_url) + _websocket = new WebSocket(_url, "", null, null, "", + "", WebSocketVersion.None, null, SslProtocols.Tls12) { EnableAutoSendPing = true, AutoSendPingInterval = 1 @@ -210,13 +212,13 @@ private void ProcessPusherEvent(string eventName, string rawJson, DictionaryThe .NET library for interacting with the Pusher WebSocket API. Register at http://pusher.com MIT icon-128.png - 2.3.0-beta - 2.3.0.0 - 2.3.0.0 + + .0 + .0