- Full-featured web application for PDF processing - Microsoft Entra (Azure AD) authentication with PKCE - Parallel PDF sorting and merging capabilities - Job management system with real-time progress tracking - Modern web UI with responsive design - Comprehensive error handling and logging - Ubuntu installation script for easy deployment - Environment configuration for secure credential management
3.2 KiB
3.2 KiB
Microsoft Entra Authentication Setup Guide
This application uses Microsoft Entra (Azure Active Directory) for authentication. Follow these steps to configure it:
1. Create an Azure AD App Registration
- Go to the Azure Portal
- Navigate to Azure Active Directory > App registrations
- Click New registration
- Enter a name for your app (e.g., "PDF Processor")
- For Supported account types, select "Accounts in this organizational directory only"
- For Redirect URI, select "Web" and enter:
http://localhost:5000/auth/callback - Click Register
2. Configure Authentication
- In your app registration, go to Authentication
- Under Redirect URIs, ensure
http://localhost:5000/auth/callbackis listed - Under Implicit grant and hybrid flows, check:
- Access tokens
- ID tokens
- Click Save
3. Get Application Credentials
- Go to Overview in your app registration
- Copy the Application (client) ID - this is your
AZURE_CLIENT_ID - Copy the Directory (tenant) ID - this is your
AZURE_TENANT_ID
4. Create a Client Secret
- Go to Certificates & secrets
- Click New client secret
- Enter a description and select an expiration
- Click Add
- Important: Copy the secret value immediately - this is your
AZURE_CLIENT_SECRET
5. Configure API Permissions
- Go to API permissions
- Click Add a permission
- Select Microsoft Graph
- Select Delegated permissions
- Add these permissions:
openidprofileemail
- Click Add permissions
- Click Grant admin consent for your organization
6. Configure Environment Variables
Create a .env file in the project root with your Azure AD settings:
# Azure AD Configuration
AZURE_TENANT_ID=your-tenant-id-here
AZURE_CLIENT_ID=your-client-id-here
AZURE_CLIENT_SECRET=your-client-secret-here
AZURE_AUTHORITY=https://login.microsoftonline.com/your-tenant-id-here
AZURE_REDIRECT_URI=http://localhost:5000/auth/callback
AZURE_SCOPES=openid profile email
7. Update Redirect URI for Production
When deploying to production, update the redirect URI in both:
- Azure AD app registration
- Your
.envfile (change localhost to your production domain)
Note: For local development, the app runs on port 5000, so use http://localhost:5000/auth/callback as the redirect URI.
8. Test the Authentication
- Start the application:
python app.py - Visit
http://localhost:5000 - Click "Login with Microsoft"
- You should be redirected to Microsoft login
- After authentication, you'll be redirected back to the app
Troubleshooting
- "invalid_client" error: Check your client ID and secret
- "invalid_request" error: Verify the redirect URI matches exactly
- Permission denied: Ensure you've granted admin consent for the API permissions
- Token errors: Check that your tenant ID is correct
Security Notes
- Never commit the
.envfile to version control - Use strong client secrets and rotate them regularly
- In production, use HTTPS for all authentication flows
- Consider implementing token refresh logic for long-running sessions