Backend/e-suite.API/eSuite.API/SingleSignOn/ICookieManager.cs
2026-01-20 21:50:10 +00:00

84 lines
3.0 KiB
C#

using e_suite.API.Common.models;
using e_suite.Database.Audit;
using eSuite.Core.Miscellaneous;
namespace eSuite.API.SingleSignOn;
/// <summary>
/// Used to create and remove cookies used by the application
/// </summary>
public interface ICookieManager
{
/// <summary>
/// Creates a session cookie containing the users JWT Tokwn
/// </summary>
/// <param name="response"></param>
/// <param name="loginResponse"></param>
/// <returns></returns>
Task CreateSessionCookie(HttpResponse response, LoginResponse loginResponse);
/// <summary>
/// Removes the session cookie.
/// </summary>
/// <param name="response"></param>
/// <returns></returns>
Task DeleteSessionCookie(HttpResponse response);
/// <summary>
/// Create a single use cookie used for linking a profile to an sso identity.
/// </summary>
/// <param name="response"></param>
/// <param name="auditUserDetails"></param>
/// <param name="id"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
Task CreateProfileLinkCookie(HttpResponse response, AuditUserDetails auditUserDetails, GeneralIdRef id, CancellationToken cancellationToken);
/// <summary>
/// Create a single use cookie used for linking a profile to an sso identity.
/// </summary>
/// <param name="response"></param>
/// <param name="auditUserDetails"></param>
/// <param name="id"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
Task CreateNewUserLinkCookie(HttpResponse response, AuditUserDetails auditUserDetails, GeneralIdRef id, CancellationToken cancellationToken);
/// <summary>
/// Looks up the value of the single use cookie and converts it to a user for further processing
/// </summary>
/// <param name="request"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
Task<CookieLink?> GetUserIdFromLinkCookie(HttpRequest request, CancellationToken cancellationToken);
/// <summary>
/// Deletes the single use cookie
/// </summary>
/// <param name="response"></param>
/// <returns></returns>
Task DeleteLinkCookie(HttpResponse response);
/// <summary>
/// Finds the current SSO Provider from the SsoId cookie, this cookie will remain in the browser between sessions
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
Task<long?> GetSsoIdFromSsoIdCookie(HttpRequest request);
/// <summary>
/// Create the SsoId cookie containing the provider ID, to help shorten the login process when using SSO
/// </summary>
/// <param name="response"></param>
/// <param name="ssoId"></param>
/// <returns></returns>
Task CreateSsoIdCookie(HttpResponse response, long ssoId);
/// <summary>
/// Removes the SsoId cookie
/// </summary>
/// <param name="response"></param>
/// <returns></returns>
Task DeleteSsoIdCookie(HttpResponse response);
}