-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathStart-SPOTool-Web.ps1
More file actions
103 lines (88 loc) · 3.81 KB
/
Start-SPOTool-Web.ps1
File metadata and controls
103 lines (88 loc) · 3.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#Requires -Version 7.0
<#
.SYNOPSIS
PermiX - Web UI Version
.DESCRIPTION
Launches a local web server that serves a browser-based UI.
The SharePoint/Core backend is identical to the WPF version;
only the presentation layer changes (HTML/CSS/JS instead of XAML/WPF).
.NOTES
Run with: pwsh ./Start-SPOTool-Web.ps1
Opens http://localhost:8080 in your default browser.
#>
param(
[int]$Port = 8080,
[string]$ListenAddress = "localhost",
[switch]$NoBrowser
)
# ============================================
# 1. Load Core modules
# ============================================
. "$PSScriptRoot\Functions\Core\Logging.ps1"
. "$PSScriptRoot\Functions\Core\Settings.ps1"
. "$PSScriptRoot\Functions\Core\OutputAdapter.ps1"
. "$PSScriptRoot\Functions\Core\SharePointDataManager.ps1"
. "$PSScriptRoot\Functions\Core\ThrottleProtection.ps1"
. "$PSScriptRoot\Functions\Core\Checkpoint.ps1"
. "$PSScriptRoot\Functions\Core\AuditLog.ps1"
# ============================================
# 2. Load Analysis modules
# ============================================
. "$PSScriptRoot\Functions\Analysis\JsonExport.ps1"
. "$PSScriptRoot\Functions\Analysis\GraphEnrichment.ps1"
. "$PSScriptRoot\Functions\Analysis\RiskScoring.ps1"
# ============================================
# 3. Load SharePoint modules
# ============================================
. "$PSScriptRoot\Functions\SharePoint\SPOConnection.ps1"
. "$PSScriptRoot\Functions\SharePoint\PermissionsMatrix.ps1"
. "$PSScriptRoot\Functions\SharePoint\SiteCollector.ps1"
. "$PSScriptRoot\Functions\SharePoint\PermissionsCollector.ps1"
# ============================================
# 4. Load Demo modules
# ============================================
. "$PSScriptRoot\Functions\Demo\DemoDataGenerator.ps1"
# ============================================
# 5. Load Web Server modules
# ============================================
. "$PSScriptRoot\Functions\Server\BackgroundJobManager.ps1"
. "$PSScriptRoot\Functions\Server\WebServer.ps1"
. "$PSScriptRoot\Functions\Server\ApiHandlers.ps1"
# ============================================
# 6. Initialize and start
# ============================================
Write-ActivityLog "=== PermiX (Web UI) ===" -Level "Information"
Initialize-SharePointDataManager
# ============================================
# 7. Auto-connect if env vars are set (container mode)
# ============================================
if ($env:SPO_TENANT_URL -and $env:SPO_CLIENT_ID) {
Write-Host ""
Write-Host " SharePoint credentials detected in environment." -ForegroundColor Cyan
Write-Host " Tenant: $($env:SPO_TENANT_URL)" -ForegroundColor White
Write-Host " Client: $($env:SPO_CLIENT_ID)" -ForegroundColor White
Write-Host ""
try {
if (-not (Test-PnPModuleAvailable)) {
throw "PnP.PowerShell module not available"
}
Write-Host " Connecting via device code flow..." -ForegroundColor Yellow
Write-Host " Follow the instructions below to authenticate:" -ForegroundColor Yellow
Write-Host ""
Connect-PnPOnline -Url $env:SPO_TENANT_URL -ClientId $env:SPO_CLIENT_ID -DeviceLogin
$script:SPOConnected = $true
Set-AppSetting -SettingName "SharePoint.TenantUrl" -Value $env:SPO_TENANT_URL
Set-AppSetting -SettingName "SharePoint.ClientId" -Value $env:SPO_CLIENT_ID
Write-Host ""
Write-Host " Connected to SharePoint Online!" -ForegroundColor Green
Write-Host ""
}
catch {
Write-Host ""
Write-Host " Auto-connect failed: $($_.Exception.Message)" -ForegroundColor Red
Write-Host " Starting in disconnected mode. Use Demo Mode or connect via the UI." -ForegroundColor Yellow
Write-Host ""
}
}
# Start the web server (blocks until Ctrl+C)
Start-WebServer -Port $Port -ListenAddress $ListenAddress -NoBrowser:$NoBrowser