| | | 1 | | using System.Security.Claims; |
| | | 2 | | |
| | | 3 | | namespace Elsa.Identity.Models; |
| | | 4 | | |
| | | 5 | | /// <summary>Identifies whether a role dependency can be changed through an administration API.</summary> |
| | | 6 | | public enum RoleDeletionDependencyOwnership |
| | | 7 | | { |
| | | 8 | | Configuration, |
| | | 9 | | Database |
| | | 10 | | } |
| | | 11 | | |
| | | 12 | | /// <summary>Describes how a role-remediation command will be executed.</summary> |
| | | 13 | | public enum RoleDeletionExecutionMode |
| | | 14 | | { |
| | | 15 | | Atomic, |
| | | 16 | | BestEffort |
| | | 17 | | } |
| | | 18 | | |
| | | 19 | | /// <summary>A safe reference to a role from an installed module.</summary> |
| | | 20 | | public sealed record RoleDeletionDependency( |
| | | 21 | | string Source, |
| | | 22 | | string OwnerId, |
| | | 23 | | string OwnerKey, |
| | | 24 | | string PolicyBranch, |
| | | 25 | | RoleDeletionDependencyOwnership Ownership, |
| | | 26 | | string? ConfigurationPath, |
| | | 27 | | long? ExpectedRevision, |
| | | 28 | | bool RemovesLastDefaultRole); |
| | | 29 | | |
| | | 30 | | /// <summary>A contributor-owned dependency snapshot.</summary> |
| | | 31 | | public sealed record RoleDeletionDependencySnapshot( |
| | | 32 | | string Source, |
| | | 33 | | string Version, |
| | | 34 | | bool SupportsAtomicRemoval, |
| | | 35 | | IReadOnlyCollection<RoleDeletionDependency> Dependencies); |
| | | 36 | | |
| | | 37 | | /// <summary>The aggregated impact of deleting a role.</summary> |
| | | 38 | | public sealed record RoleDeletionImpact( |
| | | 39 | | string RoleId, |
| | | 40 | | string DependencyVersion, |
| | | 41 | | RoleDeletionExecutionMode ExecutionMode, |
| | | 42 | | bool CanDelete, |
| | | 43 | | bool CanRemediate, |
| | | 44 | | IReadOnlyCollection<RoleDeletionDependency> Dependencies); |
| | | 45 | | |
| | | 46 | | /// <summary>Inputs used to prevalidate or remove one contributor's editable references.</summary> |
| | | 47 | | public sealed record RoleReferenceRemovalRequest( |
| | | 48 | | string RoleId, |
| | | 49 | | ClaimsPrincipal Actor, |
| | | 50 | | string ExpectedContributorVersion, |
| | | 51 | | IReadOnlyCollection<RoleDeletionDependency> Dependencies); |
| | | 52 | | |
| | | 53 | | /// <summary>Inputs for the coordinated remediation command.</summary> |
| | | 54 | | public sealed record RoleDeletionRemediationCommand( |
| | | 55 | | string RoleId, |
| | | 56 | | ClaimsPrincipal Actor, |
| | | 57 | | string ExpectedDependencyVersion, |
| | | 58 | | bool ConfirmRemoveFromEditablePolicies, |
| | | 59 | | bool ConfirmEmptyDefaultRoles, |
| | | 60 | | bool ConfirmBestEffort); |
| | | 61 | | |
| | | 62 | | public abstract record RoleReferenceRemovalValidationResult |
| | | 63 | | { |
| | | 64 | | private RoleReferenceRemovalValidationResult() |
| | | 65 | | { |
| | | 66 | | } |
| | | 67 | | |
| | | 68 | | public sealed record Valid : RoleReferenceRemovalValidationResult; |
| | | 69 | | public sealed record Forbidden(string Code) : RoleReferenceRemovalValidationResult; |
| | | 70 | | public sealed record Conflict(string Code) : RoleReferenceRemovalValidationResult; |
| | | 71 | | } |
| | | 72 | | |
| | | 73 | | public abstract record RoleReferenceRemovalResult |
| | | 74 | | { |
| | | 75 | | private RoleReferenceRemovalResult() |
| | | 76 | | { |
| | | 77 | | } |
| | | 78 | | |
| | | 79 | | public sealed record Success(IReadOnlyCollection<string> ChangedOwnerIds) : RoleReferenceRemovalResult; |
| | | 80 | | public sealed record Conflict(string Code, IReadOnlyCollection<string> ChangedOwnerIds) : RoleReferenceRemovalResult |
| | | 81 | | public sealed record Failed(string Code, IReadOnlyCollection<string> ChangedOwnerIds) : RoleReferenceRemovalResult; |
| | | 82 | | } |
| | | 83 | | |
| | | 84 | | public abstract record RoleDeletionInspectionResult |
| | | 85 | | { |
| | | 86 | | private RoleDeletionInspectionResult() |
| | | 87 | | { |
| | | 88 | | } |
| | | 89 | | |
| | | 90 | | public sealed record Success(RoleDeletionImpact Impact) : RoleDeletionInspectionResult; |
| | | 91 | | public sealed record NotFound : RoleDeletionInspectionResult; |
| | | 92 | | public sealed record Forbidden : RoleDeletionInspectionResult; |
| | | 93 | | } |
| | | 94 | | |
| | | 95 | | public abstract record RoleDeletionOperationResult |
| | | 96 | | { |
| | 4 | 97 | | private RoleDeletionOperationResult() |
| | | 98 | | { |
| | 4 | 99 | | } |
| | | 100 | | |
| | 2 | 101 | | public sealed record Deleted(IReadOnlyCollection<string> ChangedOwnerIds) : RoleDeletionOperationResult; |
| | | 102 | | public sealed record NotFound : RoleDeletionOperationResult; |
| | | 103 | | public sealed record Forbidden : RoleDeletionOperationResult; |
| | 1 | 104 | | public sealed record Blocked(RoleDeletionImpact Impact) : RoleDeletionOperationResult; |
| | 0 | 105 | | public sealed record PreconditionFailed(RoleDeletionImpact Impact) : RoleDeletionOperationResult; |
| | 2 | 106 | | public sealed record ConfirmationRequired(RoleDeletionImpact Impact, IReadOnlyCollection<string> Warnings) : RoleDel |
| | 2 | 107 | | public sealed record Incomplete(RoleDeletionImpact Impact, IReadOnlyCollection<string> ChangedOwnerIds, string Code) |
| | | 108 | | } |