feat: 完成支持鉴权刷新功能

This commit is contained in:
ccnetcore
2025-06-29 19:34:09 +08:00
parent a33c6dbf1a
commit 3d22a2ef65
6 changed files with 107 additions and 27 deletions

View File

@@ -0,0 +1,18 @@
using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.DependencyInjection;
namespace Yi.Framework.Core.Authentication;
public static class AuthenticationExtensions
{
public static void RefreshAuthentication(this HttpContext context)
{
var currentAuthenticationHandler =
context.RequestServices.GetRequiredService<IAuthenticationHandlerProvider>();
if (currentAuthenticationHandler is IRefreshAuthenticationHandlerProvider refreshAuthenticationHandler)
{
refreshAuthenticationHandler.RefreshAuthentication();
}
}
}

View File

@@ -0,0 +1,11 @@
using Microsoft.AspNetCore.Authentication;
namespace Yi.Framework.Core.Authentication;
public interface IRefreshAuthenticationHandlerProvider: IAuthenticationHandlerProvider
{
/// <summary>
/// 刷新鉴权
/// </summary>
void RefreshAuthentication();
}