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