2023-03-26 21:53:17 +00:00
using System ;
2023-01-05 12:55:08 +00:00
using Elsa.Extensions ;
using Elsa.Samples.Webhooks.WorkflowServer.Workflows ;
using Elsa.Webhooks.Extensions ;
using Microsoft.AspNetCore.Builder ;
using Microsoft.Extensions.Configuration ;
using Microsoft.Extensions.DependencyInjection ;
var builder = WebApplication . CreateBuilder ( args ) ;
// Add services to the container.
builder . Services . AddHandlersFrom < Program > ( ) ;
builder . Services . AddElsa ( elsa = >
{
elsa . AddWorkflow < HungryWorkflow > ( )
. UseHttp ( )
. UseIdentity ( identity = >
{
2023-03-26 21:53:17 +00:00
identity . UseAdminUserProvider ( ) ;
identity . TokenOptions = options = >
{
options . SigningKey = "secret-token-signing-key" ;
options . AccessTokenLifetime = TimeSpan . FromDays ( 1 ) ;
} ;
2023-01-05 12:55:08 +00:00
} )
. UseWorkflowsApi ( api = > api . CompleteTaskPolicy = policy = > policy . RequireAssertion ( _ = > true ) ) // Allows anonymous requests. Will be replaced with an API key scheme.
. UseDefaultAuthentication ( )
. UseWebhooks ( webhooks = > webhooks . WebhookOptions = options = > builder . Configuration . GetSection ( "Webhooks" ) . Bind ( options ) ) ;
} ) ;
var app = builder . Build ( ) ;
// Configure the HTTP request pipeline.
app . UseHttpsRedirection ( ) ;
app . UseAuthentication ( ) ;
app . UseAuthorization ( ) ;
app . UseWorkflowsApi ( ) ;
app . UseWorkflows ( ) ;
app . Run ( ) ;