Desk credential: only an all-desk-scope token skips the consent receipt; comment says the door withholds ids

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
Heimdall 2026-11-12 10:17:21 +00:00
commit 59f0915c03
3 changed files with 17 additions and 3 deletions

View file

@ -275,8 +275,8 @@ public static class DeskEndpoints
}
}
// A note is a decider's own words, and an answerer id names an account: only a caller on the admin-set list reads
// either (visibility ruling c; X3).
// A note is a decider's own words: only a caller on the admin-set list reads one. Bifrost strips notes itself; answerer
// and decider ids are withheld by Huginn's door (desk-read-visibility-withheld-ids), not here.
private static bool IsDecider(DeskDoorContext context) =>
context.Deciders.Contains(context.Subject, StringComparer.Ordinal);

View file

@ -114,7 +114,8 @@ public static class OidcEndpoints
}
/// <summary>A token whose scopes include a desk scope is a desk token. Only the chat token requires the training-notice receipt.</summary>
private static bool IsDeskToken(ClaimsPrincipal? principal) => principal is not null && principal.GetScopes().Any(DeskEndpoints.IsDeskScope);
// Only a token whose every scope is a desk scope skips the consent gate: a client that may hold chat scopes too cannot ride a desk scope past the receipt.
private static bool IsDeskToken(ClaimsPrincipal? principal) => principal is not null && principal.GetScopes() is { Length: > 0 } scopes && scopes.All(DeskEndpoints.IsDeskScope);
private static async Task<IResult> ExchangeAsync(HttpContext http, BifrostDbContext db)
{

View file

@ -160,6 +160,18 @@ public sealed class DeskCredentialTests : IDisposable
Assert.False(string.IsNullOrEmpty(await ExchangeAsync(client, later, laterCode, DeskClient, DeskSecret)));
}
[Fact]
public async Task A_desk_scope_mixed_with_a_chat_scope_does_not_skip_the_training_notice_receipt()
{
var (client, identity) = await SignedInAsync();
await RemoveReceiptsAsync(identity, withdrawOnly: false);
var mixed = NewRequest(DeskClient, DeskRedirect, "openid desk.read");
var final = await DriveAsync(client, mixed);
Assert.Equal(HttpStatusCode.Redirect, final.StatusCode);
Assert.DoesNotContain("code=", final.Headers.Location!.OriginalString);
}
[Fact]
public async Task The_chat_client_can_neither_ask_for_a_desk_scope_nor_use_its_own_token_on_the_desk()
{
@ -337,6 +349,7 @@ public sealed class DeskCredentialTests : IDisposable
Permissions.Endpoints.Token,
Permissions.GrantTypes.AuthorizationCode,
Permissions.ResponseTypes.Code,
Permissions.Prefixes.Scope + Scopes.OpenId,
Permissions.Prefixes.Scope + DeskEndpoints.ReadScope,
Permissions.Prefixes.Scope + DeskEndpoints.AnswerScope,
Permissions.Prefixes.Scope + DeskWebApplicationFactory.OtherAudienceScope,