The generate proxy issue resolved, it caused by a typo which the interface of the integration service not follow the conventional.
any miss configuration for integration service, or the generate proxy action is wrong?
Thanks for the help from Maliming, the auth server UI login is a cookie authentication, not the token scenario, added below code auth server module works fine
`
context.Services.ConfigureApplicationCookie(options =>
{
var previousOnSignedIn = options.Events.OnSignedIn;
options.Events.OnSignedIn = async cookieSignedInContext =>
{
await previousOnSignedIn(cookieSignedInContext);
};
var previousOnSigningOut = options.Events.OnSigningOut;
options.Events.OnSigningOut = async cookieSigningOutContext =>
{
await previousOnSigningOut(cookieSigningOutContext);
};
}); `
The simple inline handle is not triggered, the event itself may not be firing due to pipeline misconfiguration, could you give some suggestions which pipeline misconfiguration?
I want to implement some actions (such as given award points to a user daily if the user sign in every day), I need to add an event to OpenIddict server event that it could fire an event handler to implement the logistics, I have followed the article add the event handler and registered in AuthServer project (a micro-services architecture solution), but the event handler not fired and no logs logged, is there any suggestions to debug, or I am using an incorrect way to configure the event handler?
public class DailyPointsHandler : IOpenIddictServerHandler<OpenIddictServerEvents.ProcessSignInContext>//, ITransientDependency
{
public static OpenIddictServerHandlerDescriptor Descriptor { get; }
= OpenIddictServerHandlerDescriptor.CreateBuilder<OpenIddictServerEvents.ProcessSignInContext>()
.UseScopedHandler<DailyPointsHandler>()
.SetOrder(100_000)
.SetType(OpenIddictServerHandlerType.Custom)
.Build();
private readonly IdentityUserManager _userManager;
private readonly IClock _clock;
private readonly ILogger<DailyPointsHandler> _logger;
private readonly IRewardPointsHistoriesAppService _rewardPointsHistoriesAppService;
private readonly IUnitOfWorkManager _unitOfWorkManager;
public DailyPointsHandler(
IdentityUserManager userManager,
IClock clock,
ILogger<DailyPointsHandler> logger,
IRewardPointsHistoriesAppService rewardPointsHistoriesAppService,
IUnitOfWorkManager unitOfWorkManager)
{
_userManager = userManager;
_clock = clock;
_logger = logger;
_rewardPointsHistoriesAppService = rewardPointsHistoriesAppService;
_unitOfWorkManager = unitOfWorkManager;
_logger.LogInformation("DailyPointsHandler constructor initialized");
}
public async ValueTask HandleAsync(OpenIddictServerEvents.ProcessSignInContext context)
{
_logger.LogInformation("进入每日积分处理器");
if (context is null) throw new ArgumentNullException(nameof(context));
// 跳过客户端凭证流程和刷新令牌流程
if (context.Request.IsClientCredentialsGrantType() ||
context.Request.IsRefreshTokenGrantType())
{
_logger.LogInformation("跳过非用户登录流程");
return;
}
// 获取用户ID
var userId = context.Principal?.FindFirst(OpenIddictConstants.Claims.Subject)?.Value;
if (string.IsNullOrEmpty(userId))
{
_logger.LogWarning("无法从声明中获取用户ID");
return;
}
try
{
using var uow = _unitOfWorkManager.Begin(requiresNew: true);
var user = await _userManager.FindByIdAsync(userId);
if (user == null)
{
_logger.LogWarning("用户未找到: {UserId}", userId);
return;
}
if (user != null)
{
var rewardPointsHistoryCreate = new RewardPointsHistoryCreateDto();
rewardPointsHistoryCreate.UserId = user.Id;
rewardPointsHistoryCreate.RewardPointType = RewardPointType.DailySignIn;
await _rewardPointsHistoriesAppService.CreateAsync(rewardPointsHistoryCreate);
await uow.CompleteAsync();
_logger.LogInformation("用户 {UserName} 获得每日登录奖励", user.UserName);
}
}
catch (Exception ex)
{
_logger.LogError(ex, "每日积分赠送处理失败");
// 失败时继续登录流程,不影响认证
}
}
}
registered it at:
private void PreConfigureOpenIddict(IConfiguration configuration, IWebHostEnvironment hostingEnvironment)
{
PreConfigure<OpenIddictBuilder>(builder =>
{
builder.AddValidation(options =>
{
options.AddAudiences("AuthServer");
options.UseLocalServer();
options.UseAspNetCore();
});
builder.AddServer(options =>
{
options.AddEventHandler<ProcessSignInContext>(builder =>
builder.UseInlineHandler(context =>
{
// Attach custom metadata to the configuration document.
//context.Metadata["custom_metadata"] = 42;
context.Logger.LogInformation("Processing sign-in event in inline handler for user {userId}.", context.Principal?.FindFirst(OpenIddictConstants.Claims.Subject)?.Value);
return default;
}));
});
});
PreConfigure<OpenIddictServerBuilder>(serverBuilder =>
{
serverBuilder.AddEventHandler(DailyPointsHandler.Descriptor);
serverBuilder.AddEventHandler(SignOutEventHandler.Descriptor);
serverBuilder.AddEventHandler<ProcessSignInContext>(builder =>
builder.UseInlineHandler(context =>
{
// Attach custom metadata to the configuration document.
//context.Metadata["custom_metadata"] = 42;
context.Logger.LogInformation("Processing sign-in event in inline handler for user {userId}.", context.Principal?.FindFirst(OpenIddictConstants.Claims.Subject)?.Value);
return default;
}));
});
}
Thanks a lot for maliming's help, a redundant module depends caused an odd bug
That is right, my local environment debug already configured it as you suggested
here is the API app program file code:
Log.Logger = new LoggerConfiguration()
.MinimumLevel.Debug()
.MinimumLevel.Override("Microsoft.EntityFrameworkCore", LogEventLevel.Warning)
.Enrich.FromLogContext()
.WriteTo.Async(c => c.File("Logs/logs.txt", rollingInterval: RollingInterval.Day))
.WriteTo.Async(c => c.Console())
.CreateBootstrapLogger();
try
{
Log.Information($"Starting {GetCurrentAssemblyName()}");
AbpStudioEnvironmentVariableLoader.Load();
var builder = WebApplication.CreateBuilder(args);
builder.Host
.AddAppSettingsSecretsJson()
.UseAutofac()
.UseSerilog((context, services, loggerConfiguration) =>
{
var applicationName = services.GetRequiredService<IApplicationInfoAccessor>().ApplicationName;
loggerConfiguration
#if DEBUG
.MinimumLevel.Debug()
.MinimumLevel.Override("Microsoft.EntityFrameworkCore", LogEventLevel.Warning)
.Enrich.FromLogContext()
#else
.MinimumLevel.Information()
#endif
.MinimumLevel.Override("Microsoft", LogEventLevel.Information)
.MinimumLevel.Override("Microsoft.EntityFrameworkCore", LogEventLevel.Warning)
.Enrich.FromLogContext()
.Enrich.WithProperty("Application", applicationName)
.If(context.Configuration.GetValue<bool>("ElasticSearch:IsLoggingEnabled"), c =>
c.WriteTo.Elasticsearch(
new ElasticsearchSinkOptions(new Uri(context.Configuration["ElasticSearch:Url"]!))
{
AutoRegisterTemplate = true,
AutoRegisterTemplateVersion = AutoRegisterTemplateVersion.ESv6,
IndexFormat = "PointLink-log-{0:yyyy.MM}"
})
)
.WriteTo.Async(c => c.File("Logs/logs.txt", rollingInterval: RollingInterval.Day))
.WriteTo.Async(c => c.Console())
.WriteTo.Async(c => c.AbpStudio(services));
});
await builder.AddApplicationAsync<PointLinkAdministrationServiceModule>();
var app = builder.Build();
await app.InitializeApplicationAsync();
await app.RunAsync();
Log.Information($"Stopped {GetCurrentAssemblyName()}");
return 0;
}
catch (HostAbortedException)
{
/* Ignoring this exception because: https://github.com/dotnet/efcore/issues/29809#issuecomment-1345132260 */
return 2;
}
catch (Exception ex)
{
Console.WriteLine($"{GetCurrentAssemblyName()} terminated unexpectedly!");
Console.WriteLine(ex.ToString());
Console.WriteLine(ex.StackTrace ?? "");
Log.Fatal(ex, $"{GetCurrentAssemblyName()} terminated unexpectedly!");
Log.Fatal(ex.Message);
Log.Fatal(ex.StackTrace ?? "");
return 1;
}
finally
{
await Log.CloseAndFlushAsync();
}
}
below are the logs after add debug info follow up your suggestion, it seems no more info logged
2025-07-22 20:19:27.918 +08:00 [INF] Request starting HTTP/1.1 GET http://localhost:44357/api/abp/application-configuration?IncludeLocalizationResources=False&api-version=1.0 - null null 2025-07-22 20:19:27.924 +08:00 [INF] Executing endpoint 'Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.AbpApplicationConfigurationController.GetAsync (Volo.Abp.AspNetCore.Mvc)' 2025-07-22 20:19:27.924 +08:00 [INF] Route matched with {area = "abp", action = "Get", controller = "AbpApplicationConfiguration", page = ""}. Executing controller action with signature System.Threading.Tasks.Task
1[Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.ApplicationConfigurationDto] GetAsync(Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.ApplicationConfigurationRequestOptions) on controller Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.AbpApplicationConfigurationController (Volo.Abp.AspNetCore.Mvc).
2025-07-22 20:19:27.928 +08:00 [WRN] The cookie 'XSRF-TOKEN' has set 'SameSite=None' and must also set 'Secure'.
2025-07-22 20:19:27.928 +08:00 [DBG] Executing AbpApplicationConfigurationAppService.GetAsync()...
2025-07-22 20:19:28.050 +08:00 [DBG] Executed AbpApplicationConfigurationAppService.GetAsync().
2025-07-22 20:19:28.050 +08:00 [INF] Executing ObjectResult, writing value of type 'Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.ApplicationConfigurationDto'.
2025-07-22 20:19:28.051 +08:00 [INF] Executed action Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.AbpApplicationConfigurationController.GetAsync (Volo.Abp.AspNetCore.Mvc) in 126.2675ms
2025-07-22 20:19:28.051 +08:00 [INF] Executed endpoint 'Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.AbpApplicationConfigurationController.GetAsync (Volo.Abp.AspNetCore.Mvc)'
2025-07-22 20:19:28.051 +08:00 [INF] Request finished HTTP/1.1 GET http://localhost:44357/api/abp/application-configuration?IncludeLocalizationResources=False&api-version=1.0 - 200 null application/json; charset=utf-8 132.6133ms
2025-07-22 20:19:28.052 +08:00 [INF] Request starting HTTP/1.1 GET http://localhost:44357/api/abp/application-localization?CultureName=zh-Hans&OnlyDynamics=True&api-version=1.0 - null null
2025-07-22 20:19:28.059 +08:00 [INF] Executing endpoint 'Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.AbpApplicationLocalizationController.GetAsync (Volo.Abp.AspNetCore.Mvc)'
2025-07-22 20:19:28.059 +08:00 [INF] Route matched with {area = "abp", action = "Get", controller = "AbpApplicationLocalization", page = ""}. Executing controller action with signature System.Threading.Tasks.Task`1[Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.ApplicationLocalizationDto] GetAsync(Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.ApplicationLocalizationRequestDto) on controller Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.AbpApplicationLocalizationController (Volo.Abp.AspNetCore.Mvc).
2025-07-22 20:19:28.365 +08:00 [INF] Executing ObjectResult, writing value of type 'Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.ApplicationLocalizationDto'.
2025-07-22 20:19:28.365 +08:00 [INF] Executed action Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.AbpApplicationLocalizationController.GetAsync (Volo.Abp.AspNetCore.Mvc) in 305.6032ms
2025-07-22 20:19:28.365 +08:00 [INF] Executed endpoint 'Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.AbpApplicationLocalizationController.GetAsync (Volo.Abp.AspNetCore.Mvc)'
2025-07-22 20:19:28.365 +08:00 [INF] Request finished HTTP/1.1 GET http://localhost:44357/api/abp/application-localization?CultureName=zh-Hans&OnlyDynamics=True&api-version=1.0 - 200 null application/json; charset=utf-8 312.3666ms
`
This is the related logs:
2025-07-22 18:43:50.418 +08:00 [INF] Request starting HTTP/1.1 GET http://localhost:44357/api/abp/application-configuration?IncludeLocalizationResources=False&api-version=1.0 - null null
2025-07-22 18:43:50.423 +08:00 [INF] Executing endpoint 'Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.AbpApplicationConfigurationController.GetAsync (Volo.Abp.AspNetCore.Mvc)'
2025-07-22 18:43:50.423 +08:00 [INF] Route matched with {area = "abp", action = "Get", controller = "AbpApplicationConfiguration", page = ""}. Executing controller action with signature System.Threading.Tasks.Task`1[Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.ApplicationConfigurationDto] GetAsync(Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.ApplicationConfigurationRequestOptions) on controller Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.AbpApplicationConfigurationController (Volo.Abp.AspNetCore.Mvc).
2025-07-22 18:43:50.424 +08:00 [WRN] The cookie 'XSRF-TOKEN' has set 'SameSite=None' and must also set 'Secure'.
2025-07-22 18:43:50.425 +08:00 [DBG] Executing AbpApplicationConfigurationAppService.GetAsync()...
2025-07-22 18:43:50.504 +08:00 [DBG] Executed AbpApplicationConfigurationAppService.GetAsync().
2025-07-22 18:43:50.504 +08:00 [INF] Executing ObjectResult, writing value of type 'Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.ApplicationConfigurationDto'.
2025-07-22 18:43:50.504 +08:00 [INF] Executed action Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.AbpApplicationConfigurationController.GetAsync (Volo.Abp.AspNetCore.Mvc) in 81.1573ms
2025-07-22 18:43:50.504 +08:00 [INF] Executed endpoint 'Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.AbpApplicationConfigurationController.GetAsync (Volo.Abp.AspNetCore.Mvc)'
2025-07-22 18:43:50.504 +08:00 [INF] Request finished HTTP/1.1 GET http://localhost:44357/api/abp/application-configuration?IncludeLocalizationResources=False&api-version=1.0 - 200 null application/json; charset=utf-8 85.8399ms
2025-07-22 18:43:50.506 +08:00 [INF] Request starting HTTP/1.1 GET http://localhost:44357/api/abp/application-localization?CultureName=zh-Hans&OnlyDynamics=True&api-version=1.0 - null null
2025-07-22 18:43:50.509 +08:00 [INF] Executing endpoint 'Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.AbpApplicationLocalizationController.GetAsync (Volo.Abp.AspNetCore.Mvc)'
2025-07-22 18:43:50.509 +08:00 [INF] Route matched with {area = "abp", action = "Get", controller = "AbpApplicationLocalization", page = ""}. Executing controller action with signature System.Threading.Tasks.Task`1[Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.ApplicationLocalizationDto] GetAsync(Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.ApplicationLocalizationRequestDto) on controller Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.AbpApplicationLocalizationController (Volo.Abp.AspNetCore.Mvc).
2025-07-22 18:43:50.704 +08:00 [INF] Executing ObjectResult, writing value of type 'Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.ApplicationLocalizationDto'.
2025-07-22 18:43:50.704 +08:00 [INF] Executed action Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.AbpApplicationLocalizationController.GetAsync (Volo.Abp.AspNetCore.Mvc) in 194.5464ms
2025-07-22 18:43:50.704 +08:00 [INF] Executed endpoint 'Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.AbpApplicationLocalizationController.GetAsync (Volo.Abp.AspNetCore.Mvc)'
2025-07-22 18:43:50.704 +08:00 [INF] Request finished HTTP/1.1 GET http://localhost:44357/api/abp/application-localization?CultureName=zh-Hans&OnlyDynamics=True&api-version=1.0 - 200 null application/json; charset=utf-8 198.4203ms
2025-07-22 18:43:51.055 +08:00 [INF] Request starting HTTP/1.1 GET http://localhost:44357/api/abp/application-configuration?IncludeLocalizationResources=False&api-version=1.0 - null null
2025-07-22 18:43:51.059 +08:00 [INF] Executing endpoint 'Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.AbpApplicationConfigurationController.GetAsync (Volo.Abp.AspNetCore.Mvc)'
2025-07-22 18:43:51.059 +08:00 [INF] Route matched with {area = "abp", action = "Get", controller = "AbpApplicationConfiguration", page = ""}. Executing controller action with signature System.Threading.Tasks.Task`1[Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.ApplicationConfigurationDto] GetAsync(Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.ApplicationConfigurationRequestOptions) on controller Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.AbpApplicationConfigurationController (Volo.Abp.AspNetCore.Mvc).
2025-07-22 18:43:51.060 +08:00 [WRN] The cookie 'XSRF-TOKEN' has set 'SameSite=None' and must also set 'Secure'.
2025-07-22 18:43:51.060 +08:00 [DBG] Executing AbpApplicationConfigurationAppService.GetAsync()...
2025-07-22 18:43:51.129 +08:00 [DBG] Executed AbpApplicationConfigurationAppService.GetAsync().
2025-07-22 18:43:51.129 +08:00 [INF] Executing ObjectResult, writing value of type 'Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.ApplicationConfigurationDto'.
2025-07-22 18:43:51.129 +08:00 [INF] Executed action Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.AbpApplicationConfigurationController.GetAsync (Volo.Abp.AspNetCore.Mvc) in 69.8878ms
2025-07-22 18:43:51.129 +08:00 [INF] Executed endpoint 'Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.AbpApplicationConfigurationController.GetAsync (Volo.Abp.AspNetCore.Mvc)'
2025-07-22 18:43:51.129 +08:00 [INF] Request finished HTTP/1.1 GET http://localhost:44357/api/abp/application-configuration?IncludeLocalizationResources=False&api-version=1.0 - 200 null application/json; charset=utf-8 73.6633ms
2025-07-22 18:43:51.130 +08:00 [INF] Request starting HTTP/1.1 GET http://localhost:44357/api/abp/application-localization?CultureName=zh-Hans&OnlyDynamics=True&api-version=1.0 - null null
2025-07-22 18:43:51.134 +08:00 [INF] Executing endpoint 'Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.AbpApplicationLocalizationController.GetAsync (Volo.Abp.AspNetCore.Mvc)'
2025-07-22 18:43:51.134 +08:00 [INF] Route matched with {area = "abp", action = "Get", controller = "AbpApplicationLocalization", page = ""}. Executing controller action with signature System.Threading.Tasks.Task`1[Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.ApplicationLocalizationDto] GetAsync(Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.ApplicationLocalizationRequestDto) on controller Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.AbpApplicationLocalizationController (Volo.Abp.AspNetCore.Mvc).
2025-07-22 18:43:51.324 +08:00 [INF] Executing ObjectResult, writing value of type 'Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.ApplicationLocalizationDto'.
2025-07-22 18:43:51.324 +08:00 [INF] Executed action Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.AbpApplicationLocalizationController.GetAsync (Volo.Abp.AspNetCore.Mvc) in 190.6994ms
2025-07-22 18:43:51.324 +08:00 [INF] Executed endpoint 'Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.AbpApplicationLocalizationController.GetAsync (Volo.Abp.AspNetCore.Mvc)'
2025-07-22 18:43:51.324 +08:00 [INF] Request finished HTTP/1.1 GET http://localhost:44357/api/abp/application-localization?CultureName=zh-Hans&OnlyDynamics=True&api-version=1.0 - 200 null application/json; charset=utf-8 194.0796ms