| | | 1 | | using Elsa.Features.Services; |
| | | 2 | | using Elsa.Identity.Features; |
| | | 3 | | |
| | | 4 | | // ReSharper disable once CheckNamespace |
| | | 5 | | namespace Elsa.Extensions; |
| | | 6 | | |
| | | 7 | | /// <summary> |
| | | 8 | | /// Extensions for <see cref="IModule"/> that installs the <see cref="IdentityFeature"/> feature. |
| | | 9 | | /// </summary> |
| | | 10 | | public static class ModuleExtensions |
| | | 11 | | { |
| | | 12 | | /// <summary> |
| | | 13 | | /// Installs and configures the <see cref="IdentityFeature"/> feature. |
| | | 14 | | /// </summary> |
| | | 15 | | public static IModule UseIdentity(this IModule module, Action<IdentityFeature>? configure = null) |
| | | 16 | | { |
| | 2 | 17 | | module.Configure(configure); |
| | 2 | 18 | | return module; |
| | | 19 | | } |
| | | 20 | | |
| | | 21 | | /// <summary> |
| | | 22 | | /// Installs and configures the <see cref="IdentityFeature"/> feature. |
| | | 23 | | /// </summary> |
| | | 24 | | public static IModule UseIdentity(this IModule module, string signingKey, string issuer = "http://elsa.api", string |
| | | 25 | | { |
| | 0 | 26 | | module.UseIdentity(identity => identity.TokenOptions += options => |
| | 0 | 27 | | { |
| | 0 | 28 | | options.Audience = audience; |
| | 0 | 29 | | options.Issuer = issuer; |
| | 0 | 30 | | options.AccessTokenLifetime = tokenLifetime ?? TimeSpan.FromHours(1); |
| | 0 | 31 | | options.SigningKey = signingKey; |
| | 0 | 32 | | }); |
| | 0 | 33 | | return module; |
| | | 34 | | } |
| | | 35 | | |
| | | 36 | | /// <summary> |
| | | 37 | | /// Installs and configures the <see cref="DefaultAuthenticationFeature"/> feature. |
| | | 38 | | /// </summary> |
| | | 39 | | public static IModule UseDefaultAuthentication(this IModule module, Action<DefaultAuthenticationFeature>? configure |
| | | 40 | | { |
| | 2 | 41 | | module.Configure(configure); |
| | 2 | 42 | | return module; |
| | | 43 | | } |
| | | 44 | | } |