Heimdall sign-in: the start result carries the cookie name; fix a test string literal

The commit before this one did not compile (a split string literal in the tests).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Meta Vens 2026-10-11 04:41:36 +02:00
commit 5626532571
3 changed files with 5 additions and 8 deletions

View file

@ -105,7 +105,8 @@ public sealed class HeimdallAuthService(
requireMemberAccess,
returnPath,
timeProvider.GetUtcNow() + HeimdallAttemptCookie.Lifetime);
return new HeimdallAuthStartResult(new Uri(payload.AuthorizationUrl, UriKind.Absolute), nonce, Protect(attempt));
return new HeimdallAuthStartResult(
new Uri(payload.AuthorizationUrl, UriKind.Absolute), HeimdallAttemptCookie.NameFor(nonce)!, Protect(attempt));
}
public async Task<HeimdallCompletedSignIn> CompleteAsync(
@ -347,7 +348,7 @@ public sealed class HeimdallAuthService(
public class HeimdallAuthException(string message) : InvalidOperationException(message);
public sealed record HeimdallAuthStartResult(Uri AuthorizationUrl, string Nonce, string CookieValue);
public sealed record HeimdallAuthStartResult(Uri AuthorizationUrl, string CookieName, string CookieValue);
public sealed record HeimdallCompletedSignIn(ClaimsPrincipal Principal, LocalReturnPath ReturnPath);

View file

@ -379,10 +379,7 @@ app.MapGet("/auth/heimdall/{provider}", async (
requireMemberAccess,
cancellationToken);
httpContext.Response.Cookies.Append(
HeimdallAttemptCookie.NameFor(start.Nonce),
start.CookieValue,
HeimdallAttemptCookie.Options());
httpContext.Response.Cookies.Append(start.CookieName, start.CookieValue, HeimdallAttemptCookie.Options());
return Results.Redirect(start.AuthorizationUrl.ToString());
}
catch (HeimdallAuthException error)

View file

@ -699,8 +699,7 @@ public sealed class HeimdallCompletionTests
Assert.Equal(string.Empty, await start.Content.ReadAsStringAsync());
}
Assert.Contains("Heimdall start refused: Unsupported Heimdall provider.", string.Join("
", host.Logs.Lines));
Assert.Contains("Heimdall start refused: Unsupported Heimdall provider.", string.Join("\n", host.Logs.Lines));
Assert.Contains("Heimdall start refused: Heimdall provider does not support Bifrost member access.", string.Join("\n", host.Logs.Lines));
}