Azure AD Setup
This guide walks you through configuring Azure AD authentication for Cluster.
Prerequisites
- Azure subscription with Azure Active Directory
- Admin permissions to register applications
- Microsoft 365 tenant with SharePoint
Step 1: Register Application
- Navigate to Azure Portal
- Go to Azure Active Directory → App registrations
- Click New registration
Application Details
| Field | Value |
|---|---|
| Name | Cluster Research Platform |
| Supported account types | Accounts in this organizational directory only (single-tenant) |
| Redirect URI | Single-page application (SPA): http://localhost:3000 |
- Click Register
Step 2: Copy Application IDs
After registration, copy these values:
| Value | Location | Environment Variable |
|---|---|---|
| Application (client) ID | Overview page | AZURE_CLIENT_ID |
| Directory (tenant) ID | Overview page | AZURE_TENANT_ID |
Step 3: Create Client Secret
- Go to Certificates & secrets
- Click New client secret
- Add description:
Cluster API - Choose expiration: 12 months (or per your policy)
- Click Add
- Copy the Value immediately →
AZURE_CLIENT_SECRET
caution
The secret value is only shown once. Copy it now or you'll need to create a new one.
Step 4: Configure API Permissions
- Go to API permissions
- Click Add a permission
- Select Microsoft Graph
- Select Delegated permissions
Add these permissions:
| Permission | Type | Purpose |
|---|---|---|
User.Read | Delegated | Read signed-in user profile |
Files.Read.All | Delegated | Read SharePoint/OneDrive files |
Sites.Read.All | Delegated | List SharePoint sites |
- Click Grant admin consent for [Your Organization]
Verify Permissions
Your permissions should look like:
Microsoft Graph (3)
├── Files.Read.All (Delegated) ✓ Granted
├── Sites.Read.All (Delegated) ✓ Granted
└── User.Read (Delegated) ✓ Granted
Step 5: Configure Authentication
-
Go to Authentication
-
Under Single-page application, verify:
- Redirect URI:
http://localhost:3000
- Redirect URI:
-
Add production URIs when ready:
https://cluster.yourcompany.com
-
Under Implicit grant and hybrid flows:
- ✅ Access tokens
- ✅ ID tokens
-
Click Save
Step 6: Configure Cluster
Server Environment (.env)
AZURE_TENANT_ID=12345678-1234-1234-1234-123456789012
AZURE_CLIENT_ID=87654321-4321-4321-4321-210987654321
AZURE_CLIENT_SECRET=abc123~YourSecretValue
Web Environment (packages/web/.env)
VITE_AZURE_CLIENT_ID=87654321-4321-4321-4321-210987654321
VITE_AZURE_TENANT_ID=12345678-1234-1234-1234-123456789012
VITE_API_URL=http://localhost:4000/api
Step 7: Test Authentication
-
Start Cluster:
pnpm dev -
Click Sign in with Microsoft
-
Authenticate with your organization credentials
-
Grant permissions when prompted
Verify Success
After login, you should see:
- Your name/email in the header
- "Sign out" button
- SharePoint sites list (if you have access)
Troubleshooting
"AADSTS700016: Application not found"
- Verify
AZURE_CLIENT_IDmatches your app registration - Check you're using the correct tenant
"AADSTS50011: Redirect URI mismatch"
- Verify redirect URI in Azure exactly matches:
http://localhost:3000 - No trailing slash
- Must be SPA platform, not Web
"AADSTS65001: User consent required"
- Admin needs to grant consent for delegated permissions
- Go to API permissions → Grant admin consent
"Access token not valid for Microsoft Graph"
- Verify all three permissions are added
- Ensure admin consent is granted
- Try logging out and back in
"Unable to fetch SharePoint sites"
- Verify
Sites.Read.Allpermission is granted - Check that your account has access to SharePoint
- Test by visiting https://yourorg.sharepoint.com
Multi-Tenant Configuration
To allow users from any Azure AD tenant:
-
Change Supported account types to:
- "Accounts in any organizational directory (Any Azure AD directory - Multitenant)"
-
Users from different tenants will create separate organizations in Cluster
Production Checklist
Before going to production:
- Add production redirect URI (
https://your-domain.com) - Remove
localhostredirect URI - Rotate client secret
- Enable Conditional Access policies (optional)
- Configure token lifetime (optional)
Next Steps
- Installation — Complete setup
- Running Cluster — Start the application