Azure Entra
Microsoft Azure AD / Entra ID integration for Single Sign-On (SSO). Allows users to authenticate with their Microsoft organizational account instead of email/password.
Architecture
| Component | Path |
|---|---|
| Auth route | backend/src/routes/entra-auth.ts |
| Service | backend/src/services/entra/ |
| Frontend callback | frontend/src/pages/AuthCallback.tsx |
SSO Flow
- User clicks “Sign in with Microsoft” on login page
- Frontend redirects to Azure Entra authorization endpoint
- User authenticates with Microsoft credentials
- Azure redirects back to
/auth/callbackwith authorization code - Backend exchanges code for tokens, extracts user identity
- Creates or links Users account, issues JWT session
- Frontend
AuthCallbackpage stores JWT and redirects to app
Redirect URI Management
Each environment needs its redirect URI registered in Azure Entra:
| Environment | URI Pattern |
|---|---|
| Development | http://localhost:<port>/auth/callback |
| Staging | https://staging.renewa.app/auth/callback |
| Production | https://app.renewa.app/auth/callback |
| PR Preview | https://renewa-app-pr-<N>.fly.dev/auth/callback |
Managed via: make sso-register which runs scripts/manage-entra-redirect-uri.sh.
See PR Preview Deployments for preview URI registration, Makefile Commands for SSO commands.
Configuration
| Secret | Purpose |
|---|---|
| Azure Tenant ID | Organization directory |
| Azure Client ID | App registration identifier |
| Azure Client Secret | App authentication |
Stored as GitHub Environment Secrets, synced to Fly.io. See Deployment Pipeline.
User Provisioning
On first SSO login, the system:
- Checks if a Users account exists with the Microsoft email
- If exists: links the Azure identity and logs in
- If not: creates a new user account from the Azure profile
Related
- Authentication — Overall auth architecture (JWT, 2FA, password)
- Users — User account creation and linking
- External Integrations — All third-party integrations
- Makefile Commands —
make sso-registercommand - PR Preview Deployments — Dynamic redirect URI registration
- Routing — AuthCallback route handling