From 80e1ae125e6e2f4e148805b6d50afba55c6114a2 Mon Sep 17 00:00:00 2001 From: Heimdall Date: Wed, 11 Nov 2026 18:17:57 +0000 Subject: [PATCH] Desk: a bearer in the query string or a form body authenticates nothing (Soul) Co-Authored-By: Claude Sonnet 5.5 --- src/Bifrost.Web/Features/Desk/DeskEndpoints.cs | 7 ++++++- tests/Bifrost.Web.Tests/DeskCredentialTests.cs | 15 +++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/src/Bifrost.Web/Features/Desk/DeskEndpoints.cs b/src/Bifrost.Web/Features/Desk/DeskEndpoints.cs index 6632d58..3c275ce 100644 --- a/src/Bifrost.Web/Features/Desk/DeskEndpoints.cs +++ b/src/Bifrost.Web/Features/Desk/DeskEndpoints.cs @@ -36,7 +36,12 @@ public static class DeskEndpoints .AddValidation(validation => { validation.UseLocalServer(); - validation.UseAspNetCore(); + // The bearer travels in the Authorization header only: a token in a URL lands in access logs. + validation.UseAspNetCore().Configure(options => + { + options.DisableAccessTokenExtractionFromQueryString = true; + options.DisableAccessTokenExtractionFromBodyForm = true; + }); }); services.TryAddSingleton(); } diff --git a/tests/Bifrost.Web.Tests/DeskCredentialTests.cs b/tests/Bifrost.Web.Tests/DeskCredentialTests.cs index ea45409..f6205e4 100644 --- a/tests/Bifrost.Web.Tests/DeskCredentialTests.cs +++ b/tests/Bifrost.Web.Tests/DeskCredentialTests.cs @@ -104,6 +104,21 @@ public sealed class DeskCredentialTests : IDisposable Assert.Empty(factory.Door.Calls); } + [Fact] + public async Task A_bearer_in_the_query_string_or_a_form_body_authenticates_nothing() + { + var (_, token) = await MemberWithTokenAsync("desk.answer"); + DeskReplay.HoldVectorForks(factory.Door); + + var query = await factory.SendAsync( + "POST", DeskReplay.Target("answer", "gamecult-chat", null) + "?access_token=" + token, DeskReplay.AnswerBody(DeskReplay.ChatFork)); + var list = await factory.SendAsync("GET", DeskReplay.Target("list", "gamecult-chat", null) + "?access_token=" + token, null); + + Assert.Equal(401, query.Status); + Assert.Equal(401, list.Status); + Assert.Empty(factory.Door.Calls); + } + [Fact] public async Task A_desk_answer_token_reaches_the_answer_door_but_cannot_list() {