mirror of
https://github.com/Kareadita/Kavita.git
synced 2026-04-02 07:14:30 -04:00
Co-authored-by: Vipin Singh <72501790+vipin2310@users.noreply.github.com> Co-authored-by: Ibrahim Hamshari <Ibraheem.Hamshari@gmail.com> Co-authored-by: Ibrahim Hamshari <Ibrahim.Hamshari@gmail.com>
47 lines
1.6 KiB
C#
47 lines
1.6 KiB
C#
using System.Security.Claims;
|
|
using System.Threading;
|
|
using System.Threading.Tasks;
|
|
using Kavita.Common;
|
|
using Kavita.Models.Entities.User;
|
|
using Microsoft.AspNetCore.Authentication.Cookies;
|
|
using Microsoft.AspNetCore.Http;
|
|
|
|
namespace Kavita.API.Services;
|
|
|
|
public interface IOidcService
|
|
{
|
|
/// <summary>
|
|
/// Returns the user authenticated with OpenID Connect
|
|
/// </summary>
|
|
/// <param name="request"></param>
|
|
/// <param name="principal"></param>
|
|
/// <param name="ct"></param>
|
|
/// <returns></returns>
|
|
/// <exception cref="KavitaException">if any requirements aren't met</exception>
|
|
Task<AppUser?> LoginOrCreate(HttpRequest request, ClaimsPrincipal principal, CancellationToken ct = default);
|
|
|
|
/// <summary>
|
|
/// Refresh the token inside the cookie when it's close to expiring. And sync the user
|
|
/// </summary>
|
|
/// <param name="ctx"></param>
|
|
/// <param name="ct"></param>
|
|
/// <returns></returns>
|
|
/// <remarks>If the token is refreshed successfully, updates the last active time of the suer</remarks>
|
|
Task<AppUser?> RefreshCookieToken(CookieValidatePrincipalContext ctx, CancellationToken ct = default);
|
|
|
|
/// <summary>
|
|
/// Remove <see cref="AppUser.OidcId"/> from all users
|
|
/// </summary>
|
|
/// <param name="ct"></param>
|
|
/// <returns></returns>
|
|
Task ClearOidcIds(CancellationToken ct = default);
|
|
|
|
/// <summary>
|
|
/// Remove <see cref="AppUser.OidcId"/> from the given user
|
|
/// </summary>
|
|
/// <param name="userId"></param>
|
|
/// <param name="ct"></param>
|
|
/// <returns></returns>
|
|
Task ClearOidcIdForUser(int userId, CancellationToken ct = default);
|
|
}
|