| | | 1 | | using Elsa.Features.Abstractions; |
| | | 2 | | using Elsa.Features.Services; |
| | | 3 | | using Elsa.SasTokens.Contracts; |
| | | 4 | | using Microsoft.AspNetCore.DataProtection; |
| | | 5 | | using Microsoft.Extensions.DependencyInjection; |
| | | 6 | | |
| | | 7 | | namespace Elsa.SasTokens.Features; |
| | | 8 | | |
| | | 9 | | /// <summary> |
| | | 10 | | /// Adds the SAS tokens feature to the workflow runtime. |
| | | 11 | | /// </summary> |
| | | 12 | | /// <inheritdoc /> |
| | 1 | 13 | | public class SasTokensFeature(IModule module) : FeatureBase(module) |
| | | 14 | | { |
| | | 15 | | /// <summary> |
| | | 16 | | /// Configures the <see cref="IDataProtectionBuilder"/> used for setting up data protection. |
| | | 17 | | /// Defaults to setting the application name to "Elsa Workflows". |
| | | 18 | | /// </summary> |
| | 4 | 19 | | public Action<IDataProtectionBuilder> ConfigureDataProtectionBuilder { get; set; } = b => { b.SetApplicationName("El |
| | | 20 | | |
| | | 21 | | /// <summary> |
| | | 22 | | /// Factory method to create an instance of <see cref="ITokenService"/>. |
| | | 23 | | /// Defaults to creating a <see cref="DataProtectorTokenService"/> using dependency injection. |
| | | 24 | | /// </summary> |
| | 3 | 25 | | public Func<IServiceProvider, ITokenService> TokenService { get; set; } = sp => ActivatorUtilities.CreateInstance<Da |
| | | 26 | | |
| | | 27 | | /// <inheritdoc /> |
| | | 28 | | public override void Apply() |
| | | 29 | | { |
| | 1 | 30 | | var builder = Services.AddDataProtection(); |
| | 1 | 31 | | ConfigureDataProtectionBuilder(builder); |
| | | 32 | | |
| | 1 | 33 | | Services.AddScoped(TokenService); |
| | 1 | 34 | | } |
| | | 35 | | } |