- Added session timeout settings - Explicitly blocks test/debug/simple-index.php files - Clearer comments on what's protected - Matches simpler approach from root .htaccess - Maintains security without breaking functionality |
||
|---|---|---|
| .. | ||
| .env.example | ||
| .htaccess | ||
| .htaccess-old | ||
| APACHE_DEPLOY.md | ||
| auth.php | ||
| AuthMiddleware.php | ||
| config.php | ||
| download.php | ||
| env_loader.php | ||
| generate-simple.php | ||
| generate.php | ||
| index-streaming.php | ||
| index.php | ||
| JWTValidator.php | ||
| MAMP_QUICK_START.txt | ||
| MAMP_SETUP.md | ||
| QUICK_START.md | ||
| README.md | ||
| simple-index.php | ||
| test-index.php | ||
| test.php | ||
Newsroom Reporter - Web Interface
A PHP web interface for generating newsroom reports with SSO authentication.
Features
- SSO Authentication: Uses the same Microsoft Azure AD authentication as NANO-RESEARCH
- Date Selection: Choose any date to generate reports
- Real-time Output: Streams Python script output to the browser
- Secure Download: Authenticated PDF downloads
- Beautiful UI: Modern, responsive design with Montserrat font
Setup Instructions
1. Copy SSO Configuration from NANO-RESEARCH
The web interface uses the same SSO settings as your NANO-RESEARCH app.
Create .env file in the web/ directory:
cp .env.example .env
Edit .env and add your SSO credentials:
SSO_ENABLED=true
SSO_TENANT_ID=your-tenant-id-from-nano-research
SSO_CLIENT_ID=your-client-id-from-nano-research
You can find these values in /Users/daveporter/Desktop/CODING-2024/NANO-RESEARCH/.env
2. Configure Web Server
Option A: Local Development with PHP Built-in Server
cd web/
php -S localhost:8000
Then visit: http://localhost:8000
Option B: Apache/Nginx
- Point your web server document root to the
web/directory - Ensure PHP is enabled
- Ensure the
reports/directory is writable by the web server
3. Azure AD App Registration
If not already done for NANO-RESEARCH, register the application in Azure AD:
- Go to Azure Portal → Azure Active Directory → App registrations
- Use the same app registration as NANO-RESEARCH, or create a new one
- Add redirect URI:
http://your-domain/index.php - Copy Tenant ID and Client ID to
.env
File Structure
web/
├── index.php # Main UI (date selection, output streaming)
├── generate.php # Backend script (runs Python, streams output)
├── download.php # Secure PDF download handler
├── auth.php # Authentication API endpoint
├── config.php # Configuration
├── AuthMiddleware.php # SSO authentication logic
├── JWTValidator.php # JWT token validation
├── env_loader.php # Environment variable loader
├── .env.example # Environment template
└── .env # Your SSO credentials (gitignored)
Usage
- Access the app: Open in browser (http://localhost:8000 or your domain)
- Sign in: Click "Sign In with Microsoft"
- Enter date: Type date like "Tuesday, January 7"
- Generate: Click "Generate Report" button
- Watch output: See real-time Python output streaming
- Download: Click "Download PDF Report" when complete
Security
- SSO Authentication: Only authenticated Microsoft users can access
- Path Traversal Prevention: Filename validation prevents directory attacks
- Secure Cookies: HttpOnly, SameSite cookies for session management
- JWT Validation: Tokens validated against Azure AD
Troubleshooting
SSO Not Working
- Check
.envfile has correct SSO_TENANT_ID and SSO_CLIENT_ID - Verify redirect URI is registered in Azure AD app
Python Script Errors
- Check Python virtual environment is activated:
source ../venv/bin/activate - Verify dependencies installed:
pip install -r ../requirements.txt - Check file permissions on
reports/directory
Output Not Streaming
- Disable output buffering in
php.ini:output_buffering = Off
Development Mode
To disable SSO for local testing:
SSO_ENABLED=false
You'll be logged in as "Local Developer" without authentication.
Production Deployment
- Set
SSO_ENABLED=truein.env - Use HTTPS (required for secure cookies)
- Set proper file permissions
- Enable error logging, disable display_errors
- Configure web server security headers
Enjoy your automated newsroom reports! 📰