feat: implement ohttp gateway middleware#1306
feat: implement ohttp gateway middleware#1306Harshdev098 wants to merge 3 commits intopayjoin:masterfrom
Conversation
|
ThankS for working on this @Harshdev098. Ideally we would want this middleware to be written with axum so it would fit in with the rest of the middlwares we plan to add, @spacebear21 this is correct right ? |
Yes exactly. The gateway should be an axum middleware written mostly from scratch similar to @zealsham's ongoing work in #1296. Duplication could also be reduced by first making the helper utils ( |
|
okay will use axum in the middleware and update you! |
e454ea4 to
f8fcdfe
Compare
|
@spacebear21 Can you please review it, have updated the PR to use axum, also should I refactor the payjoin-directory becuase in the middleware I have done encapsulation and decapsulation, and the payjoin-directory is duplicating it which causes the failures of integration tests. |
|
@Harshdev098 I still see so many traces of hyper in the recent commit. can you take a look at #1101, should help with re-writting the ohttp middleware in axum. |
|
There are also many comments deleted with no explanation, which seems like unreviewed (and undisclosed) LLM work. |
156c799 to
45ac88d
Compare
45ac88d to
43b12a9
Compare
|
@zealsham @spacebear21 Have updated the code as you referenced and disclosed my claude usage too in the description! |
|
Haven’t taken good look since I’m away from keyboard , However you need the test cases passing, it’s the only way we can tell everything works well. I see your prior question about removing directory code because decapsulation is done twice. The answer to that is you have to do what you think we make the test cases pass. If you think doing something will complete the Pr, then do it. Reviewers are here to catch something totally off. Remember a complete Pr ready for review is the Pr with all green checks in CI cheers! |
Pull Request Test Coverage Report for Build 22011074362Details
💛 - Coveralls |
89d951a to
2a0def2
Compare
|
Hey @zealsham @spacebear21 Can you please review it! have removed the ohttp handling from the directory in order to pass the test and prevent double encapsulation and decapsulation |
2a0def2 to
a928973
Compare
The tests does not pass ? , can you see the CI result for your pull request ?. |
|
Actually I think I have removed/added some dependencies earlier in the commits and forgot to run update lock file script |
a928973 to
5957c0a
Compare
|
@zealsham the tests are passing now! |
zealsham
left a comment
There was a problem hiding this comment.
Cack!, jsut some review changes and an extra review eyes from one other person to get this in
| Ok(result) => result, | ||
| Err(e) => { | ||
| debug!("OHTTP decapsulation failed: {}", e); | ||
| return match e { |
There was a problem hiding this comment.
This should be an error!, rather than a debug
| debug!("Invalid URI in BHTTP: {}", e); | ||
| return (StatusCode::BAD_REQUEST, "Invalid URI").into_response(); |
| Err(e) => { | ||
| debug!("OHTTP encapsulation failed: {}", e); | ||
| return (StatusCode::INTERNAL_SERVER_ERROR, "Failed to encapsulate response") | ||
| .into_response(); |
There was a problem hiding this comment.
same as above , should be an error!
| let server = create_test_ohttp_server(); | ||
| let sentinel_tag = SentinelTag::new([0u8; 32]); | ||
|
|
||
| let config1 = OhttpGatewayConfig::new(server, sentinel_tag); |
There was a problem hiding this comment.
What is the value of this test , the test_config_creation test seems to cover this test. why are we testing that this is cloneable
There was a problem hiding this comment.
Also i don't think checking if the memory size is greater than 0 is a good way to validate config. it could be all junk data and still greater than 0
| ( | ||
| StatusCode::BAD_REQUEST, | ||
| [("content-type", "application/problem+json")], | ||
| OHTTP_KEY_REJECTION_JSON, | ||
| ) |
There was a problem hiding this comment.
| pub fn decapsulate_ohttp_request( | ||
| ohttp_body: &[u8], | ||
| ohttp_server: &ohttp::Server, | ||
| ) -> Result<(DecapsulatedRequest, ohttp::ServerResponse), GatewayError> { |
There was a problem hiding this comment.
Had my reservations about the error variant returned but then again the primary reason decapsulation fails most times its due to invalid keys , so maybe this can stay this way
5957c0a to
8901bec
Compare
|
@zealsham @spacebear21 Have updated the pr with required changes! |
part of #941
added ohttp gateway middleware in payjoin-services.
have used claude to fix errors in the development works
Pull Request Checklist
Please confirm the following before requesting review:
AI
in the body of this PR.