mirror of
https://github.com/Kareadita/Kavita.git
synced 2026-06-05 14:25:17 -04:00
Inherit web links for Series and bug fixes (#4152)
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
using System.Threading.Tasks;
|
||||
#nullable enable
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using API.Extensions;
|
||||
using API.Services;
|
||||
using Kavita.Common;
|
||||
@@ -6,11 +8,14 @@ using Microsoft.AspNetCore.Authentication;
|
||||
using Microsoft.AspNetCore.Authentication.Cookies;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.IdentityModel.Protocols;
|
||||
using Microsoft.IdentityModel.Protocols.OpenIdConnect;
|
||||
|
||||
namespace API.Controllers;
|
||||
|
||||
[Route("[controller]")]
|
||||
public class OidcController: ControllerBase
|
||||
public class OidcController(ILogger<OidcController> logger, [FromServices] ConfigurationManager<OpenIdConnectConfiguration>? configurationManager = null): ControllerBase
|
||||
{
|
||||
|
||||
[AllowAnonymous]
|
||||
@@ -36,7 +41,15 @@ public class OidcController: ControllerBase
|
||||
}
|
||||
|
||||
var res = await Request.HttpContext.AuthenticateAsync(CookieAuthenticationDefaults.AuthenticationScheme);
|
||||
if (!res.Succeeded || res.Properties == null || string.IsNullOrEmpty(res.Properties.GetTokenValue(OidcService.IdToken)))
|
||||
if (configurationManager == null || !res.Succeeded || res.Properties == null || string.IsNullOrEmpty(res.Properties.GetTokenValue(OidcService.IdToken)))
|
||||
{
|
||||
HttpContext.Response.Cookies.Delete(OidcService.CookieName);
|
||||
return Redirect(Configuration.BaseUrl);
|
||||
}
|
||||
|
||||
// Authelia is dysfunctional and doesn't support logging out like this
|
||||
var config = await configurationManager.GetConfigurationAsync();
|
||||
if (config == null || string.IsNullOrEmpty(config.EndSessionEndpoint))
|
||||
{
|
||||
HttpContext.Response.Cookies.Delete(OidcService.CookieName);
|
||||
return Redirect(Configuration.BaseUrl);
|
||||
|
||||
Reference in New Issue
Block a user