Commit graph

12 commits

Author SHA1 Message Date
DJP
3c3523d960 Add graceful fallback if auth system fails
CRITICAL FIX: Page now loads even if auth system has errors

Changes:

1. WRAPPED AUTH IN TRY-CATCH (index.php)
   - Auth errors no longer break the app
   - Falls back to default user if auth fails
   - Logs error but continues loading
   - App functional even with broken auth

2. ADDED COMPOSER AUTOLOAD (JWTValidator.php)
   - Includes vendor/autoload.php for Firebase JWT
   - Checks if file exists before requiring
   - Prevents "Class not found" errors

3. RESILIENT ERROR HANDLING
   - Default user: ['name' => 'User', 'preferred_username' => 'user@localhost']
   - SSO disabled by default if auth fails
   - Error logged to error_log for debugging
   - No blank/broken pages

This ensures:
 App always loads (even with auth issues)
 Can diagnose auth problems without breaking site
 Graceful degradation if Composer not installed yet
 Works during deployment/setup

Perfect for testing and deployment scenarios!

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 (1M context) <noreply@anthropic.com>
2025-12-16 10:26:22 -05:00
DJP
e114b7e430 Fix PHP warnings in image history display
Fixed two errors in Recent Images gallery:

1. Undefined array key "filename" (index.php:1053)
   - Added check: isset($historyItem['filename'])
   - Skip history items without filename key
   - Prevents warning on legacy session data

2. file_get_contents() reading directory (session_manager.php:123)
   - Added is_file() check before file_exists()
   - Ensures path is a file, not directory
   - Returns null for invalid paths
   - Also added is_file() check for metadata file

Additional Improvements:
- Added isset() check for expires_at in metadata
- More robust error handling in getImage()
- Graceful degradation for corrupted history data

Result: No more PHP warnings in Recent Images section

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 (1M context) <noreply@anthropic.com>
2025-12-16 10:10:18 -05:00
DJP
61aa1931bb Add MSAL/Azure AD authentication with toggle support
Implemented complete Microsoft Authentication Library (MSAL) / Azure AD
Single Sign-On (SSO) system following Ferrero app pattern.

KEY FEATURE: Toggle authentication on/off via environment variable
- SSO_ENABLED=false → Mock user, no login required (local dev)
- SSO_ENABLED=true → Full Azure AD authentication (production)

NEW FILES:
- composer.json - Firebase JWT dependency
- .env.example - Environment variable template
- env_loader.php - Parse .env file
- JWTValidator.php - Validate JWT tokens from Azure AD
- AuthMiddleware.php - Core auth orchestrator with login UI
- auth.php - Authentication API (login/logout/status)
- auth-test.php - Debug authentication status
- AUTH_README.md - Complete setup documentation

UPDATED FILES:
- config.php - Load env vars, add SSO constants
- index.php - Require auth, add logout button, MSAL script
- api.php - Add authentication check
- enhance_prompt.php - Add authentication check
- .gitignore - Exclude .env and vendor/

AUTHENTICATION FLOW:
1. User visits app → Auth check
2. If SSO disabled → Mock "Local Developer" user
3. If SSO enabled → Validate JWT from cookie
4. If no token → Show MSAL login page
5. User signs in → Token validated → Cookie set → App loads

SECURITY FEATURES:
 httpOnly cookies (XSS prevention)
 SameSite=Lax (CSRF prevention)
 JWT signature validation
 Claims validation (exp, nbf, aud, iss)
 JWKS from Azure AD
 24-hour token expiration
 Secure flag for HTTPS

DEPENDENCIES INSTALLED:
- firebase/php-jwt v6.11.1

TESTING:
- Local: SSO disabled by default in .env
- Server: Set SSO_ENABLED=true with Azure AD credentials
- Cannot test MSAL locally (redirect URI bound to server)

DEPLOYMENT:
1. Install composer dependencies
2. Configure .env with Azure AD credentials
3. Set SSO_ENABLED=true when ready
4. Visit auth-test.php to verify setup

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 (1M context) <noreply@anthropic.com>
2025-12-16 10:08:07 -05:00
DJP
7f2dd95e73 Add lightbox modal for full-size image inspection
UX Improvements:
- Click main image to view full-size in lightbox modal
- Dark overlay backdrop (95% opacity black)
- Smooth zoom-in animation
- Click outside or close button (×) to close
- ESC key closes lightbox
- Hover effect on main image (subtle scale)
- Prevents background scrolling when open

Modal Features:
- Full-screen overlay (95% viewport)
- Rounded corners and shadow on image
- Animated close button (turns gold on hover)
- Click-to-close on background
- Responsive sizing (max 95% width/height)

Perfect for inspecting generated images in detail!

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 (1M context) <noreply@anthropic.com>
2025-12-16 09:27:38 -05:00
DJP
c5c28da8af Fix CSS conflict - conversation history now actually compact
Problem: Both conversation history and image gallery used .history-item class
Result: Conversation boxes were forced to square aspect-ratio (1:1)

Solution:
- Renamed image gallery class: .history-item → .history-image-item
- Renamed overlay class: .history-item-overlay → .history-image-overlay
- Conversation history keeps .history-item (now properly compact)

