Desk: a bearer in the query string or a form body authenticates nothing (Soul)

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
Heimdall 2026-11-11 18:17:57 +00:00
commit 80e1ae125e
2 changed files with 21 additions and 1 deletions

View file

@ -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<IDeskCredential, OidcDeskCredential>();
}

View file

@ -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()
{