using Elsa.Features.Services;
using Elsa.Identity.Features;
// ReSharper disable once CheckNamespace
namespace Elsa.Extensions;
/// <summary>
/// Extensions for <see cref="IModule"/> that installs the <see cref="IdentityFeature"/> feature.
/// </summary>
public static class ModuleExtensions
{
/// Installs and configures the <see cref="IdentityFeature"/> feature.
public static IModule UseIdentity(this IModule module, Action<IdentityFeature>? configure = null)
module.Configure(configure);
return module;
}
public static IModule UseIdentity(this IModule module, string signingKey, string issuer = "http://elsa.api", string audience = "http://elsa.api", TimeSpan? tokenLifetime = null)
module.UseIdentity(identity => identity.TokenOptions += options =>
options.Audience = audience;
options.Issuer = issuer;
options.AccessTokenLifetime = tokenLifetime ?? TimeSpan.FromHours(1);
options.SigningKey = signingKey;
});
/// Installs and configures the <see cref="DefaultAuthenticationFeature"/> feature.
public static IModule UseDefaultAuthentication(this IModule module, Action<DefaultAuthenticationFeature>? configure = null)