Commit graph

17 commits

Author SHA1 Message Date
Vadym Samoilenko
0976ee9421 fix: Azure AD SSO authentication (AADSTS900144 client_id error)
Changes:
- Use tenant-specific authority instead of 'organizations' endpoint
- Pass code parameter explicitly in acquire_token_by_authorization_code
- Fix REDIRECT_URI to include /auth/callback path
- Add ALLOWED_TENANT_IDS support for multi-tenant auth
- Improve error logging for token acquisition

Co-Authored-By: Claude Sonnet 4.5 (1M context) <noreply@anthropic.com>
2026-02-25 11:48:07 +00:00
SamoilenkoVadym
1156209232 fix: prevent filename collisions that break Excel metadata lookup
- Remove collision-avoidance rename (_1, _2, etc) in FileService.save_upload;
  overwrite file on disk instead, preserving original filename
- Deduplicate in SessionStore.add_file_to_session: replace existing entry
  with same filename instead of appending duplicate
- Deduplicate upload results list for consistent frontend response

The rename broke Excel/import metadata lookup which matches by
Path(filename).stem.lower(). Files are already isolated per user_id
directory, so overwriting is safe.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-12 10:22:25 +00:00
SamoilenkoVadym
d4b71ff34e Switch AI to GPT-5.2 with Responses API (v1/responses)
- Default model: gpt-5.2
- New models use client.responses.create() (Responses API)
- Older models (gpt-3.5-turbo) still use chat.completions.create()
- Response parsing handles both API formats
- Updated valid models list

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-02-09 22:13:55 +00:00
SamoilenkoVadym
ebc2322d61 Background AI with polling for bulk uploads (up to 100 files)
- Upload returns immediately for AI source, processes in background
- New GET /session/{id}/files endpoint for polling AI progress
- Frontend polls every 3s, updates UI as files complete
- Shows progress: "X of Y files done..."

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-02-09 22:09:06 +00:00
SamoilenkoVadym
3fe4ed0b4a Fix AI upload: process inline instead of background
Background AI processing returned before results were ready,
leaving the UI showing "AI processing..." forever. Now AI
metadata generation runs inline (awaited) so results are
returned immediately in the upload response.

Background SSE-based processing can be re-enabled later for
large batch uploads (10+ files).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-02-09 22:07:34 +00:00
SamoilenkoVadym
b3bb2831a0 Fix update-manual 500: fallback to filename if title is empty
base_updater.validate_metadata() requires non-empty title.
Now uses filename stem as fallback when user leaves title blank.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-02-09 22:05:06 +00:00
SamoilenkoVadym
f5cb1170bb Fix superadmin matching: case-insensitive username/email lookup
Azure AD returns mixed-case usernames (VadymSamoilenko) but
superadmin was created with lowercase. Use LOWER() for matching.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-02-09 21:57:49 +00:00
SamoilenkoVadym
c59db0e9fd Serve static files via Apache, not Docker
- deploy.sh copies static/ to /var/www/html/solventum-image-metadata/
- Apache Alias serves CSS/JS directly from disk
- ProxyPass exclusion prevents static requests going to Docker
- Updated apache config with full working example

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-02-09 21:50:02 +00:00
SamoilenkoVadym
60e403494e Switch MSAL.js CDN from msauth.net to jsdelivr
Microsoft CDN URL was unreachable. Using jsdelivr with
@azure/msal-browser@3.27.0 instead.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-02-09 21:47:20 +00:00
SamoilenkoVadym
154658f5d7 Fix MSAL redirectUri to match Azure AD registration
redirectUri = https://ai-sandbox.oliver.solutions/solventum-image-metadata/
(app root, not /login or /auth/callback)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-02-09 21:46:11 +00:00
SamoilenkoVadym
eaa12be728 Fix MSAL.js load order: use onload callback
Define initMsal() first, then load CDN script with onload="initMsal()".
Prevents 'msal is not defined' race condition.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-02-09 21:45:29 +00:00
SamoilenkoVadym
ff3b89f18c Fix MSAL.js: async initialize() before use
MSAL.js 2.x requires await initialize() before loginPopup().
Also added openid/profile/email scopes and loading state guard.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-02-09 21:43:58 +00:00
SamoilenkoVadym
f8711c1ace Switch SSO to client-side MSAL.js (no client secret needed)
- Frontend MSAL.js handles Azure AD popup login
- Backend validates access token via Graph API
- Removed server-side MSAL redirect flow (get_auth_url, acquire_token)
- MicrosoftSSO class simplified: only needs Graph API validation
- No AZURE_CLIENT_SECRET required

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-02-09 21:42:10 +00:00
SamoilenkoVadym
f635432f65 Make AZURE_CLIENT_SECRET optional for SSO
Support both ConfidentialClientApplication (with secret) and
PublicClientApplication (without secret). SSO now only requires
AZURE_CLIENT_ID and AZURE_TENANT_ID.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-02-09 21:39:15 +00:00
SamoilenkoVadym
b49096f42d Add itsdangerous dependency for Starlette session middleware
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-02-09 21:33:11 +00:00
SamoilenkoVadym
bcb2c49e43 Fix deploy.sh: auto-detect sudo for docker commands
git pull runs as current user (needs SSH key), docker commands
use sudo automatically if the user doesn't have docker socket access.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-02-09 21:29:20 +00:00
SamoilenkoVadym
3deaa5ef40 Initial commit: Oliver Metadata Tool (FastAPI)
Complete Flask → FastAPI migration with:
- FastAPI app with session auth, Azure AD SSO, rate limiting
- SQLite-backed session store (survives restarts)
- Bulk AI metadata generation with SSE progress
- Admin panel (user management, audit log, AI usage)
- Subpath deployment support (ROOT_PATH config)
- Docker + deploy.sh for production deployment
- Test suite (auth, upload, templates, imports, admin, sessions)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-02-09 21:23:42 +00:00