| | | 1 | | using Elsa.ExternalAuthentication.Contracts; |
| | | 2 | | using Elsa.ExternalAuthentication.Models; |
| | | 3 | | using Elsa.ExternalAuthentication.Options; |
| | | 4 | | using Microsoft.Extensions.Options; |
| | | 5 | | |
| | | 6 | | namespace Elsa.ExternalAuthentication.Providers; |
| | | 7 | | |
| | | 8 | | /// <summary> |
| | | 9 | | /// Projects optional database-owned rows into the effective registry. The backing store is deliberately replaceable. |
| | | 10 | | /// </summary> |
| | 1 | 11 | | public sealed class DatabaseIdentityProviderConnectionSource( |
| | 1 | 12 | | IIdentityProviderConnectionStore store, |
| | 1 | 13 | | IConnectionRegistryVersionStore versions, |
| | 1 | 14 | | IOptionsMonitor<ExternalAuthenticationOptions> options) : IIdentityProviderConnectionSource |
| | | 15 | | { |
| | | 16 | | public const string SourceName = "database"; |
| | | 17 | | |
| | 1 | 18 | | public string Name => SourceName; |
| | 1 | 19 | | public ConnectionSourceOwnership Ownership => ConnectionSourceOwnership.Database; |
| | | 20 | | |
| | | 21 | | public async ValueTask<ConnectionSourceSnapshot> GetSnapshotAsync(ConnectionScope scope, CancellationToken cancellat |
| | | 22 | | { |
| | 0 | 23 | | if (!options.CurrentValue.EnableDatabaseConnections) |
| | 0 | 24 | | return new ConnectionSourceSnapshot(scope, "disabled", []); |
| | | 25 | | |
| | 0 | 26 | | var page = await store.FindAsync(new ConnectionFilter { Scope = scope }, cancellationToken); |
| | 0 | 27 | | var version = await versions.GetVersionAsync(cancellationToken); |
| | 0 | 28 | | return new ConnectionSourceSnapshot(scope, version.ToString(System.Globalization.CultureInfo.InvariantCulture), |
| | 0 | 29 | | } |
| | | 30 | | } |