♻️ Mix things up

This commit is contained in:
2025-07-13 01:55:35 +08:00
parent 4a7f2e18b3
commit e66abe2e0c
19 changed files with 546 additions and 78 deletions

View File

@ -1,9 +1,11 @@
using System.Text.Json;
using System.Threading.RateLimiting;
using dotnet_etcd.interfaces;
using DysonNetwork.Pusher.Email;
using DysonNetwork.Pusher.Notification;
using DysonNetwork.Pusher.Services;
using DysonNetwork.Shared.Cache;
using DysonNetwork.Shared.Proto;
using Microsoft.AspNetCore.RateLimiting;
using Microsoft.OpenApi.Models;
using NodaTime;
@ -42,6 +44,18 @@ public static class ServiceCollectionExtensions
// Register gRPC services
services.AddScoped<PusherServiceGrpc>();
// Register AuthService.AuthServiceClient for AuthMiddleware
services.AddSingleton(sp =>
{
var etcdClient = sp.GetRequiredService<IEtcdClient>();
var configuration = sp.GetRequiredService<IConfiguration>();
var clientCertPath = configuration["ClientCert:Path"];
var clientKeyPath = configuration["ClientKey:Path"];
var clientCertPassword = configuration["ClientCert:Password"];
return GrpcClientHelper.CreateAuthServiceClient(etcdClient, clientCertPath, clientKeyPath, clientCertPassword);
});
// Register OIDC services
services.AddControllers().AddJsonOptions(options =>
{