diff --git a/src/SecurityTokenService/SecurityTokenService.csproj b/src/SecurityTokenService/SecurityTokenService.csproj index 3e0c7da..97c87ab 100644 --- a/src/SecurityTokenService/SecurityTokenService.csproj +++ b/src/SecurityTokenService/SecurityTokenService.csproj @@ -26,6 +26,7 @@ + diff --git a/src/SecurityTokenService/Startup.cs b/src/SecurityTokenService/Startup.cs index f3ef65f..69b55a1 100644 --- a/src/SecurityTokenService/Startup.cs +++ b/src/SecurityTokenService/Startup.cs @@ -53,7 +53,11 @@ public void ConfigureServices(IServiceCollection services) Util.DataProtectionKeyAes.Key = Encoding.UTF8.GetBytes(dataProtectionKey); } - services.AddControllers(); + var builder = services.AddControllers(); + if (!string.IsNullOrWhiteSpace(Environment.GetEnvironmentVariable("DAPR_HTTP_PORT"))) + { + builder.AddDapr(); + } // 影响隐私数据加密、AntiToken 加解密 var dataProtectionBuilder = services.AddDataProtection() @@ -140,8 +144,19 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env) app.UseMiddleware(Configuration); app.UseIdentityServer(); app.UseAuthorization(); + var inDapr = !string.IsNullOrWhiteSpace(Environment.GetEnvironmentVariable("DAPR_HTTP_PORT")); + if (inDapr) + { + app.UseCloudEvents(); + } + app.UseEndpoints(endpoints => { + if (inDapr) + { + endpoints.MapSubscribeHandler(); + } + endpoints.MapControllers().RequireCors("cors"); }); }