🔄refactor: 使用OpenIddict 重构Identity

This commit is contained in:
yubaolee
2026-06-25 23:42:43 +08:00
parent 7a34fa7c51
commit 5e6ca18770
42 changed files with 697 additions and 2074 deletions

View File

@@ -1,9 +1,3 @@
// Copyright (c) Brock Allen & Dominick Baier. All rights reserved.
// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.
using System.Threading.Tasks;
using IdentityServer4.Services;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Hosting;
@@ -11,17 +5,14 @@ using Microsoft.Extensions.Logging;
namespace OpenAuth.IdentityServer.Quickstart.Home
{
[SecurityHeaders]
[AllowAnonymous]
public class HomeController : Controller
{
private readonly IIdentityServerInteractionService _interaction;
private readonly IHostEnvironment _environment;
private readonly ILogger _logger;
public HomeController(IIdentityServerInteractionService interaction, IHostEnvironment environment, ILogger<HomeController> logger)
public HomeController(IHostEnvironment environment, ILogger<HomeController> logger)
{
_interaction = interaction;
_environment = environment;
_logger = logger;
}
@@ -30,7 +21,6 @@ namespace OpenAuth.IdentityServer.Quickstart.Home
{
if (_environment.IsDevelopment())
{
// only show in development
return View();
}
@@ -39,24 +29,14 @@ namespace OpenAuth.IdentityServer.Quickstart.Home
}
/// <summary>
/// Shows the error page
/// 显示错误页面
/// </summary>
public async Task<IActionResult> Error(string errorId)
public IActionResult Error(string errorId)
{
var vm = new ErrorViewModel();
// retrieve error details from identityserver
var message = await _interaction.GetErrorContextAsync(errorId);
if (message != null)
var vm = new ErrorViewModel
{
vm.Error = message;
if (!_environment.IsDevelopment())
{
// only show in development
message.ErrorDescription = null;
}
}
ErrorId = errorId
};
return View("Error", vm);
}