Now Working:
- Conversation history: Single-line compact items
- Image gallery: Square thumbnails as intended
- No CSS conflicts between the two

The conversation history boxes are now actually compact instead of
just having centered text in big square boxes!

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 (1M context) <noreply@anthropic.com>
2025-12-16 09:16:31 -05:00
DJP
0f8b82aca6 Make conversation history more compact
UI Improvements:
- Reduced padding: 15px → 10px vertical
- Prompt and time on same line (flexbox layout)
- Removed unnecessary vertical spacing
- Time aligned to right, no-wrap
- Smaller font sizes for better density
- Tighter line height (1.3)

Before: Large boxes with lots of empty space
After: Compact single-line items showing more history

Visual Changes:
- History items now ~40% shorter
- Time displays inline on right
- More items visible without scrolling
- Cleaner, more efficient use of space

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 (1M context) <noreply@anthropic.com>
2025-12-16 09:08:13 -05:00
DJP
24132234d6 Add image history gallery (last 10 images)
New Features:
- Track last 10 generated images per session
- Display thumbnail gallery below main image
- Click any thumbnail to download that image
- Timestamps show when each image was created
- Hover effects highlight thumbnails

UI Components:
- Responsive grid layout (auto-fill 120px thumbnails)
- Hover overlay with timestamp
- Golden border on hover
- Shows count: "Recent Images (X/10)"

SessionManager Updates:
- addToImageHistory() - Track images (max 10)
- getImageHistory() - Retrieve history array
- restoreImageFromHistory() - Restore previous image
- Auto-adds to history when setCurrentImage() called

User Experience:
- Easy access to recent generations
- Quick downloads without re-generating
- Visual timeline of session work
- 24-hour persistence (with images)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 (1M context) <noreply@anthropic.com>
2025-12-16 09:06:34 -05:00
DJP
baee82606a Fix quick action buttons to populate prompt instead of auto-submit
Quick action buttons now:
- Populate the prompt field with suggested text
- Focus on the prompt field for editing
- Scroll to prompt field for visibility
- User can edit before clicking Generate

Previously: Auto-submitted form immediately
Now: User has control to review/edit before generating

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 (1M context) <noreply@anthropic.com>
2025-12-16 09:03:32 -05:00
DJP
7d1cd03a32 Add multi-user support with 24-hour image expiration
Implemented complete session management system for multiple users:

**New Features:**
- Isolated user sessions with unique session IDs
- File-based image storage (not in PHP session)
- Automatic 24-hour image expiration
- Session directories: uploads/sessions/{session_id}/
- Images stored with metadata (creation time, expiry, MIME type)

**New Files:**
- session_manager.php - Complete session management class
- cleanup.php - Cron script to delete expired images
- uploads/.htaccess - Security: prevent direct file access

**Updated Files:**
- api.php - Uses SessionManager for file-based storage
- index.php - Loads images from disk via SessionManager
- .gitignore - Exclude user uploads from repository

**Usage:**
- Each user gets isolated session automatically
- Images auto-delete after 24 hours
- Run cleanup.php via cron: `0 * * * * php cleanup.php`

**Security:**
- Session IDs regenerated on first access
- Upload directory protected by .htaccess
- User images isolated by session

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 (1M context) <noreply@anthropic.com>
2025-12-16 08:56:26 -05:00
DJP
bf5fa7fd48 Add all 40+ cinematography application presets
Complete integration of prompt studio with full preset library:

- Added 40+ application/lighting presets across all categories
- Studio & Portrait (2)
- Product & Macro (5)
- Outdoor & Natural (3)
- Action & Motion (1)
- Creative & Artistic (6)
- Auteur Styles (9)
- Professional Production (6)
- Editorial & Fashion (4)
- Documentary & Journalism (3)
- Architectural & Interior (2)

All lighting physics data now matches original React app.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 (1M context) <noreply@anthropic.com>
2025-12-16 08:44:06 -05:00
DJP
0271c2bb8f Add Cinematography Prompt Studio integration
- Created enhance_prompt.php API endpoint for AI prompt enhancement
- Integrated cinematography controls into main UI
- Added camera body, lens kit, and lighting application selections
- Implemented creative freedom slider for prompt customization
- Enhanced prompts now auto-fill into image generation form
- Seamless workflow: enhance prompt → generate image

Features:
- Real camera physics (Arri Alexa 35, Sony Venice 2, etc.)
- Professional lens characteristics (Cooke, Panavision, Canon K-35)
- Lighting presets (Golden Hour, Blue Hour, Neon Cyberpunk, etc.)
- Gemini AI integration for prompt optimization

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 (1M context) <noreply@anthropic.com>
2025-12-16 08:40:35 -05:00
DJP
4deed84ba0 Initial commit: Nano AI Image Generator
- Complete working image generation app using Imagen 3
- PHP backend with Gemini API integration
- Dark themed UI with prompt enhancement
- Session management and logging system

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 (1M context) <noreply@anthropic.com>
2025-12-16 08:35:02 -05:00