gaoxingliang opened a new issue, #274:
URL: https://github.com/apache/apisix-java-plugin-runner/issues/274

   ### Issue description
   I have a env :
   wolf --> ext-plugin-post-req (decrypt the request)-> my upstream (python) 
--->  ext-plugin-post-resp (encrypt the response)
   
   but when I check the content in my upstream, the body is still encrypted.
   ```
   my post-req filter:
   logger.info("input headers:{}, raw input:{}", request.getHeaders(), 
request.getBody());
           User user = 
userService.tryFindUser(request.getHeader(Constants.HEADER_USER_ID));
           if (user == null) {
               response.setStatusCode(403);
               response.setBody(ERROR_NOT_FOUND);
               logger.warn("未找到用户:{}", request.getHeaders());
           } else {
               try {
                   String decryptedBody = 
userService.decryptBody(request.getBody(), user);
                   request.setBody(decryptedBody);
                   request.setHeader(HEADER_REQUESTBODY_ENCRYPTED_FLAG, "true");
                   logger.info("DecryptRequestFilter:request:{}, user:{},{}", 
request.getRequestId(), user.getUserid(), decryptedBody);
               } catch (Exception e) {
                   logger.error("decrypt request failure", e);
                   response.setStatusCode(400);
                   response.setBody(ERROR_DECRYPT_REQUEST_FAILURE);
               }
           }
   
   ```
   and related log(you can see the request body is decrypted successfully.)
   
![image](https://github.com/apache/apisix-java-plugin-runner/assets/3148215/0650652a-3e62-4e49-ab52-667ef6efdae5)
   
   but the log in my python code(it says it's still encrypted )
   
![image](https://github.com/apache/apisix-java-plugin-runner/assets/3148215/d6a9652c-de43-4c54-913b-6835c037ad87)
   
   ```
   my post-resp filter:
   String userId = request.getUpstreamHeaders().get(Constants.HEADER_USER_ID);
           logger.info("Current user id : {}, {}, body from upstream:{}", 
userId, request.getUpstreamHeaders(), request.getBody());
           User user = userService.tryFindUser(userId);
           if (user == null) {
               response.setStatusCode(403);
               response.setBody(Constants.ERROR_NOT_FOUND);
               logger.warn("not found the user, maybe disabled. wolfuserid: 
{}", userId);
           } else {
               String encryptedBody = 
userService.encryptBody(request.getBody(), user);
               response.setBody(encryptedBody);
               response.setHeader(Constants.HEADER_RESPONSEBODY_ENCRYPTED_FLAG, 
"true");
               response.setStatusCode(request.getUpstreamStatusCode());
               logger.info("EncryptResponseFilter success:user(wolf):{},{}", 
user.getUserid(), encryptedBody);
           }
   ```
   
   
   ### Environment
   
   runner:0.0.4
   
   ### Minimal test code / Steps to reproduce the issue
   
   
   ### What's the actual result? (including assertion message & call stack if 
applicable)
   
   ### What's the expected result?
   the post-req filter should change the body sent to upstream.


-- 
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]

Reply via email to