A SharePoint permissions auditing application for analyzing site permissions, sharing links, and security risks.
Early development - Not recommended for production use. Breaking changes expected.
The tool collects and displays:
- Sharing Links - Anonymous, organization-wide, and specific-people links with metadata (expiration, password protection, download restrictions, member lists)
- Permission Assignments - Direct role assignments on sites, lists, and items
- Broken Inheritance - Items with unique permissions that differ from their parent
- Sensitivity Labels - Microsoft Information Protection labels applied to content
- Site Structure - Webs, lists, libraries, folders, and files
- Principals - Users, groups, and security principals with access
Each audit creates a snapshot (audit run) that can be compared over time.
The tool requires an Entra ID (Azure AD) app registration with certificate authentication.
- Go to Azure Portal > Microsoft Entra ID > App registrations
- Click New registration
- Name:
spaudit(or your preference) - Supported account types: Accounts in this organizational directory only
- Click Register
- Copy the Application (client) ID and Directory (tenant) ID
- Go to API permissions > Add a permission
- Select SharePoint > Application permissions
- Add these permissions:
Sites.FullControl.All(required for sharing link enumeration)
- Click Grant admin consent
Generate a self-signed certificate:
# PowerShell - create certificate
$cert = New-SelfSignedCertificate -Subject "CN=spaudit" -CertStoreLocation "Cert:\CurrentUser\My" -KeyExportPolicy Exportable -KeySpec Signature -KeyLength 2048 -KeyAlgorithm RSA -HashAlgorithm SHA256 -NotAfter (Get-Date).AddYears(2)
# Export PFX (with private key)
$pwd = ConvertTo-SecureString -String "your-password" -Force -AsPlainText
Export-PfxCertificate -Cert $cert -FilePath "spaudit.pfx" -Password $pwd
# Export CER (public key only, for Azure upload)
Export-Certificate -Cert $cert -FilePath "spaudit.cer"- Go to your app registration > Certificates & secrets
- Click Upload certificate
- Upload the
.cerfile (public key)
Copy the .pfx file to your server and configure the environment variables (see Configuration below).
- Go 1.25+
- Mage (
go install github.com/magefile/mage@latest) - Entra ID app registration with SharePoint permissions (see Azure Setup)
- Certificate (.pfx file)
# Clone and bootstrap
git clone https://github.com/f0oster/spaudit && cd spaudit
mage bootstrap
# Configure environment
cd cmd/server
cp ../../.env.example .env
# Edit .env with your SharePoint credentials
# Build and run
mage build
./server.exe- Add Site - Enter a SharePoint site URL in the web interface
- Start Audit - The tool queues a background job to audit the site
- Data Collection - The job connects to SharePoint and collects:
- Site structure (webs, lists, items)
- Permission role assignments
- Sharing links and their members
- Sensitivity labels
- Progress Updates - Real-time progress via Server-Sent Events
- View Results - Browse collected data organized by site, list, and item
Each audit creates a new "audit run" - a point-in-time snapshot. You can switch between audit runs to compare changes.
Jobs can be cancelled from the web interface. The audit supports configurable batch sizes, retry logic, and parallel item scanning.
| Variable | Description |
|---|---|
SP_TENANT_ID |
Azure tenant ID (GUID) |
SP_CLIENT_ID |
App registration client ID (GUID) |
SP_CERT_PATH |
Path to .pfx certificate file |
SP_CERT_PASSWORD |
Certificate password (empty if none) |
| Variable | Default | Description |
|---|---|---|
HTTP_ADDR |
:8080 |
Server listen address |
HTTP_LOG_PATH |
(none) | Path for HTTP request logging (JSON format) |
| Variable | Default | Description |
|---|---|---|
DB_PATH |
./spaudit.db |
SQLite database file path |
DB_MAX_OPEN_CONNS |
25 |
Maximum open connections |
DB_MAX_IDLE_CONNS |
5 |
Maximum idle connections |
DB_CONN_MAX_LIFETIME |
1h |
Connection max lifetime |
DB_CONN_MAX_IDLE_TIME |
15m |
Idle connection timeout |
DB_BUSY_TIMEOUT_MS |
5000 |
SQLite busy timeout (ms) |
DB_ENABLE_WAL |
true |
Enable Write-Ahead Logging |
| Variable | Default | Description |
|---|---|---|
LOG_LEVEL |
info |
Log level: debug, info, warn, error |
LOG_FORMAT |
json |
Log format: json or text |
LOG_OUTPUT |
stdout |
Output: stdout, stderr, or file path |
mage bootstrap # Install tools and run generators
mage build # Build server binary
mage test # Run tests
mage gen # Regenerate database and template code
mage verify # Run formatting, linting, tests, and buildspaudit/
├── cmd/server/ # Entry point
├── domain/ # Entities, contracts, events
├── application/ # Services
├── infrastructure/ # Repositories, SharePoint client
├── interfaces/web/ # HTTP handlers, templates, presenters
├── platform/ # Job executors, workflows
├── database/ # Migrations and queries
└── gen/db/ # SQLC generated code
- SQLite (modernc.org/sqlite)
- SQLC - SQL code generation
- Chi - HTTP router
- Gosip - SharePoint client
- Templ - HTML templates
- HTMX - Frontend interactivity
MIT License - see LICENSE
For architecture details, see docs/ARCHITECTURE.md.