Add CookieNames helper for constructing cookie names

Introduce a new static class `CookieNames` in the `DigitalData.Auth.Claims` namespace to centralize and standardize the construction of cookie names for envelope receiver tokens.

- Added `GetEnvelopeReceiverCookieName` methods to generate cookie names with or without a default cookie name.
- Updated `AuthController` to use the `CookieNames` helper for constructing cookie names, replacing direct concatenation logic.
- Improved maintainability and consistency of cookie naming conventions across the application.
This commit is contained in:
2026-05-29 09:01:21 +02:00
parent 8f722ce3c9
commit 2c78ed106c
2 changed files with 29 additions and 1 deletions

View File

@@ -0,0 +1,27 @@
namespace DigitalData.Auth.Claims
{
/// <summary>
/// Provides helpers for building cookie names used in the DigitalData.Auth ecosystem.
/// </summary>
public static class CookieNames
{
private const string ReceiverSuffix = "SignFLOWReceiver.";
/// <summary>
/// Builds the cookie name for an envelope receiver token.
/// </summary>
/// <param name="defaultCookieName">The base cookie name configured in <c>AuthApiParams</c>.</param>
/// <param name="key">The unique envelope receiver key.</param>
/// <returns>A cookie name in the format <c>{defaultCookieName}SignFLOWReceiver.{key}</c>.</returns>
public static string GetEnvelopeReceiverCookieName(string defaultCookieName, string key)
=> defaultCookieName + ReceiverSuffix + key;
/// <summary>
/// Builds the cookie name for an envelope receiver token. This overload assumes a default cookie name of "AuthToken".
/// </summary>
/// <param name="key">The unique envelope receiver key.</param>
/// <returns>A cookie name in the format <c>{defaultCookieName}SignFLOWReceiver.{key}</c>.</returns>
public static string GetEnvelopeReceiverCookieName(string key)
=> "AuthToken" + ReceiverSuffix + key;
}
}