| | | 1 | | using System.Security.Claims; |
| | | 2 | | using System.Text.Json; |
| | | 3 | | using Elsa.Abstractions; |
| | | 4 | | using Elsa.Common; |
| | | 5 | | using Elsa.ExternalAuthentication.Contracts; |
| | | 6 | | using Elsa.ExternalAuthentication.Models; |
| | | 7 | | using Elsa.ExternalAuthentication.Notifications; |
| | | 8 | | using Elsa.ExternalAuthentication.Options; |
| | | 9 | | using Elsa.ExternalAuthentication.Permissions; |
| | | 10 | | using Elsa.ExternalAuthentication.Providers; |
| | | 11 | | using Elsa.Mediator.Contracts; |
| | | 12 | | using Microsoft.Extensions.DependencyInjection; |
| | | 13 | | using Microsoft.Extensions.Logging; |
| | | 14 | | using Microsoft.Extensions.Options; |
| | | 15 | | |
| | | 16 | | namespace Elsa.ExternalAuthentication.Services; |
| | | 17 | | |
| | | 18 | | /// <summary> |
| | | 19 | | /// Applies management-only invariants before mutating database-owned connections. |
| | | 20 | | /// Connection stores remain responsible for durable compare-and-swap and unique-key enforcement. |
| | | 21 | | /// </summary> |
| | 86 | 22 | | public sealed partial class IdentityProviderConnectionManagementService( |
| | 86 | 23 | | IIdentityProviderConnectionStore store, |
| | 86 | 24 | | IIdentityProviderConnectionRegistry registry, |
| | 86 | 25 | | IIdentityProviderConnectionValidityAssessor validityAssessor, |
| | 86 | 26 | | IConnectionRegistryVersionStore registryVersions, |
| | 86 | 27 | | IExternalAuthenticationAdapterRegistry adapters, |
| | 86 | 28 | | IAdapterSettingsMigrationService settingsMigrations, |
| | 86 | 29 | | IUnlinkedIdentityPolicyRegistry policies, |
| | 86 | 30 | | IExternalUserMatcherRegistry matchers, |
| | 86 | 31 | | IPermissionGrantSourceRegistry grantSources, |
| | 86 | 32 | | IEnumerable<ISecretBindingResolver> secretBindingResolvers, |
| | 86 | 33 | | IEnumerable<IManagedSecretBindingWriter> managedSecretBindingWriters, |
| | 86 | 34 | | IPermissionDelegationAuthorizer delegationAuthorizer, |
| | 86 | 35 | | ConnectionRevisionCalculator revisionCalculator, |
| | 86 | 36 | | ISystemClock clock, |
| | 86 | 37 | | IOptions<ExternalAuthenticationOptions> options, |
| | 86 | 38 | | Elsa.Identity.Contracts.IRoleAuthorizationService roleAuthorizationService, |
| | 86 | 39 | | IExternalAuthenticationSessionStore sessions, |
| | 86 | 40 | | IServiceProvider services, |
| | 86 | 41 | | ILogger<IdentityProviderConnectionManagementService> logger) |
| | | 42 | | { |
| | 170 | 43 | | private readonly IReadOnlyDictionary<string, ISecretBindingResolver> _secretBindingResolvers = secretBindingResolver |
| | 170 | 44 | | private readonly IReadOnlyDictionary<string, IManagedSecretBindingWriter> _managedSecretBindingWriters = managedSecr |
| | | 45 | | |
| | | 46 | | public async ValueTask<ManagementConnectionLookupResult> FindAsync(string id, string targetTenantId, CancellationTok |
| | | 47 | | { |
| | 38 | 48 | | var effective = await registry.FindByIdAsync(targetTenantId, id, cancellationToken); |
| | 38 | 49 | | if (effective is not null && effective.Scope == ConnectionScope.Host) |
| | 37 | 50 | | return new ManagementConnectionLookupResult.Found(await validityAssessor.AssessAsync(effective, cancellation |
| | | 51 | | |
| | 1 | 52 | | var connection = await store.FindByIdAsync(id, cancellationToken); |
| | 1 | 53 | | if (connection is null || connection.TenantId != ConnectionScope.HostTenantId) |
| | 1 | 54 | | return new ManagementConnectionLookupResult.NotFound(); |
| | | 55 | | |
| | 0 | 56 | | return new ManagementConnectionLookupResult.Found(await validityAssessor.AssessAsync(ToEffective(connection), ca |
| | 38 | 57 | | } |
| | | 58 | | |
| | | 59 | | /// <summary>Returns the deployment-derived read-only upstream callback URI for management display.</summary> |
| | 33 | 60 | | public Uri? GetProviderCallbackUri(IdentityProviderConnection connection) => options.Value.Redirects.ExternalCallbac |
| | 33 | 61 | | ? ExternalAuthenticationCallbackUris.GetAuthorizationCallbackUri(baseUri, connection, BrokerTransactionPurpose.E |
| | 33 | 62 | | : null; |
| | | 63 | | |
| | | 64 | | /// <summary>Returns the deployment-derived read-only callback URI used by provider preview sign-ins.</summary> |
| | 33 | 65 | | public Uri? GetProviderPreviewCallbackUri(IdentityProviderConnection connection) => options.Value.Redirects.External |
| | 33 | 66 | | ? ExternalAuthenticationCallbackUris.GetAuthorizationCallbackUri(baseUri, connection, BrokerTransactionPurpose.P |
| | 33 | 67 | | : null; |
| | | 68 | | |
| | | 69 | | public async ValueTask<IReadOnlyCollection<EffectiveIdentityProviderConnection>> ListAsync(string targetTenantId, Co |
| | | 70 | | { |
| | 2 | 71 | | var effective = await registry.GetAsync(targetTenantId, cancellationToken); |
| | 2 | 72 | | var matches = effective.Connections |
| | 6 | 73 | | .Where(x => x.Scope == ConnectionScope.Host) |
| | 6 | 74 | | .Where(x => Matches(x, filter)) |
| | 6 | 75 | | .OrderBy(x => x.Scope.Kind) |
| | 6 | 76 | | .ThenBy(x => x.Connection.DisplayOrder) |
| | 6 | 77 | | .ThenBy(x => x.Connection.Key, StringComparer.Ordinal) |
| | 6 | 78 | | .ThenBy(x => x.Connection.Id, StringComparer.Ordinal) |
| | 2 | 79 | | .ToArray(); |
| | 8 | 80 | | return await Task.WhenAll(matches.Select(x => validityAssessor.AssessAsync(x, cancellationToken).AsTask())); |
| | 2 | 81 | | } |
| | | 82 | | |
| | | 83 | | public async ValueTask<ManagementConnectionMutationResult> CreateAsync(IdentityProviderConnection connection, Claims |
| | | 84 | | { |
| | 19 | 85 | | NormalizeForCreate(connection, targetTenantId); |
| | 19 | 86 | | if (!CanMutate(connection.TenantId, targetTenantId)) |
| | 0 | 87 | | return new ManagementConnectionMutationResult.Forbidden(); |
| | 19 | 88 | | var validation = await ValidateAsync(connection, actor, targetTenantId, requireCompleteConfiguration: false, con |
| | 19 | 89 | | if (!validation.IsValid) |
| | 6 | 90 | | return new ManagementConnectionMutationResult.ValidationFailed(validation); |
| | 13 | 91 | | if (await CollidesWithConfigurationOrHostAsync(connection, null, targetTenantId, cancellationToken)) |
| | 2 | 92 | | return new ManagementConnectionMutationResult.Conflict("connection_key_conflict"); |
| | | 93 | | |
| | 11 | 94 | | connection.MaterialRevision = revisionCalculator.CalculateMaterialRevision(connection); |
| | 11 | 95 | | var result = await store.CreateAsync(connection, cancellationToken); |
| | 11 | 96 | | return await ProcessMutationAsync(result, actor, "created", null, cancellationToken); |
| | 19 | 97 | | } |
| | | 98 | | |
| | | 99 | | public async ValueTask<ManagementConnectionMutationResult> UpdateAsync(string id, IdentityProviderConnection candida |
| | | 100 | | { |
| | 14 | 101 | | var existing = await store.FindByIdAsync(id, cancellationToken); |
| | 14 | 102 | | if (existing is null || existing.TenantId != ConnectionScope.HostTenantId) |
| | 0 | 103 | | return new ManagementConnectionMutationResult.NotFound(); |
| | 14 | 104 | | if (!CanMutate(existing.TenantId, targetTenantId)) |
| | 0 | 105 | | return new ManagementConnectionMutationResult.Forbidden(); |
| | | 106 | | |
| | 14 | 107 | | candidate.Id = existing.Id; |
| | 14 | 108 | | candidate.CreatedAt = existing.CreatedAt; |
| | 14 | 109 | | candidate.Revision = existing.Revision; |
| | 14 | 110 | | candidate.ArchivedAt = existing.ArchivedAt; |
| | 14 | 111 | | NormalizeForUpdate(candidate, existing); |
| | 14 | 112 | | if (!CanMutate(candidate.TenantId, targetTenantId)) |
| | 0 | 113 | | return new ManagementConnectionMutationResult.Forbidden(); |
| | 14 | 114 | | if (!string.Equals(existing.Key, candidate.Key, StringComparison.Ordinal)) |
| | 1 | 115 | | return new ManagementConnectionMutationResult.Conflict("connection_key_immutable"); |
| | 13 | 116 | | var requireUnsafeConfirmation = adapters.TryGet(candidate.AdapterType, out var candidateAdapter) && |
| | 13 | 117 | | UnsafeSettingsChanged(existing.AdapterSettings, candidate.AdapterSettings, candidateAdapter.Describe()); |
| | 13 | 118 | | var validation = await ValidateAsync(candidate, actor, targetTenantId, requireCompleteConfiguration: candidate.I |
| | 12 | 119 | | if (!validation.IsValid) |
| | 1 | 120 | | return new ManagementConnectionMutationResult.ValidationFailed(validation); |
| | | 121 | | |
| | 11 | 122 | | if (await IsBlockedByFinalLoginPathGuardAsync(existing, candidate, targetTenantId, actor, confirmFinalLoginPathO |
| | 1 | 123 | | return new ManagementConnectionMutationResult.Conflict("final_login_path_guard"); |
| | | 124 | | |
| | 10 | 125 | | candidate.MaterialRevision = revisionCalculator.CalculateMaterialRevision(candidate); |
| | 10 | 126 | | var result = await store.UpdateAsync(candidate, expectedRevision, cancellationToken); |
| | 10 | 127 | | return await ProcessMutationAsync(result, actor, "updated", GetLifecycle(existing), cancellationToken, existing) |
| | 13 | 128 | | } |
| | | 129 | | |
| | | 130 | | public async ValueTask<ManagementConnectionMutationResult> ChangeLifecycleAsync(string id, ConnectionLifecycle actio |
| | | 131 | | { |
| | 5 | 132 | | var existing = await store.FindByIdAsync(id, cancellationToken); |
| | 5 | 133 | | if (existing is null || existing.TenantId != ConnectionScope.HostTenantId) |
| | 0 | 134 | | return new ManagementConnectionMutationResult.NotFound(); |
| | 5 | 135 | | if (!CanMutate(existing.TenantId, targetTenantId)) |
| | 0 | 136 | | return new ManagementConnectionMutationResult.Forbidden(); |
| | | 137 | | |
| | 5 | 138 | | var previousLifecycle = GetLifecycle(existing); |
| | 5 | 139 | | var candidate = IdentityProviderConnectionCloner.Clone(existing); |
| | | 140 | | switch (action) |
| | | 141 | | { |
| | | 142 | | case ConnectionLifecycle.Enabled: |
| | | 143 | | { |
| | 2 | 144 | | var validation = await ValidateAsync(candidate, actor, targetTenantId, requireCompleteConfiguration: tru |
| | 2 | 145 | | if (!validation.IsValid) |
| | 1 | 146 | | return new ManagementConnectionMutationResult.ValidationFailed(validation); |
| | 1 | 147 | | if (candidate.ArchivedAt.HasValue) |
| | 0 | 148 | | return new ManagementConnectionMutationResult.Conflict("connection_archived"); |
| | 1 | 149 | | if (candidate.IsPreferred) |
| | | 150 | | { |
| | 0 | 151 | | var current = await registry.GetAsync(targetTenantId, cancellationToken); |
| | 0 | 152 | | if (current.Connections.Any(x => |
| | 0 | 153 | | x.Ownership == ConnectionSourceOwnership.Configuration && |
| | 0 | 154 | | !x.IsShadowed && |
| | 0 | 155 | | x.Connection.IsEnabled && |
| | 0 | 156 | | !x.Connection.ArchivedAt.HasValue && |
| | 0 | 157 | | x.Connection.IsPreferred && |
| | 0 | 158 | | x.Validity != ConnectionValidity.Invalid && |
| | 0 | 159 | | (!candidate.OverridesConfigurationConnection || !string.Equals(x.Connection.Key, candidate.K |
| | 0 | 160 | | return new ManagementConnectionMutationResult.Conflict("configuration_preferred_connection"); |
| | 0 | 161 | | if (current.Connections.Any(x => x.Ownership == ConnectionSourceOwnership.Database && x.Connection.I |
| | 0 | 162 | | return new ManagementConnectionMutationResult.Conflict("default_connection_conflict"); |
| | | 163 | | } |
| | 1 | 164 | | candidate.IsEnabled = true; |
| | 1 | 165 | | break; |
| | | 166 | | } |
| | | 167 | | case ConnectionLifecycle.Disabled: |
| | 1 | 168 | | if (candidate.ArchivedAt.HasValue) |
| | 0 | 169 | | return new ManagementConnectionMutationResult.Conflict("connection_archived"); |
| | 1 | 170 | | candidate.IsEnabled = false; |
| | 1 | 171 | | break; |
| | | 172 | | case ConnectionLifecycle.Archived: |
| | 1 | 173 | | candidate.IsEnabled = false; |
| | 1 | 174 | | candidate.ArchivedAt = clock.UtcNow; |
| | 1 | 175 | | break; |
| | | 176 | | case ConnectionLifecycle.Draft: |
| | 1 | 177 | | if (!candidate.ArchivedAt.HasValue) |
| | 0 | 178 | | return new ManagementConnectionMutationResult.Conflict("connection_not_archived"); |
| | 1 | 179 | | candidate.ArchivedAt = null; |
| | 1 | 180 | | candidate.IsEnabled = false; |
| | 1 | 181 | | break; |
| | | 182 | | default: |
| | 0 | 183 | | return new ManagementConnectionMutationResult.Conflict("invalid_lifecycle_action"); |
| | | 184 | | } |
| | | 185 | | |
| | 4 | 186 | | candidate.UpdatedAt = clock.UtcNow; |
| | 4 | 187 | | candidate.MaterialRevision = revisionCalculator.CalculateMaterialRevision(candidate); |
| | 4 | 188 | | if (await IsBlockedByFinalLoginPathGuardAsync(existing, candidate, targetTenantId, actor, confirmFinalLoginPathO |
| | 0 | 189 | | return new ManagementConnectionMutationResult.Conflict("final_login_path_guard"); |
| | 4 | 190 | | var result = await store.UpdateAsync(candidate, expectedRevision, cancellationToken); |
| | 4 | 191 | | var processed = await ProcessMutationAsync(result, actor, action.ToString().ToLowerInvariant(), previousLifecycl |
| | 4 | 192 | | if (processed is ManagementConnectionMutationResult.Success && action == ConnectionLifecycle.Disabled && revokeA |
| | | 193 | | { |
| | 1 | 194 | | var connectionKey = ConnectionRevisionCalculator.NormalizeKey(candidate.Key); |
| | 1 | 195 | | var revokedCount = await sessions.RevokeActiveForConnectionAsync(connectionKey, "connection_disabled", clock |
| | 1 | 196 | | await PublishBulkSessionRevocationAsync(candidate, actor, revokedCount); |
| | | 197 | | } |
| | 4 | 198 | | return processed; |
| | 5 | 199 | | } |
| | | 200 | | |
| | | 201 | | public async ValueTask<ConnectionValidationResult> ValidateAsync(IdentityProviderConnection connection, ClaimsPrinci |
| | | 202 | | { |
| | 37 | 203 | | var errors = new List<ConnectionValidationError>(); |
| | 37 | 204 | | var warnings = new List<string>(); |
| | 37 | 205 | | var configuredOptions = options.Value; |
| | 37 | 206 | | ValidateEnvelope(connection, configuredOptions, errors); |
| | | 207 | | |
| | 37 | 208 | | if (!adapters.TryGet(connection.AdapterType, out var adapter) || !IsAllowed(configuredOptions.AllowedAdapterType |
| | 0 | 209 | | errors.Add(new ConnectionValidationError("adapterType", "unavailable", "The selected adapter is not installe |
| | | 210 | | |
| | 37 | 211 | | await ValidatePolicyAsync(connection, actor, configuredOptions, errors, cancellationToken); |
| | 36 | 212 | | ValidateGrantSources(connection, configuredOptions, errors); |
| | 36 | 213 | | if (connection.PermissionGrantSources.Count != 0) |
| | | 214 | | { |
| | 0 | 215 | | var delegation = await delegationAuthorizer.AuthorizeAsync(actor, connection.PermissionGrantSources.ToArray( |
| | 0 | 216 | | if (!delegation.IsAuthorized) |
| | 0 | 217 | | errors.Add(new ConnectionValidationError("permissionGrantSources", "delegation_denied", "The caller may |
| | | 218 | | } |
| | | 219 | | |
| | 36 | 220 | | if (adapter is null) |
| | 0 | 221 | | return new ConnectionValidationResult(false, errors, warnings); |
| | | 222 | | |
| | 36 | 223 | | await ApplySettingsMigrationAsync(connection, errors, cancellationToken); |
| | 36 | 224 | | if (errors.Count != 0) |
| | 6 | 225 | | return new ConnectionValidationResult(false, errors, warnings); |
| | | 226 | | |
| | 30 | 227 | | var descriptor = adapter.Describe(); |
| | 30 | 228 | | ValidateSecretBindingFields(connection, descriptor, requireCompleteConfiguration, errors); |
| | 30 | 229 | | ValidateSecretBindingsAreNotAdapterSettings(connection.AdapterSettings, descriptor, errors); |
| | 30 | 230 | | if (requireUnsafeConfirmation && UsesUnsafeSettings(connection.AdapterSettings, descriptor) && (!confirmUnsafeSe |
| | 0 | 231 | | errors.Add(new ConnectionValidationError("adapterSettings", "unsafe_confirmation_required", "Unsafe provider |
| | | 232 | | |
| | 30 | 233 | | if (requireCompleteConfiguration) |
| | | 234 | | { |
| | 6 | 235 | | var secretStates = await GetSecretStatesAsync(connection, cancellationToken); |
| | 14 | 236 | | foreach (var (name, state) in secretStates) |
| | | 237 | | { |
| | 1 | 238 | | if (!state.IsConfigured) |
| | 0 | 239 | | errors.Add(new ConnectionValidationError($"secretBindings.{name}", "required", "A required secret bi |
| | 1 | 240 | | else if (!state.IsResolvable) |
| | 0 | 241 | | errors.Add(new ConnectionValidationError($"secretBindings.{name}", "unresolvable", "The secret bindi |
| | | 242 | | } |
| | | 243 | | } |
| | | 244 | | |
| | 30 | 245 | | if (errors.Count != 0 || allowIncompleteDraft) |
| | 25 | 246 | | return new ConnectionValidationResult(errors.Count == 0, errors, warnings); |
| | | 247 | | |
| | 5 | 248 | | var effective = ToEffective(connection); |
| | 5 | 249 | | var adapterValidation = await adapter.ValidateAsync(new ConnectionValidationContext(effective, new Dictionary<st |
| | 5 | 250 | | errors.AddRange(adapterValidation.Errors); |
| | 5 | 251 | | warnings.AddRange(adapterValidation.Warnings); |
| | 5 | 252 | | return new ConnectionValidationResult(errors.Count == 0 && adapterValidation.IsValid, errors, warnings); |
| | 36 | 253 | | } |
| | | 254 | | |
| | 33 | 255 | | public ValueTask<IReadOnlyDictionary<string, SecretBindingState>> GetSecretBindingStatesAsync(IdentityProviderConnec |
| | | 256 | | |
| | 5 | 257 | | public SecretBindingPresentation PresentSecretBinding(SecretBinding binding, SecretBindingState? state) => new( |
| | 5 | 258 | | binding.Ownership == SecretBindingOwnership.Managed ? "managed" : "external", |
| | 5 | 259 | | state?.IsConfigured ?? false, |
| | 5 | 260 | | state?.IsResolvable ?? false); |
| | | 261 | | |
| | 1 | 262 | | public bool CanCreateConfigurationOverride() => options.Value.AllowConfigurationConnectionOverrides; |
| | | 263 | | |
| | | 264 | | public bool CanPromoteToConfigurationOverride(EffectiveIdentityProviderConnection connection) => |
| | 33 | 265 | | connection.Ownership == ConnectionSourceOwnership.Database && |
| | 33 | 266 | | connection.IsShadowed && |
| | 33 | 267 | | !connection.Connection.ArchivedAt.HasValue && |
| | 33 | 268 | | options.Value.AllowConfigurationConnectionOverrides; |
| | | 269 | | |
| | | 270 | | private async ValueTask<bool> IsBlockedByFinalLoginPathGuardAsync(IdentityProviderConnection existing, IdentityProvi |
| | | 271 | | { |
| | 15 | 272 | | var guard = services.GetService<FinalLoginPathGuard>(); |
| | 15 | 273 | | if (guard is null) |
| | 0 | 274 | | return false; |
| | | 275 | | |
| | 15 | 276 | | var guardExisting = existing; |
| | 15 | 277 | | if (!existing.OverridesConfigurationConnection && candidate.OverridesConfigurationConnection) |
| | | 278 | | { |
| | 2 | 279 | | var normalizedKey = ConnectionRevisionCalculator.NormalizeKey(candidate.Key); |
| | 2 | 280 | | var effective = await registry.GetAsync(targetTenantId, cancellationToken); |
| | 2 | 281 | | var displacedConfigurationConnection = effective.Connections.FirstOrDefault(x => |
| | 4 | 282 | | x.Ownership == ConnectionSourceOwnership.Configuration && |
| | 4 | 283 | | !x.IsShadowed && |
| | 4 | 284 | | string.Equals(ConnectionRevisionCalculator.NormalizeKey(x.Connection.Key), normalizedKey, StringComparis |
| | 2 | 285 | | if (displacedConfigurationConnection is not null) |
| | 2 | 286 | | guardExisting = displacedConfigurationConnection.Connection; |
| | 2 | 287 | | } |
| | | 288 | | |
| | 15 | 289 | | return await guard.AuthorizeAsync(guardExisting, candidate, targetTenantId, actor, confirmedOverride, cancellati |
| | 15 | 290 | | } |
| | | 291 | | |
| | | 292 | | private async ValueTask<ManagementConnectionMutationResult> ProcessMutationAsync(ConnectionMutationResult result, Cl |
| | | 293 | | { |
| | | 294 | | switch (result) |
| | | 295 | | { |
| | | 296 | | case ConnectionMutationResult.Created(var createdConnection): |
| | 11 | 297 | | await RunPostCommitActionsAsync(createdConnection, actor, operation, previousLifecycle, previousConnecti |
| | 11 | 298 | | return new ManagementConnectionMutationResult.Success(createdConnection); |
| | | 299 | | case ConnectionMutationResult.Updated(var updatedConnection): |
| | 12 | 300 | | await RunPostCommitActionsAsync(updatedConnection, actor, operation, previousLifecycle, previousConnecti |
| | 12 | 301 | | return new ManagementConnectionMutationResult.Success(updatedConnection); |
| | | 302 | | case ConnectionMutationResult.NotFound: |
| | 0 | 303 | | return new ManagementConnectionMutationResult.NotFound(); |
| | | 304 | | case ConnectionMutationResult.DuplicateKey: |
| | 0 | 305 | | return new ManagementConnectionMutationResult.Conflict("connection_key_conflict"); |
| | | 306 | | case ConnectionMutationResult.RevisionConflict(var currentRevision): |
| | 2 | 307 | | return new ManagementConnectionMutationResult.PreconditionFailed(currentRevision); |
| | | 308 | | default: |
| | 0 | 309 | | throw new InvalidOperationException("The connection store returned an unknown mutation result."); |
| | | 310 | | } |
| | 25 | 311 | | } |
| | | 312 | | |
| | | 313 | | private async ValueTask RunPostCommitActionsAsync(IdentityProviderConnection connection, ClaimsPrincipal actor, stri |
| | | 314 | | { |
| | | 315 | | try |
| | | 316 | | { |
| | 23 | 317 | | await registryVersions.AdvanceAsync(CancellationToken.None); |
| | 23 | 318 | | } |
| | 0 | 319 | | catch (Exception exception) |
| | | 320 | | { |
| | 0 | 321 | | logger.LogCritical(exception, "Connection {ConnectionId} was committed, but advancing the external-authentic |
| | 0 | 322 | | } |
| | | 323 | | |
| | | 324 | | try |
| | | 325 | | { |
| | 23 | 326 | | await PublishAsync(connection, actor, operation, previousLifecycle, previousConnection, CancellationToken.No |
| | 22 | 327 | | } |
| | 1 | 328 | | catch (Exception exception) |
| | | 329 | | { |
| | 1 | 330 | | logger.LogError(exception, "Connection {ConnectionId} was committed, but publishing external-authentication |
| | 1 | 331 | | } |
| | 23 | 332 | | } |
| | | 333 | | |
| | | 334 | | private async ValueTask PublishBulkSessionRevocationAsync(IdentityProviderConnection connection, ClaimsPrincipal act |
| | | 335 | | { |
| | 1 | 336 | | if (revokedCount == 0) |
| | 0 | 337 | | return; |
| | | 338 | | |
| | 1 | 339 | | var notificationSender = services.GetService<INotificationSender>(); |
| | 1 | 340 | | if (notificationSender is null) |
| | 0 | 341 | | return; |
| | | 342 | | |
| | | 343 | | try |
| | | 344 | | { |
| | 1 | 345 | | var context = new SecurityEventContext( |
| | 1 | 346 | | actor.FindFirstValue(ClaimTypes.NameIdentifier) ?? actor.FindFirstValue("sub"), |
| | 1 | 347 | | connection.TenantId, |
| | 1 | 348 | | connection.Id, |
| | 1 | 349 | | null, |
| | 1 | 350 | | clock.UtcNow, |
| | 1 | 351 | | SecurityEventOutcome.Succeeded, |
| | 1 | 352 | | Guid.NewGuid().ToString("N"), |
| | 1 | 353 | | "Active external authentication sessions were revoked when the connection was disabled."); |
| | 1 | 354 | | await notificationSender.SendAsync(new ExternalAuthenticationConnectionSessionsRevoked(context, revokedCount |
| | 1 | 355 | | } |
| | 0 | 356 | | catch (Exception exception) |
| | | 357 | | { |
| | 0 | 358 | | logger.LogError(exception, "Connection {ConnectionId} sessions were revoked, but publishing the aggregate se |
| | 0 | 359 | | } |
| | 1 | 360 | | } |
| | | 361 | | |
| | | 362 | | private async ValueTask PublishAsync(IdentityProviderConnection connection, ClaimsPrincipal actor, string operation, |
| | | 363 | | { |
| | 23 | 364 | | var notificationSender = services.GetService<INotificationSender>(); |
| | 23 | 365 | | if (notificationSender is null) |
| | 0 | 366 | | return; |
| | | 367 | | |
| | 23 | 368 | | var context = new SecurityEventContext( |
| | 23 | 369 | | actor.FindFirstValue(ClaimTypes.NameIdentifier) ?? actor.FindFirstValue("sub"), |
| | 23 | 370 | | connection.TenantId, |
| | 23 | 371 | | connection.Id, |
| | 23 | 372 | | null, |
| | 23 | 373 | | clock.UtcNow, |
| | 23 | 374 | | SecurityEventOutcome.Succeeded, |
| | 23 | 375 | | Guid.NewGuid().ToString("N"), |
| | 23 | 376 | | "Identity provider connection management operation completed."); |
| | 23 | 377 | | await notificationSender.SendAsync(new IdentityProviderConnectionChanged(context, operation, connection.Revision |
| | 22 | 378 | | if (previousLifecycle is { } previous && previous != GetLifecycle(connection)) |
| | 4 | 379 | | await notificationSender.SendAsync(new IdentityProviderConnectionLifecycleChanged(context, previous.ToString |
| | 22 | 380 | | if (previousConnection is not null) |
| | | 381 | | { |
| | 11 | 382 | | var fields = previousConnection.SecretBindings.Keys |
| | 11 | 383 | | .Concat(connection.SecretBindings.Keys) |
| | 11 | 384 | | .Distinct(StringComparer.Ordinal) |
| | 15 | 385 | | .Where(field => !previousConnection.SecretBindings.TryGetValue(field, out var before) || !connection.Sec |
| | 28 | 386 | | foreach (var field in fields) |
| | | 387 | | { |
| | 3 | 388 | | previousConnection.SecretBindings.TryGetValue(field, out var previousBinding); |
| | 3 | 389 | | connection.SecretBindings.TryGetValue(field, out var binding); |
| | 3 | 390 | | var isConfigured = binding is not null && _secretBindingResolvers.TryGetValue(binding.ResolverType, out |
| | 3 | 391 | | await notificationSender.SendAsync(new IdentityProviderConnectionSecretBindingChanged(context, field, bi |
| | 3 | 392 | | } |
| | | 393 | | } |
| | 22 | 394 | | } |
| | | 395 | | |
| | | 396 | | private async ValueTask<bool> CollidesWithConfigurationOrHostAsync(IdentityProviderConnection candidate, string? sel |
| | | 397 | | { |
| | 13 | 398 | | var lookupTenant = candidate.TenantId == ConnectionScope.HostTenantId ? ConnectionScope.HostTenantId : candidate |
| | 13 | 399 | | var effective = await registry.GetAsync(lookupTenant, cancellationToken); |
| | 13 | 400 | | var key = ConnectionRevisionCalculator.NormalizeKey(candidate.Key); |
| | 15 | 401 | | if (effective.Connections.Any(x => x.Ownership == ConnectionSourceOwnership.Configuration && x.Scope.TenantId == |
| | 1 | 402 | | return !candidate.OverridesConfigurationConnection; |
| | | 403 | | |
| | 12 | 404 | | if (candidate.TenantId != ConnectionScope.HostTenantId) |
| | 0 | 405 | | return effective.Connections.Any(x => |
| | 0 | 406 | | !string.Equals(x.Connection.Id, selfId, StringComparison.Ordinal) && |
| | 0 | 407 | | x.Scope.Kind == ConnectionScopeKind.Host && |
| | 0 | 408 | | string.Equals(ConnectionRevisionCalculator.NormalizeKey(x.Connection.Key), key, StringComparison.Ordinal)); |
| | | 409 | | |
| | 12 | 410 | | var rows = await store.FindAsync(new ConnectionFilter(), cancellationToken); |
| | 12 | 411 | | if (rows.Items.Any(x => |
| | 15 | 412 | | !string.Equals(x.Id, selfId, StringComparison.Ordinal) && |
| | 15 | 413 | | x.TenantId != ConnectionScope.HostTenantId && |
| | 15 | 414 | | string.Equals(ConnectionRevisionCalculator.NormalizeKey(x.Key), key, StringComparison.Ordinal))) |
| | 1 | 415 | | return true; |
| | | 416 | | |
| | 11 | 417 | | return options.Value.ConfigurationConnections.Any(x => |
| | 11 | 418 | | x.TenantId != ConnectionScope.HostTenantId && |
| | 11 | 419 | | string.Equals(ConnectionRevisionCalculator.NormalizeKey(x.Key), key, StringComparison.Ordinal)); |
| | 13 | 420 | | } |
| | | 421 | | |
| | | 422 | | private async ValueTask<IReadOnlyDictionary<string, SecretBindingState>> GetSecretStatesAsync(IdentityProviderConnec |
| | | 423 | | { |
| | 39 | 424 | | var states = new Dictionary<string, SecretBindingState>(StringComparer.Ordinal); |
| | 90 | 425 | | foreach (var (name, binding) in connection.SecretBindings) |
| | | 426 | | { |
| | 6 | 427 | | if (!_secretBindingResolvers.TryGetValue(binding.ResolverType, out var resolver)) |
| | 0 | 428 | | states[name] = new SecretBindingState(false, false); |
| | | 429 | | else |
| | 6 | 430 | | states[name] = await resolver.GetStateAsync(binding, cancellationToken); |
| | | 431 | | } |
| | | 432 | | |
| | 39 | 433 | | return states; |
| | 39 | 434 | | } |
| | | 435 | | |
| | | 436 | | private async ValueTask ApplySettingsMigrationAsync(IdentityProviderConnection connection, ICollection<ConnectionVal |
| | | 437 | | { |
| | | 438 | | try |
| | | 439 | | { |
| | 36 | 440 | | var migration = await settingsMigrations.MigrateAsync(connection.AdapterType, connection.AdapterSettingsVers |
| | 34 | 441 | | connection.AdapterSettingsVersion = migration.SettingsVersion; |
| | 34 | 442 | | connection.AdapterSettings = migration.Settings; |
| | 34 | 443 | | } |
| | 2 | 444 | | catch (InvalidOperationException) |
| | | 445 | | { |
| | 2 | 446 | | errors.Add(new ConnectionValidationError("adapterSettingsVersion", "migration_unavailable", "The adapter set |
| | 2 | 447 | | } |
| | 36 | 448 | | } |
| | | 449 | | |
| | | 450 | | private void NormalizeForCreate(IdentityProviderConnection connection, string targetTenantId) |
| | | 451 | | { |
| | 19 | 452 | | connection.Id = string.IsNullOrWhiteSpace(connection.Id) ? Guid.NewGuid().ToString("N") : connection.Id; |
| | 19 | 453 | | connection.Key = connection.Key?.Trim() ?? string.Empty; |
| | 19 | 454 | | connection.TenantId = ConnectionScope.HostTenantId; |
| | 19 | 455 | | connection.IsEnabled = false; |
| | 19 | 456 | | connection.ArchivedAt = null; |
| | 19 | 457 | | connection.Revision = 1; |
| | 19 | 458 | | connection.CreatedAt = clock.UtcNow; |
| | 19 | 459 | | connection.UpdatedAt = clock.UtcNow; |
| | 19 | 460 | | connection.MaterialRevision = revisionCalculator.CalculateMaterialRevision(connection); |
| | 19 | 461 | | } |
| | | 462 | | |
| | | 463 | | private void NormalizeForUpdate(IdentityProviderConnection candidate, IdentityProviderConnection existing) |
| | | 464 | | { |
| | 14 | 465 | | candidate.Key = candidate.Key?.Trim() ?? string.Empty; |
| | 14 | 466 | | candidate.TenantId = ConnectionScope.HostTenantId; |
| | 14 | 467 | | candidate.IsEnabled = existing.IsEnabled; |
| | 14 | 468 | | candidate.UpdatedAt = clock.UtcNow; |
| | 14 | 469 | | candidate.SecretBindings ??= new Dictionary<string, SecretBinding>(StringComparer.Ordinal); |
| | 14 | 470 | | candidate.PermissionGrantSources ??= []; |
| | 14 | 471 | | candidate.ClaimProjection ??= ClaimProjection.Empty; |
| | 14 | 472 | | } |
| | | 473 | | |
| | | 474 | | private static void ValidateEnvelope(IdentityProviderConnection connection, ExternalAuthenticationOptions configured |
| | | 475 | | { |
| | 37 | 476 | | if (!configuredOptions.EnableDatabaseConnections) |
| | 0 | 477 | | errors.Add(new ConnectionValidationError("source", "disabled", "Database-owned connections are disabled by d |
| | 37 | 478 | | if (connection.OverridesConfigurationConnection && !configuredOptions.AllowConfigurationConnectionOverrides) |
| | 1 | 479 | | errors.Add(new ConnectionValidationError("overridesConfigurationConnection", "not_allowed", "This deployment |
| | 37 | 480 | | if (string.IsNullOrWhiteSpace(connection.Key) || connection.Key.Length > 128 || connection.Key.Any(char.IsWhiteS |
| | 0 | 481 | | errors.Add(new ConnectionValidationError("key", "invalid", "Connection keys must be non-empty lowercase URL- |
| | 37 | 482 | | else if (!ConnectionKeyPattern().IsMatch(connection.Key)) |
| | 1 | 483 | | errors.Add(new ConnectionValidationError("key", "invalid", "Connection keys must use lowercase letters, digi |
| | 37 | 484 | | if (string.IsNullOrWhiteSpace(connection.DisplayName) || connection.DisplayName.Trim().Length > 256) |
| | 0 | 485 | | errors.Add(new ConnectionValidationError("displayName", "invalid", "Display name is required and may not exc |
| | 37 | 486 | | if (connection.AdapterSettingsVersion <= 0) |
| | 0 | 487 | | errors.Add(new ConnectionValidationError("adapterSettingsVersion", "invalid", "Adapter settings version must |
| | 37 | 488 | | if (!Enum.IsDefined(connection.UpstreamLogoutMode)) |
| | 0 | 489 | | errors.Add(new ConnectionValidationError("upstreamLogoutMode", "invalid", "Upstream logout mode is invalid." |
| | 37 | 490 | | if (!IsValidScope(connection.TenantId)) |
| | 0 | 491 | | errors.Add(new ConnectionValidationError("scope", "host_scope_required", "Identity provider connections are |
| | 37 | 492 | | if (connection.ClaimProjection.MaximumClaimCount < 0 || connection.ClaimProjection.MaximumValueLength < 0 || con |
| | 37 | 493 | | connection.ClaimProjection.MaximumClaimCount > configuredOptions.Claims.MaximumClaimCount || connection.Clai |
| | 0 | 494 | | errors.Add(new ConnectionValidationError("claimProjection", "invalid", "Claim projection limits exceed deplo |
| | 37 | 495 | | if (!connection.ClaimProjection.RedactedClaimTypes.IsSubsetOf(connection.ClaimProjection.AllowedClaimTypes)) |
| | 0 | 496 | | errors.Add(new ConnectionValidationError("claimProjection.redactedClaimTypes", "invalid", "Redacted claim ty |
| | 37 | 497 | | } |
| | | 498 | | |
| | | 499 | | private async ValueTask ValidatePolicyAsync(IdentityProviderConnection connection, ClaimsPrincipal actor, ExternalAu |
| | | 500 | | { |
| | 37 | 501 | | if (connection.UnlinkedPolicy is not { } policy) |
| | 33 | 502 | | return; |
| | 4 | 503 | | if (!configuredOptions.UnlinkedIdentityPolicy.AllowDatabaseConnectionOverride) |
| | 0 | 504 | | errors.Add(new ConnectionValidationError("unlinkedPolicy", "not_allowed", "This deployment does not allow da |
| | 4 | 505 | | else if (policy.SettingsVersion <= 0 || !policies.TryGet(policy.Type, out _) || !IsAllowed(configuredOptions.All |
| | 0 | 506 | | errors.Add(new ConnectionValidationError("unlinkedPolicy", "unavailable", "The selected unlinked identity po |
| | | 507 | | else |
| | | 508 | | { |
| | 4 | 509 | | if (UsesCreateUserFallback(policy) && |
| | 4 | 510 | | !await roleAuthorizationService.CanAssignRolesAsync(actor, Policies.CreateUserUnlinkedIdentityPolicy.Rea |
| | 1 | 511 | | errors.Add(new ConnectionValidationError("unlinkedPolicy.defaultRoleIds", "forbidden", "The selected def |
| | | 512 | | |
| | 3 | 513 | | if (string.Equals(policy.Type, Policies.MatchExternalUserUnlinkedIdentityPolicy.PolicyType, StringComparison |
| | 3 | 514 | | (!TryGetMatcherSelection(policy.Settings, out var matcherType, out var matcherSettingsVersion) || |
| | 3 | 515 | | !IsAllowed(configuredOptions.AllowedExternalUserMatcherTypes, matcherType) || |
| | 3 | 516 | | !matchers.TryGet(matcherType, out _) || |
| | 5 | 517 | | matchers.ListDescriptors().All(x => !string.Equals(x.Type, matcherType, StringComparison.Ordinal) || x. |
| | 1 | 518 | | errors.Add(new ConnectionValidationError("unlinkedPolicy.matcher", "unavailable", "The selected external |
| | 3 | 519 | | } |
| | 36 | 520 | | } |
| | | 521 | | |
| | | 522 | | private static bool UsesCreateUserFallback(PolicySelection policy) => |
| | 4 | 523 | | string.Equals(policy.Type, Policies.CreateUserUnlinkedIdentityPolicy.PolicyType, StringComparison.Ordinal) || |
| | 4 | 524 | | string.Equals(policy.Type, Policies.MatchExternalUserUnlinkedIdentityPolicy.PolicyType, StringComparison.Ordinal |
| | 4 | 525 | | string.Equals(ReadString(policy.Settings, "noMatchAction"), "create-user", StringComparison.OrdinalIgnoreCase); |
| | | 526 | | |
| | | 527 | | private static bool TryGetMatcherSelection(JsonElement settings, out string matcherType, out int settingsVersion) |
| | | 528 | | { |
| | 3 | 529 | | matcherType = string.Empty; |
| | 3 | 530 | | settingsVersion = 0; |
| | 3 | 531 | | if (settings.ValueKind != JsonValueKind.Object || !settings.TryGetProperty("matcher", out var matcher) || matche |
| | 0 | 532 | | return false; |
| | | 533 | | |
| | 3 | 534 | | matcherType = type.GetString() ?? string.Empty; |
| | 3 | 535 | | return !string.IsNullOrWhiteSpace(matcherType) && matcher.TryGetProperty("settingsVersion", out var version) && |
| | | 536 | | } |
| | | 537 | | |
| | | 538 | | private static string? ReadString(JsonElement settings, string propertyName) => |
| | 4 | 539 | | settings.ValueKind == JsonValueKind.Object && |
| | 4 | 540 | | settings.TryGetProperty(propertyName, out var value) && |
| | 4 | 541 | | value.ValueKind == JsonValueKind.String |
| | 4 | 542 | | ? value.GetString() |
| | 4 | 543 | | : null; |
| | | 544 | | |
| | | 545 | | private void ValidateGrantSources(IdentityProviderConnection connection, ExternalAuthenticationOptions configuredOpt |
| | | 546 | | { |
| | 36 | 547 | | var orders = new HashSet<int>(); |
| | 72 | 548 | | foreach (var source in connection.PermissionGrantSources) |
| | | 549 | | { |
| | 0 | 550 | | if (source.SettingsVersion <= 0 || !grantSources.TryGet(source.Type, out _) || !IsAllowed(configuredOptions. |
| | 0 | 551 | | errors.Add(new ConnectionValidationError("permissionGrantSources", "unavailable", "A selected permission |
| | 0 | 552 | | if (!orders.Add(source.Order)) |
| | 0 | 553 | | errors.Add(new ConnectionValidationError("permissionGrantSources", "duplicate_order", "Permission grant |
| | | 554 | | } |
| | 36 | 555 | | } |
| | | 556 | | |
| | | 557 | | private static void ValidateSecretBindingFields(IdentityProviderConnection connection, ExternalAuthenticationAdapter |
| | | 558 | | { |
| | 120 | 559 | | var secretFields = descriptor.Fields.Where(x => x.IsSecretBinding).ToDictionary(x => x.Name, StringComparer.Ordi |
| | 72 | 560 | | foreach (var name in connection.SecretBindings.Keys) |
| | 6 | 561 | | if (!secretFields.ContainsKey(name)) |
| | 0 | 562 | | errors.Add(new ConnectionValidationError($"secretBindings.{name}", "undeclared", "The adapter does not d |
| | 30 | 563 | | if (!requireCompleteConfiguration) |
| | 24 | 564 | | return; |
| | 20 | 565 | | foreach (var field in secretFields.Values.Where(x => x.IsRequired)) |
| | 1 | 566 | | if (!connection.SecretBindings.ContainsKey(field.Name)) |
| | 1 | 567 | | errors.Add(new ConnectionValidationError($"secretBindings.{field.Name}", "required", "A required secret |
| | 6 | 568 | | } |
| | | 569 | | |
| | | 570 | | private static void ValidateSecretBindingsAreNotAdapterSettings(JsonElement settings, ExternalAuthenticationAdapterD |
| | | 571 | | { |
| | 30 | 572 | | if (settings.ValueKind != JsonValueKind.Object) |
| | 0 | 573 | | return; |
| | | 574 | | |
| | 180 | 575 | | foreach (var field in descriptor.Fields.Where(x => x.IsSecretBinding)) |
| | 30 | 576 | | if (settings.TryGetProperty(field.Name, out _)) |
| | 1 | 577 | | errors.Add(new ConnectionValidationError($"adapterSettings.{field.Name}", "secret_binding_required", "Se |
| | 30 | 578 | | } |
| | | 579 | | |
| | | 580 | | private static bool UsesUnsafeSettings(JsonElement settings, ExternalAuthenticationAdapterDescriptor descriptor) |
| | | 581 | | { |
| | 14 | 582 | | if (settings.ValueKind != JsonValueKind.Object) |
| | 0 | 583 | | return false; |
| | 42 | 584 | | return descriptor.Fields.Where(x => x.IsUnsafe).Any(field => |
| | 28 | 585 | | settings.TryGetProperty(field.Name, out var value) && IsUnsafeFieldValue(field, value)); |
| | | 586 | | } |
| | | 587 | | |
| | | 588 | | private static bool UnsafeSettingsChanged(JsonElement beforeSettings, JsonElement afterSettings, ExternalAuthenticat |
| | | 589 | | { |
| | 13 | 590 | | if (afterSettings.ValueKind != JsonValueKind.Object) |
| | 0 | 591 | | return false; |
| | | 592 | | |
| | 78 | 593 | | foreach (var field in descriptor.Fields.Where(x => x.IsUnsafe)) |
| | | 594 | | { |
| | 13 | 595 | | if (!afterSettings.TryGetProperty(field.Name, out var afterValue) || !IsUnsafeFieldValue(field, afterValue)) |
| | | 596 | | continue; |
| | 2 | 597 | | if (beforeSettings.ValueKind != JsonValueKind.Object || !beforeSettings.TryGetProperty(field.Name, out var b |
| | 0 | 598 | | return true; |
| | | 599 | | } |
| | | 600 | | |
| | 13 | 601 | | return false; |
| | 0 | 602 | | } |
| | | 603 | | |
| | | 604 | | private static bool IsUnsafeFieldValue(SettingFieldDescriptor field, JsonElement value) => |
| | 3 | 605 | | value.ValueKind is not JsonValueKind.Null and not JsonValueKind.Undefined and not JsonValueKind.False && |
| | 3 | 606 | | (!string.Equals(field.Name, "providerPkce", StringComparison.Ordinal) || value.ValueKind != JsonValueKind.String |
| | | 607 | | |
| | | 608 | | private static bool JsonValueEquals(JsonElement left, JsonElement right) => |
| | 2 | 609 | | left.ValueKind == right.ValueKind && string.Equals(left.GetRawText(), right.GetRawText(), StringComparison.Ordin |
| | | 610 | | |
| | 5 | 611 | | private static EffectiveIdentityProviderConnection ToEffective(IdentityProviderConnection connection) => new(connect |
| | 5 | 612 | | private static ConnectionScope ToScope(string tenantId) => tenantId == ConnectionScope.HostTenantId ? ConnectionScop |
| | 52 | 613 | | private static bool CanMutate(string connectionTenantId, string targetTenantId) => connectionTenantId == ConnectionS |
| | 37 | 614 | | private static bool IsValidScope(string tenantId) => tenantId == ConnectionScope.HostTenantId; |
| | 0 | 615 | | private static string NormalizeScopeTenantId(string requestedTenantId, string fallback) => requestedTenantId is null |
| | 44 | 616 | | private static bool IsAllowed(ICollection<string> allowedTypes, string type) => allowedTypes.Count == 0 || allowedTy |
| | 2 | 617 | | private static bool HasPermission(ClaimsPrincipal actor, string permission) => actor.FindAll(PermissionNames.ClaimTy |
| | 30 | 618 | | private static ConnectionLifecycle GetLifecycle(IdentityProviderConnection connection) => connection.ArchivedAt.HasV |
| | | 619 | | private static bool Matches(EffectiveIdentityProviderConnection connection, ConnectionFilter filter) => |
| | 6 | 620 | | (filter.Ownership is null || filter.Ownership == connection.Ownership) && |
| | 6 | 621 | | (filter.Scope is null || filter.Scope == connection.Scope) && |
| | 6 | 622 | | (string.IsNullOrWhiteSpace(filter.Search) || connection.Connection.Key.Contains(filter.Search, StringComparison. |
| | 6 | 623 | | (string.IsNullOrWhiteSpace(filter.AdapterType) || string.Equals(filter.AdapterType, connection.Connection.Adapte |
| | 6 | 624 | | (!filter.IsEnabled.HasValue || filter.IsEnabled.Value == connection.Connection.IsEnabled) && |
| | 6 | 625 | | (!filter.IsArchived.HasValue || filter.IsArchived.Value == connection.Connection.ArchivedAt.HasValue); |
| | | 626 | | |
| | | 627 | | [System.Text.RegularExpressions.GeneratedRegex("^[a-z0-9](?:[a-z0-9-]{0,126}[a-z0-9])?$")] |
| | | 628 | | private static partial System.Text.RegularExpressions.Regex ConnectionKeyPattern(); |
| | | 629 | | } |
| | | 630 | | |
| | | 631 | | public abstract record ManagementConnectionLookupResult |
| | | 632 | | { |
| | | 633 | | private ManagementConnectionLookupResult() { } |
| | | 634 | | public sealed record Found(EffectiveIdentityProviderConnection Connection) : ManagementConnectionLookupResult; |
| | | 635 | | public sealed record NotFound : ManagementConnectionLookupResult; |
| | | 636 | | } |
| | | 637 | | |
| | | 638 | | public abstract record ManagementConnectionMutationResult |
| | | 639 | | { |
| | | 640 | | private ManagementConnectionMutationResult() { } |
| | | 641 | | public sealed record Success(IdentityProviderConnection Connection) : ManagementConnectionMutationResult; |
| | | 642 | | public sealed record NotFound : ManagementConnectionMutationResult; |
| | | 643 | | public sealed record Conflict(string Code) : ManagementConnectionMutationResult; |
| | | 644 | | public sealed record PreconditionFailed(long CurrentRevision) : ManagementConnectionMutationResult; |
| | | 645 | | public sealed record Forbidden : ManagementConnectionMutationResult; |
| | | 646 | | public sealed record ValidationFailed(ConnectionValidationResult Validation) : ManagementConnectionMutationResult; |
| | | 647 | | } |