< Summary

Information
Class: Elsa.ExternalAuthentication.Contracts.ConnectionValidationContext
Assembly: Elsa.ExternalAuthentication
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.ExternalAuthentication/Contracts/ExternalAuthenticationContracts.cs
Line coverage
100%
Covered lines: 1
Uncovered lines: 0
Coverable lines: 1
Total lines: 320
Line coverage: 100%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
get_Connection()100%11100%

File(s)

/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.ExternalAuthentication/Contracts/ExternalAuthenticationContracts.cs

#LineLine coverage
 1using System.Security.Claims;
 2using System.Text.Json;
 3using Elsa.Common;
 4using Elsa.Common.Models;
 5using Elsa.ExternalAuthentication.Models;
 6
 7namespace Elsa.ExternalAuthentication.Contracts;
 8
 9public interface IExternalAuthenticationAdapter
 10{
 11    string Type { get; }
 12    ExternalAuthenticationAdapterDescriptor Describe();
 13    ValueTask<ConnectionValidationResult> ValidateAsync(ConnectionValidationContext context, CancellationToken cancellat
 14    ValueTask<ExternalAuthorizationRequest> CreateAuthorizationRequestAsync(ExternalAuthorizationContext context, Cancel
 15    ValueTask<ExternalAuthenticationResult> AuthenticateCallbackAsync(ExternalCallbackContext context, CancellationToken
 16    ValueTask<ConnectionTestResult> TestAsync(ConnectionTestContext context, CancellationToken cancellationToken = defau
 17    ValueTask<ExternalLogoutRequest?> CreateLogoutRequestAsync(ExternalLogoutContext context, CancellationToken cancella
 18}
 19
 20public interface IExternalAuthenticationAdapterRegistry
 21{
 22    IReadOnlyCollection<ExternalAuthenticationAdapterDescriptor> ListDescriptors();
 23    bool TryGet(string type, out IExternalAuthenticationAdapter adapter);
 24}
 25
 26public interface IUnlinkedIdentityPolicyRegistry
 27{
 28    IReadOnlyCollection<UnlinkedIdentityPolicyDescriptor> ListDescriptors();
 29    bool TryGet(string type, out IUnlinkedIdentityPolicy policy);
 30}
 31
 32public interface IPermissionGrantSourceRegistry
 33{
 34    IReadOnlyCollection<PermissionGrantSourceDescriptor> ListDescriptors();
 35    bool TryGet(string type, out IPermissionGrantSource source);
 36}
 37
 38public interface IExternalUserMatcherRegistry
 39{
 40    IReadOnlyCollection<ExternalUserMatcherDescriptor> ListDescriptors();
 41    bool TryGet(string type, out IExternalUserMatcher matcher);
 42}
 43
 44public interface IAdapterSettingsMigration
 45{
 46    string AdapterType { get; }
 47    int FromVersion { get; }
 48    int ToVersion { get; }
 49    ValueTask<JsonElement> MigrateAsync(JsonElement settings, CancellationToken cancellationToken = default);
 50}
 51
 52public interface IAdapterSettingsMigrationService
 53{
 54    ValueTask<AdapterSettingsMigrationResult> MigrateAsync(
 55        string adapterType,
 56        int settingsVersion,
 57        JsonElement settings,
 58        CancellationToken cancellationToken = default);
 59}
 60
 61public interface IIdentityProviderConnectionSource
 62{
 63    string Name { get; }
 64    ConnectionSourceOwnership Ownership { get; }
 65    ValueTask<ConnectionSourceSnapshot> GetSnapshotAsync(ConnectionScope scope, CancellationToken cancellationToken = de
 66}
 67
 68public interface IIdentityProviderConnectionRegistry
 69{
 70    ValueTask<EffectiveConnectionRegistry> GetAsync(string targetTenantId, CancellationToken cancellationToken = default
 71    ValueTask<EffectiveIdentityProviderConnection?> FindByKeyAsync(string targetTenantId, string key, CancellationToken 
 72    ValueTask<EffectiveIdentityProviderConnection?> FindByIdAsync(string targetTenantId, string connectionId, Cancellati
 73}
 74
 75public interface IIdentityProviderConnectionValidityAssessor
 76{
 77    ValueTask<EffectiveIdentityProviderConnection> AssessAsync(
 78        EffectiveIdentityProviderConnection connection,
 79        CancellationToken cancellationToken = default);
 80}
 81
 82public interface IIdentityProviderConnectionStore
 83{
 84    ValueTask<Page<IdentityProviderConnection>> FindAsync(ConnectionFilter filter, CancellationToken cancellationToken =
 85    ValueTask<IdentityProviderConnection?> FindByIdAsync(string id, CancellationToken cancellationToken = default);
 86    ValueTask<ConnectionMutationResult> CreateAsync(IdentityProviderConnection connection, CancellationToken cancellatio
 87    ValueTask<ConnectionMutationResult> UpdateAsync(IdentityProviderConnection connection, long expectedRevision, Cancel
 88}
 89
 90public interface ISecretBindingResolver
 91{
 92    string Type { get; }
 93    ValueTask<SecretBindingState> GetStateAsync(SecretBinding binding, CancellationToken cancellationToken = default);
 94    ValueTask<ResolvedSecretBinding> ResolveAsync(SecretBinding binding, CancellationToken cancellationToken = default);
 95}
 96
 97/// <summary>Optionally accepts a secret value once and stages it through a managed secret backend.</summary>
 98public interface IManagedSecretBindingWriter
 99{
 100    string ResolverType { get; }
 101    string DisplayName { get; }
 102    /// <summary>
 103    /// Stores the value under a fresh reference that is not used by any live binding.
 104    /// Implementations must not rotate or overwrite an existing reference.
 105    /// </summary>
 106    ValueTask<SecretBinding> StageAsync(ManagedSecretBindingWriteRequest request, CancellationToken cancellationToken = 
 107    ValueTask RemoveAsync(SecretBinding binding, CancellationToken cancellationToken = default);
 108}
 109
 110/// <summary>Write-only input for a managed connection secret. Implementations must not expose <see cref="Value"/>.</sum
 111public sealed record ManagedSecretBindingWriteRequest(string ConnectionId, string FieldName, SensitiveString Value);
 112
 113/// <summary>Creates keyed, non-reversible storage keys for opaque browser handles.</summary>
 114public interface IExternalAuthenticationHandleHasher
 115{
 116    string Hash(string value);
 117}
 118
 119public interface IUnlinkedIdentityPolicy
 120{
 121    string Type { get; }
 122    UnlinkedIdentityPolicyDescriptor Describe();
 123    ValueTask<UnlinkedIdentityDecision> EvaluateAsync(UnlinkedIdentityContext context, CancellationToken cancellationTok
 124}
 125
 126/// <summary>Trusted deployed extension that may identify one Elsa user for an unlinked external identity.</summary>
 127public interface IExternalUserMatcher
 128{
 129    string Type { get; }
 130    ExternalUserMatcherDescriptor Describe();
 131    ValueTask<ExternalUserMatchResult> MatchAsync(ExternalUserMatcherContext context, CancellationToken cancellationToke
 132}
 133
 134public interface IExternalIdentityResolver
 135{
 136    ValueTask<ExternalIdentityResolution> ResolveAsync(ExternalIdentityResolutionContext context, CancellationToken canc
 137}
 138
 139/// <summary>Optionally records completed sign-ins for an external identity resolver or provisioner.</summary>
 140public interface IExternalIdentitySignInTracker
 141{
 142    /// <summary>
 143    /// Records a completed sign-in for the tenant-scoped external identity link without changing its other metadata.
 144    /// Concurrent calls must preserve the latest timestamp.
 145    /// </summary>
 146    ValueTask<bool> RecordSuccessfulSignInAsync(
 147        string tenantId,
 148        string connectionKey,
 149        ExternalIdentity identity,
 150        string userId,
 151        DateTimeOffset signedInAt,
 152        CancellationToken cancellationToken = default);
 153}
 154
 155public interface IExternalIdentityProvisioner
 156{
 157    /// <summary>
 158    /// Finds the link for a normalized external identity without exposing its persisted subject representation.
 159    /// </summary>
 160    ValueTask<ExternalIdentityLink?> FindLinkAsync(string tenantId, string connectionKey, ExternalIdentity identity, Can
 161
 162    /// <summary>
 163    /// Creates the requested link and, when requested, its credential-less user; compensates a losing writer; or return
 164    /// </summary>
 165    ValueTask<ProvisioningResult> CreateLinkOrGetExistingAsync(ProvisioningRequest request, CancellationToken cancellati
 166
 167    /// <summary>
 168    /// Atomically removes the tenant-scoped link identified by <see cref="ExternalIdentityLinkReplaceRequest.LinkId"/>
 169    /// and creates its replacement, or returns the conflicting link without changing the original.
 170    /// </summary>
 171    ValueTask<ExternalIdentityLinkReplaceResult> ReplaceAsync(ExternalIdentityLinkReplaceRequest request, CancellationTo
 172        throw new NotSupportedException("This external identity provisioner does not support atomic link replacement.");
 173}
 174
 175/// <summary>
 176/// Provides tenant-bounded administration of existing external identity links.
 177/// Creation remains on <see cref="IExternalIdentityProvisioner"/> so administrator prelinks and JIT provisioning use th
 178/// </summary>
 179public interface IExternalIdentityLinkManagementStore
 180{
 181    ValueTask<Page<ExternalIdentityLink>> FindAsync(ExternalIdentityLinkFilter filter, CancellationToken cancellationTok
 182    ValueTask<bool> DeleteAsync(string tenantId, string linkId, CancellationToken cancellationToken = default);
 183}
 184
 185public interface IPermissionGrantSource
 186{
 187    string Type { get; }
 188    PermissionGrantSourceDescriptor Describe();
 189    ValueTask<PermissionGrantResult> GetGrantsAsync(PermissionGrantContext context, CancellationToken cancellationToken 
 190}
 191
 192public interface IPermissionDelegationAuthorizer
 193{
 194    ValueTask<PermissionDelegationResult> AuthorizeAsync(ClaimsPrincipal actor, IReadOnlyCollection<GrantSourceSelection
 195}
 196
 197public interface IPermissionGrantResolver
 198{
 199    ValueTask<PermissionGrantResult> ResolveAsync(PermissionGrantResolutionContext context, CancellationToken cancellati
 200}
 201
 202public interface IPermissionDescriptorProvider
 203{
 204    IEnumerable<PermissionDescriptor> GetDescriptors();
 205}
 206
 207public interface IPermissionDescriptorRegistry
 208{
 209    IReadOnlyCollection<PermissionDescriptor> List();
 210}
 211
 212public interface IExternalAuthenticationStateStore
 213{
 214    ValueTask PutAsync<T>(string purpose, string handleHash, T value, DateTimeOffset expiresAt, CancellationToken cancel
 215    ValueTask<TakeResult<T>> TryTakeAsync<T>(string purpose, string handleHash, CancellationToken cancellationToken = de
 216}
 217
 218public interface IAuthorizationGrantStore
 219{
 220    ValueTask SaveAsync(AuthorizationGrant grant, CancellationToken cancellationToken = default);
 221    ValueTask<TakeResult<AuthorizationGrant>> TryTakeAsync(string codeHash, CancellationToken cancellationToken = defaul
 222}
 223
 224public interface IExternalAuthenticationSessionStore
 225{
 226    ValueTask<IReadOnlyCollection<ExternalAuthenticationSession>> FindAsync(ExternalAuthenticationSessionFilter filter, 
 227    ValueTask<ExternalAuthenticationSession?> FindByIdAsync(string sessionId, CancellationToken cancellationToken = defa
 228    ValueTask<ExternalAuthenticationSession?> FindByRefreshTokenHashAsync(string refreshTokenHash, CancellationToken can
 229    ValueTask SaveAsync(ExternalAuthenticationSession session, CancellationToken cancellationToken = default);
 230    ValueTask<ExternalAuthenticationSessionRotationResult> TryRotateRefreshTokenAsync(string sessionId, string refreshTo
 231    ValueTask<bool> RevokeAsync(string sessionId, string reason, DateTimeOffset revokedAt, CancellationToken cancellatio
 232    ValueTask<int> RevokeActiveForConnectionAsync(string connectionKey, string reason, DateTimeOffset revokedAt, Cancell
 233}
 234
 235public interface IPreviewResultStore
 236{
 237    ValueTask SaveAsync(PreviewResult result, CancellationToken cancellationToken = default);
 238    ValueTask<TakeResult<PreviewResult>> TryTakeAsync(string handleHash, string administratorId, CancellationToken cance
 239}
 240
 241public interface IConnectionObservationStore
 242{
 243    ValueTask<ConnectionObservation?> FindLatestAsync(string connectionId, CancellationToken cancellationToken = default
 244    ValueTask SaveLatestAsync(ConnectionObservation observation, CancellationToken cancellationToken = default);
 245}
 246
 247public interface IConnectionRegistryVersionStore
 248{
 249    ValueTask<long> GetVersionAsync(CancellationToken cancellationToken = default);
 250    ValueTask<long> AdvanceAsync(CancellationToken cancellationToken = default);
 251    ValueTask<bool> IsCurrentAsync(long version, CancellationToken cancellationToken = default);
 252}
 253
 254public interface IExternalAuthenticationTokenIssuer
 255{
 256    ValueTask<ExternalTokenResponse> IssueAsync(ExternalAuthenticationSession session, CancellationToken cancellationTok
 257    ValueTask<ExternalTokenResponse> RefreshAsync(string clientId, SensitiveString refreshToken, CancellationToken cance
 258}
 259
 260public sealed record ResolvedSecretBinding(SensitiveString Value, string GenerationFingerprint);
 261
 262public sealed record ConnectionSourceSnapshot(ConnectionScope Scope, string Version, IReadOnlyCollection<IdentityProvide
 263
 264public sealed record IdentityProviderConnectionReference(
 265    string Id,
 266    string DisplayName,
 267    ConnectionSourceOwnership Ownership);
 268
 269public sealed record EffectiveIdentityProviderConnection(
 270    IdentityProviderConnection Connection,
 271    ConnectionSourceOwnership Ownership,
 272    ConnectionScope Scope,
 273    ConnectionValidity Validity,
 274    bool IsShadowed,
 275    string SourceName)
 276{
 277    public IdentityProviderConnectionReference? ShadowedBy { get; init; }
 278    public IReadOnlyCollection<IdentityProviderConnectionReference> Shadows { get; init; } = [];
 279}
 280
 281public sealed record EffectiveConnectionRegistry(
 282    IReadOnlyCollection<EffectiveIdentityProviderConnection> Connections,
 283    IReadOnlyCollection<LoginMethod> LoginMethods,
 284    string SourceVersion);
 285
 92286public sealed record ConnectionValidationContext(EffectiveIdentityProviderConnection Connection, IReadOnlyDictionary<str
 287
 288public sealed record ExternalAuthorizationContext(EffectiveIdentityProviderConnection Connection, IReadOnlyDictionary<st
 289
 290public sealed record ExternalCallbackContext(EffectiveIdentityProviderConnection Connection, IReadOnlyDictionary<string,
 291
 292public sealed record ConnectionTestContext(EffectiveIdentityProviderConnection Connection, IReadOnlyDictionary<string, R
 293
 294public sealed record ExternalLogoutContext(EffectiveIdentityProviderConnection Connection, IReadOnlyDictionary<string, R
 295
 296public sealed record UnlinkedIdentityContext(string TargetTenantId, EffectiveIdentityProviderConnection Connection, Exte
 297public sealed record ExternalUserMatcherContext(string TargetTenantId, EffectiveIdentityProviderConnection Connection, E
 298
 299public abstract record UnlinkedIdentityDecision
 300{
 301    private UnlinkedIdentityDecision() { }
 302    public sealed record Reject(string SafeReason) : UnlinkedIdentityDecision;
 303    public sealed record CreateUser(UserCreationProposal Proposal) : UnlinkedIdentityDecision;
 304    public sealed record LinkExistingUser(string UserId, string AuthorizationBasis) : UnlinkedIdentityDecision;
 305}
 306
 307public sealed record ExternalIdentityResolutionContext(string TargetTenantId, EffectiveIdentityProviderConnection Connec
 308
 309public sealed record PermissionGrantContext(string TargetTenantId, string UserId, EffectiveIdentityProviderConnection Co
 310public sealed record PermissionGrantResolutionContext(string TargetTenantId, string UserId, EffectiveIdentityProviderCon
 311
 312public abstract record ExternalAuthenticationSessionRotationResult
 313{
 314    private ExternalAuthenticationSessionRotationResult() { }
 315    public sealed record Rotated(ExternalAuthenticationSession Session) : ExternalAuthenticationSessionRotationResult;
 316    public sealed record NotFound : ExternalAuthenticationSessionRotationResult;
 317    public sealed record Expired : ExternalAuthenticationSessionRotationResult;
 318    public sealed record Reused : ExternalAuthenticationSessionRotationResult;
 319    public sealed record Revoked : ExternalAuthenticationSessionRotationResult;
 320}

Methods/Properties

get_Connection()