Inherit web links for Series and bug fixes (#4152)

This commit is contained in:
Fesaa
2025-10-25 21:35:53 +02:00
committed by GitHub
parent 935ed96416
commit 76f9e085eb
31 changed files with 4284 additions and 119 deletions
+16 -3
View File
@@ -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);