feat(02-02): define PermissionEntry, ScanOptions, and IPermissionsService
- PermissionEntry record with 9 fields matching PS Generate-PnPSitePermissionRpt - ScanOptions record with defaults: IncludeInherited=false, ScanFolders=true, FolderDepth=1, IncludeSubsites=false - IPermissionsService interface with ScanSiteAsync method enabling ViewModel mocking
This commit is contained in:
17
SharepointToolbox/Core/Models/PermissionEntry.cs
Normal file
17
SharepointToolbox/Core/Models/PermissionEntry.cs
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
namespace SharepointToolbox.Core.Models;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Flat record representing one permission assignment on a SharePoint object.
|
||||||
|
/// Mirrors the $entry object built by the PowerShell Generate-PnPSitePermissionRpt function.
|
||||||
|
/// </summary>
|
||||||
|
public record PermissionEntry(
|
||||||
|
string ObjectType, // "Site Collection" | "Site" | "List" | "Folder"
|
||||||
|
string Title,
|
||||||
|
string Url,
|
||||||
|
bool HasUniquePermissions,
|
||||||
|
string Users, // Semicolon-joined display names
|
||||||
|
string UserLogins, // Semicolon-joined login names
|
||||||
|
string PermissionLevels, // Semicolon-joined role names (Limited Access already removed)
|
||||||
|
string GrantedThrough, // "Direct Permissions" | "SharePoint Group: <name>"
|
||||||
|
string PrincipalType // "SharePointGroup" | "User" | "External User"
|
||||||
|
);
|
||||||
12
SharepointToolbox/Core/Models/ScanOptions.cs
Normal file
12
SharepointToolbox/Core/Models/ScanOptions.cs
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
namespace SharepointToolbox.Core.Models;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Immutable scan configuration value object.
|
||||||
|
/// Controls which SharePoint objects are included in the permission scan.
|
||||||
|
/// </summary>
|
||||||
|
public record ScanOptions(
|
||||||
|
bool IncludeInherited = false, // When false: only objects with unique permissions are returned
|
||||||
|
bool ScanFolders = true, // Include folder-level permission entries
|
||||||
|
int FolderDepth = 1, // Max folder depth to scan (999 = unlimited)
|
||||||
|
bool IncludeSubsites = false // Whether to recursively scan subsites
|
||||||
|
);
|
||||||
17
SharepointToolbox/Services/IPermissionsService.cs
Normal file
17
SharepointToolbox/Services/IPermissionsService.cs
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
using Microsoft.SharePoint.Client;
|
||||||
|
using SharepointToolbox.Core.Models;
|
||||||
|
|
||||||
|
namespace SharepointToolbox.Services;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Contract for the permission scan engine.
|
||||||
|
/// Enables ViewModel mocking in unit tests.
|
||||||
|
/// </summary>
|
||||||
|
public interface IPermissionsService
|
||||||
|
{
|
||||||
|
Task<IReadOnlyList<PermissionEntry>> ScanSiteAsync(
|
||||||
|
ClientContext ctx,
|
||||||
|
ScanOptions options,
|
||||||
|
IProgress<OperationProgress> progress,
|
||||||
|
CancellationToken ct);
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user