refactor(lightspeed): create permission middleware and update proxy passthrough#3316
Conversation
Changed Packages
|
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #3316 +/- ##
==========================================
- Coverage 54.01% 54.01% -0.01%
==========================================
Files 2403 2403
Lines 87411 87389 -22
Branches 24182 24159 -23
==========================================
- Hits 47219 47202 -17
+ Misses 38709 38704 -5
Partials 1483 1483
*This pull request uses carry forward flags. Click here to find out more. Continue to review full report in Codecov by Harness.
🚀 New features to boost your workflow:
|
96ee094 to
98c7266
Compare
|
/hold going to wait for #3296 |
98c7266 to
d00c4cd
Compare
|
/unhold |
Code Review by Qodo
1. History length never injected
|
…assthrough handling Signed-off-by: Jordan Dubrick <jdubrick@redhat.com>
Signed-off-by: Jordan Dubrick <jdubrick@redhat.com>
Signed-off-by: Jordan Dubrick <jdubrick@redhat.com>
Signed-off-by: Jordan Dubrick <jdubrick@redhat.com>
c1ee110 to
41dfeae
Compare
|
|
Will deal with the |
yangcao77
left a comment
There was a problem hiding this comment.
changes look good to me



PR Summary by Qodo
lightspeed: add permission middleware and replace proxy catch-all routes
✨ Enhancement🧪 Tests🕐 40+ MinutesWalkthroughs
User Description
Hey, I just made a Pull Request!
What was done
await authorizer.authorizeUser(...)with try/catch blocks duplicated across every route handler. Now a standalone Express middleware factoryutils.tsuser_idandhistory_lengthquery-param injection that was inline in the catch-all's pathRewrite callback is now the standalone rewriteLightspeedProxyPath function, independently testableSKIP_USER_ID_ENDPOINTSandDEFAULT_HISTORY_LENGTHtoconstant.tsrouter.tsandtypes.ts, now are with the other constantsWhy it was done
✔️ Checklist
AI Description
Diagram
graph TD R["Lightspeed router"] --> PM["Permission middleware"] --> PS["Backstage permissions"] R --> PX["HTTP proxy"] --> LCS{{"Lightspeed Core"}} PX --> U["Path rewrite util"] T["Unit tests"] --> R --> PX T --> PM T --> U subgraph Legend direction LR _r["Router/module"] ~~~ _m["Middleware"] ~~~ _e{{"External service"}} ~~~ _t["Tests"] endHigh-Level Assessment
The following are alternative approaches to this PR:
1. Keep catch-all proxy + stricter allowlist matcher
2. Declarative route table (config-driven) that generates routes
Recommendation: The PR’s approach (explicit route definitions + shared permission middleware) is the most secure and reviewable option because it makes the exposed surface area and required permissions auditable in code. A declarative route table could be considered later if endpoint count grows, but the current explicit implementation is a good trade-off for clarity and security.
File Changes
Enhancement (2)
Refactor (4)
Tests (3)
Other (1)