diff --git a/.github/workflows/ci-pipeline.yml b/.github/workflows/ci-pipeline.yml index 5cff1c057a..5941157710 100644 --- a/.github/workflows/ci-pipeline.yml +++ b/.github/workflows/ci-pipeline.yml @@ -1776,7 +1776,7 @@ jobs: - name: Setup Release Artifacts run: | mkdir release_assets - cp ./swaggger/tgs_api.json ./release_assets/swagger.json + cp ./swagger/tgs_api.json ./release_assets/swagger.json - name: Create GitHub Release uses: softprops/action-gh-release@a06a81a03ee405af7f2048a818ed3f03bbf83c7b diff --git a/build/Version.props b/build/Version.props index a692f2d0ab..f20333b535 100644 --- a/build/Version.props +++ b/build/Version.props @@ -3,7 +3,7 @@ - 6.19.1 + 6.19.2 5.9.0 10.14.0 0.7.0 diff --git a/src/DMAPI/tgs/LICENSE b/src/DMAPI/tgs/LICENSE index 324c48e993..0e39538813 100644 --- a/src/DMAPI/tgs/LICENSE +++ b/src/DMAPI/tgs/LICENSE @@ -1,6 +1,6 @@ The MIT License -Copyright (c) 2017-2024 Jordan Brown +Copyright (c) 2017-2026 Jordan Brown Permission is hereby granted, free of charge, to any person obtaining a copy of this software and diff --git a/src/Tgstation.Server.Api/ApiHeaders.cs b/src/Tgstation.Server.Api/ApiHeaders.cs index 00b7733715..fe8aab4a9e 100644 --- a/src/Tgstation.Server.Api/ApiHeaders.cs +++ b/src/Tgstation.Server.Api/ApiHeaders.cs @@ -309,7 +309,7 @@ namespace Tgstation.Server.Api break; } - var basicAuthSplits = joinedString.Split(ColonSeparator, StringSplitOptions.RemoveEmptyEntries); + var basicAuthSplits = joinedString.Split(ColonSeparator, 2, StringSplitOptions.RemoveEmptyEntries); if (basicAuthSplits.Length < 2) { AddError(HeaderErrorTypes.AuthorizationInvalid, badBasicAuthHeaderMessage); diff --git a/tests/Tgstation.Server.Api.Tests/TestApiHeaders.cs b/tests/Tgstation.Server.Api.Tests/TestApiHeaders.cs index a0cf7fc181..b4bc1a1a61 100644 --- a/tests/Tgstation.Server.Api.Tests/TestApiHeaders.cs +++ b/tests/Tgstation.Server.Api.Tests/TestApiHeaders.cs @@ -1,9 +1,11 @@ -using Microsoft.AspNetCore.Http; -using Microsoft.AspNetCore.Http.Headers; -using Microsoft.VisualStudio.TestTools.UnitTesting; -using System; +using System; using System.Net.Http.Headers; using System.Net.Mime; +using System.Text; + +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Http.Headers; +using Microsoft.VisualStudio.TestTools.UnitTesting; using Tgstation.Server.Api.Models; using Tgstation.Server.Api.Models.Response; @@ -16,7 +18,7 @@ namespace Tgstation.Server.Api.Tests [TestClass] public sealed class TestApiHeaders { - readonly ProductHeaderValue productHeaderValue = new ("Tgstation.Server.Api.Tests", "1.0.0"); + readonly ProductHeaderValue productHeaderValue = new("Tgstation.Server.Api.Tests", "1.0.0"); [TestMethod] public void TestConstruction() @@ -44,7 +46,8 @@ namespace Tgstation.Server.Api.Tests }; return new ApiHeaders(new RequestHeaders(headers), false, false); - }; + } + ; var header = TestHeader(BrowserHeader); Assert.AreEqual(BrowserHeader, header.RawUserAgent); @@ -56,5 +59,28 @@ namespace Tgstation.Server.Api.Tests Assert.ThrowsExactly(() => TestHeader(String.Empty)); } + + [TestMethod] + public void TestBasicAuthenticationDeserialization() + { + const string BrowserHeader = "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36."; + const string Password = "askdjf::SDokjdf**"; + const string Username = "deeznuts"; + + var authHeader = $"Basic {Convert.ToBase64String(Encoding.UTF8.GetBytes($"{Username}:{Password}"))}"; + var headers = new HeaderDictionary + { + { "Accept", MediaTypeNames.Application.Json }, + { "Api", "Tgstation.Server.Api/4.0.0.0" }, + { "Authorization", authHeader }, + { "User-Agent", BrowserHeader }, + }; + + var header = new ApiHeaders(new RequestHeaders(headers), false, false); + + Assert.AreEqual(BrowserHeader, header.RawUserAgent); + Assert.AreEqual(Username, header.Username); + Assert.AreEqual(Password, header.Password); + } } }