From bab82b545023f638110037feac86259d169bf63a Mon Sep 17 00:00:00 2001 From: rulak Date: Tue, 21 Jun 2022 09:05:01 -0500 Subject: [PATCH] inject the Authentication handler to override the anonymous handler that gets injected by default (#3139) (cherry picked from commit f861bf8a01dc3734c869f91532a9b99dd4d788e8) Co-authored-by: Rojan Ulak --- .../Elsa.Samples.HttpEndpointSecurity/Startup.cs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/samples/aspnet/Elsa.Samples.HttpEndpointSecurity/Startup.cs b/src/samples/aspnet/Elsa.Samples.HttpEndpointSecurity/Startup.cs index ac63f58446..8adc1f7f82 100644 --- a/src/samples/aspnet/Elsa.Samples.HttpEndpointSecurity/Startup.cs +++ b/src/samples/aspnet/Elsa.Samples.HttpEndpointSecurity/Startup.cs @@ -1,5 +1,7 @@ +using System; using System.IdentityModel.Tokens.Jwt; using System.Text; +using Elsa.Activities.Http.Services; using Elsa.Samples.HttpEndpointSecurity.Options; using Elsa.Samples.HttpEndpointSecurity.Services; using Microsoft.AspNetCore.Authentication.JwtBearer; @@ -61,8 +63,15 @@ public void ConfigureServices(IServiceCollection services) // Elsa. services .AddElsa(elsa => elsa - .AddHttpActivities(http => Configuration.GetSection("Elsa:Server").Bind(http)) - .AddWorkflowsFrom() + .AddHttpActivities(http => + + { + http.HttpEndpointAuthorizationHandlerFactory = + ActivatorUtilities.GetServiceOrCreateInstance; + http.BaseUrl = new Uri(Configuration["Elsa:Server:BaseUrl"]); + http.BasePath = Configuration["Elsa:Server:BasePath"]; + } + ).AddWorkflowsFrom() ); // Application Services.