Introduce FastAPI - #2745
Conversation
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
|
Build failed. ✔️ pre-commit SUCCESS in 1m 50s |
Venefilyn
left a comment
There was a problem hiding this comment.
Looks like a good start! I think going with /v1 etc. instead of /api/v1 is fine. Would API documentation go to /v1/docs or /docs?
| # Swagger and ReDoc don't work without these | ||
| "style-src 'self' 'unsafe-inline' https://cdn.jsdelivr.net; " | ||
| "script-src 'self' 'unsafe-inline' https://cdn.jsdelivr.net; " |
There was a problem hiding this comment.
Something we should track in a separate issue. If auth ever becomes something Packit implements this might then be a security threat - especially with JS scripts
Currently it goes under |
Ah okay. Yeah I'd say put it under the specific api version due to using versioning |
|
Build failed. ✔️ pre-commit SUCCESS in 1m 53s |
Introduce FastAPI running with Uvicorn (+Gunicorn in prod/stg), keep old Flask endpoints under /api hardcoded as WSGI. New endpoints will come under /v1, Swagger is at /docs and Redoc under /redoc.
We no longer run httpd.
majamassarini
left a comment
There was a problem hiding this comment.
I think we should land this on stg soon, because now our stg service instance is down.
Thanks!
|
recheck |
|
Build succeeded. ✔️ pre-commit SUCCESS in 1m 56s |
|
I fixed the staging in #2750 so I would wait with merging this until Monday afternoon (prod deployment), so that this can be observed a bit more in staging. |
|
Unfortunately, with the recent capacity reduction of our team, we needed to deprioritise few of the epics so that we are able to deliver the high-prio ones (see board). I won't merge this until we have the necessary capacity to continue with the epic, as changing the framework may introduce additional work. |
|
/fs-review |
|
🤖 Finished Review · ✅ Success · Started 10:01 AM UTC · Completed 10:20 AM UTC |
ReviewFindingsHigh
Medium
Low
Next steps:
|
There was a problem hiding this comment.
See the review comment for full details.
Note: The following inline comments could not be posted on the diff (GitHub returned 422) and are included here instead:
packit_service/service/app.py:128: [high] CORS-misconfiguration
The FastAPI CORS middleware combines allow_origins=[''] with allow_credentials=True. Starlette's CORSMiddleware reflects the request's Origin header verbatim in this configuration, allowing any origin to make credentialed cross-origin requests. The previous Flask-CORS setup (CORS(app)) defaults to allow_origins='' without credentials, making this a security regression.
Suggested fix: Either remove allow_credentials=True if credentials are not needed, or replace allow_origins=['*'] with a specific allowlist of trusted origins.
packit_service/service/app.py:153: [medium] logic-error
The HTTPS redirect middleware hardcodes port=443, but the service listens on port 8443 (in run_server.sh and docker-compose.yml). If the redirect fires (e.g., behind a TLS-terminating proxy), it sends clients to the wrong port.
Suggested fix: Remove the HTTPS redirect (the server already listens on HTTPS), or omit the port=443 override to preserve the existing port: url = request.url.replace(scheme='https').
packit_service/service/app.py:85: [low] edge-case
Flask SERVER_NAME config is commented out with a TODO. Without it, Flask derives hostnames from request headers, which may produce incorrect absolute URLs behind a reverse proxy. The TODO acknowledges local deployment issues.
CONTRIBUTING.md(file-level): Line 73 · [low] stale-reference
Example curl output still shows Server: Apache/... mod_wsgi/... headers, which are no longer accurate since the server now runs Uvicorn/Gunicorn.
Merge after #2749 (needed for tests to pass)
Fixes #2715
To discuss:
TODO:
security_and_https_middlewaremoreRELEASE NOTES BEGIN
N/A
RELEASE NOTES END