Public CORS decorator (PP-5045) - #3680
Conversation
|
Claude finished @tdilauro's task in 6m 36s —— View job SummaryThe decorator itself is sound: DetailsMinor:
|
Greptile SummaryThe PR introduces a decorator for wildcard CORS on unauthenticated public routes, including preflight handling and an application hook that preserves CORS headers on error and short-circuit responses.
Confidence Score: 5/5The PR appears safe to merge because no blocking failure remains. No blocking failure remains.
|
| Filename | Overview |
|---|---|
| src/palace/manager/api/routes.py | Adds public wildcard-CORS decoration, incompatible-decorator checks, preflight configuration, and error-response header backfilling. |
| tests/manager/api/test_routes.py | Adds broad functional coverage for public CORS behavior, including preflight and response paths that bypass the decorated view. |
Sequence Diagram
sequenceDiagram
participant Browser
participant Flask
participant Route
participant ErrorHandler
Browser->>Flask: Cross-origin request
Flask->>Route: Dispatch decorated public route
alt View returns normally
Route-->>Flask: Response with wildcard CORS header
else View raises or outer decorator short-circuits
Route-->>ErrorHandler: Error or alternate response
ErrorHandler-->>Flask: Response without CORS header
Flask->>Flask: after_request checks endpoint marker
Flask->>Flask: Add wildcard CORS header
end
Flask-->>Browser: Readable cross-origin response
Reviews (3): Last reviewed commit: "CI AI code review feedback" | Re-trigger Greptile
| assert False == routes.app.url_map.merge_slashes | ||
|
|
||
|
|
||
| class TestAllowsPublicCors: |
There was a problem hiding this comment.
TestAllowsPublicCors organizes these tests around one behavior rather than the module under test, contrary to the repository's module-oriented test-class convention and making related route tests less consistent to locate.
Context Used: CLAUDE.md (source)
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3680 +/- ##
=======================================
Coverage 93.55% 93.55%
=======================================
Files 513 513
Lines 46907 46927 +20
Branches 6405 6409 +4
=======================================
+ Hits 43884 43904 +20
Misses 1954 1954
Partials 1069 1069 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
More Claude / greptile beef. And I'm here for it! 😂
|
Description
Adds an
allows_public_corsroute decorator that sends open CORS headers and handles preflight requests. The decorator comment documents that it must not be stacked withallows_patron_weband must only go on GET/HEAD routes.Access-Control-Allow-Origin: *,GET,HEAD, andOPTIONSmethods.An
after_requesthook back-fills the wildcard header on responses the decorator never sees, such as a raising view converted by the app-level error handler, or an outer decorator returning a problem detail. Without it, cross-origin clients would get an opaque CORS failure instead of a readable error body.No routes use it yet.
Motivation and Context
Public catalog data is readable by anyone without credentials, so an origin allowlist adds no protection there. What it does do is break browser-based catalog clients (like CPW) when their hosts are not configured, which creates friction for dev instances and new deployments. This decorator is the first step. A follow-up PR will apply it to the public routes.
[Jira PP-5045]
How Has This Been Tested?
Checklist