mirror of
https://github.com/Kareadita/Kavita.git
synced 2025-10-22 14:28:59 -04:00
Co-authored-by: DieselTech <30128380+DieselTech@users.noreply.github.com> Co-authored-by: majora2007 <josephmajora@gmail.com>
38 lines
992 B
C#
38 lines
992 B
C#
using API.Extensions;
|
|
using API.Services;
|
|
using Microsoft.AspNetCore.Authentication;
|
|
using Microsoft.AspNetCore.Authentication.Cookies;
|
|
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
namespace API.Controllers;
|
|
|
|
[Route("[controller]")]
|
|
public class OidcController: ControllerBase
|
|
{
|
|
|
|
[AllowAnonymous]
|
|
[HttpGet("login")]
|
|
public IActionResult Login(string returnUrl = "/")
|
|
{
|
|
var properties = new AuthenticationProperties { RedirectUri = returnUrl };
|
|
return Challenge(properties, IdentityServiceExtensions.OpenIdConnect);
|
|
}
|
|
|
|
[HttpGet("logout")]
|
|
public IActionResult Logout()
|
|
{
|
|
|
|
if (!Request.Cookies.ContainsKey(OidcService.CookieName))
|
|
{
|
|
return Redirect("/");
|
|
}
|
|
|
|
return SignOut(
|
|
new AuthenticationProperties { RedirectUri = "/login" },
|
|
CookieAuthenticationDefaults.AuthenticationScheme,
|
|
IdentityServiceExtensions.OpenIdConnect);
|
|
}
|
|
|
|
}
|