eschutho opened a new pull request, #43336:
URL: https://github.com/apache/superset/pull/43336

   ## SUMMARY
   
   The dashboard Excel export success email (#41133) links to a pre-signed S3 
URL that is only valid for as long as *both* its own `ExpiresIn` window and the 
credentials that signed it remain valid. Deployments whose S3 client 
authenticates via short-lived, auto-refreshed credentials (e.g. an EKS IRSA 
role assumed through `AssumeRoleWithWebIdentity`, which AWS caps at 12 hours) 
can silently invalidate the pre-signed URL long before 
`EXCEL_EXPORT_LINK_TTL_SECONDS` elapses, since the *credentials'* session — not 
just the URL's own `ExpiresIn` — bounds how long it actually works.
   
   To keep that promise regardless of credential lifetime, the email now links 
to a small Superset redirect endpoint (`GET 
.../export_xlsx/download/<job_id>/`) instead of a raw S3 URL. The link's own 
lifetime is enforced independently via the `key_value` store's `expires_on`, 
and the actual pre-signed URL is generated fresh — with then-current 
credentials — at click time, valid only long enough to complete a single 
download. The redirect intentionally requires no login, matching a raw 
pre-signed URL's own access model: the unguessable job id is the credential, 
and the dashboard access check already ran once when the export was requested.
   
   Reusing this same job_id-keyed store also removes a separate limitation: 
`export_xlsx` previously hard-required the requester to have an email address 
on file, since email was the only delivery channel — which excluded 
guest/embedded dashboard sessions (`GuestUser`) entirely. A new `GET 
.../export_xlsx/status/<job_id>/` polling endpoint lets the frontend discover 
completion without an email: the `DownloadMenuItems` component now polls after 
enqueueing and auto-downloads once ready, so an embedded/guest session (no 
email) gets a working export too. A regular logged-in session gets both the 
browser auto-download and, still, the email — the polling arrives before the 
email does in practice.
   
   `export_xlsx` needs a CSRF exemption for this to work end-to-end: it's a 
POST route now reachable from embedded/guest sessions whose fetch calls carry 
no CSRF token, the same reason `chart/data` is already in 
`WTF_CSRF_EXEMPT_LIST`.
   
   ## BEFORE/AFTER
   
   **Before:** the export email links directly to a pre-signed S3 URL that can 
silently stop working hours before its promised expiry on IRSA-style 
deployments, and `POST export_xlsx` 400s for any session without an email 
address (all embedded/guest dashboards).
   
   **After:** the export email (and, for guest sessions, browser polling) links 
to a Superset redirect that re-signs the S3 URL at click time; guest/embedded 
sessions can request and receive an export.
   
   ## TESTING INSTRUCTIONS
   
   - `pytest tests/integration_tests/dashboards/api_tests.py -k "download_xlsx 
or export_xlsx"` — 17 new/updated tests
   - `pytest tests/unit_tests/tasks/test_export_dashboard_excel.py` — 47 tests
   - `pytest tests/integration_tests/security_tests.py -k 
test_views_are_secured`
   - `npx jest 
src/dashboard/components/menu/DownloadMenuItems/DownloadMenuItems.test.tsx` — 
18 tests (3 new, covering ready/pending/error polling states)
   - `ruff check` / `ruff format --check` / `oxlint` / `prettier --check` all 
clean on touched files
   - `mypy` clean on touched files (pre-existing, unrelated repo-wide errors 
aside)
   
   ## ADDITIONAL INFORMATION
   
   - [ ] Has associated issue
   - [ ] Required feature flags
   - [x] Changes UI
   - [x] Includes DB migration - N/A, reuses the existing `key_value` table via 
a new `KeyValueResource.EXCEL_EXPORT_DOWNLOAD` enum member, no schema change
   - [ ] Confirm DB migration upgrade and downgrade tested
   - [ ] Introduces new feature or API
   - [ ] Removes existing feature or API


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to