Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AuditHandler cannot logged request, response, query parameters if response is sent by a framework middleware handler #840

Closed
jiachen1120 opened this issue Nov 24, 2020 · 5 comments
Assignees
Labels
enhancement Issue: Enhancement

Comments

@jiachen1120
Copy link
Contributor

The current design of the audit handler is that users implement their own way to audit their requests and response in their own handler.

However, it seems if the response is sent by framework middleware handler, people may be hard to auditing the request and response. For example, if openapi validation error happen, status will be sent back but this response won't be auditted.

Probably we can provide a option to users to audit these kind of request and response.

There are two situation:

  1. Framework help users auditting every request and response, regardless of success or fail
  • User can enable dump handler at this time. We can retrieve dumpped request and response from dumpped exchange attachment and add them into auditMap
  1. Framework help users auditting failed request and response, and the response is sent by a framework middleware handler
  • User set the auditOnError to true, then the response at this moment is the error status, which already exists in the auditInfo, we can directly add it to the auditMap
@jiachen1120 jiachen1120 added the enhancement Issue: Enhancement label Nov 24, 2020
@stevehu
Copy link
Contributor

stevehu commented Nov 24, 2020

@jiachen1120 I would prefer the second option and still position the dump handler as a debugging tool for the dev environment as it is too heavy. @miklish What do you think?

@jiachen1120
Copy link
Contributor Author

@stevehu Yeah. Acctually the second situation already can fulfill our customer's requirements. Just wondering will it be useful if we also added dumpped request and response into auditMap in dev environment when people enable dumpped handler for debugging?

I personally think option2 should be enough. @miklish Looking forward to your opinion.

@miklish
Copy link
Collaborator

miklish commented Nov 25, 2020

I prefer option 2 as well @stevehu @jiachen1120

jiachen1120 added a commit that referenced this issue Dec 3, 2020
- audit request if bodyHandler enabled
- audit query parameters if request contains it
- audit response on error
stevehu pushed a commit that referenced this issue Dec 9, 2020
* - solved #840
- audit request if bodyHandler enabled
- audit query parameters if request contains it
- audit response on error

* - auditing all request components
- auditing serviceId

* - added more test cases
stevehu pushed a commit that referenced this issue Dec 9, 2020
* - solved #840
- audit request if bodyHandler enabled
- audit query parameters if request contains it
- audit response on error

* - auditing all request components
- auditing serviceId

* - added more test cases
@stevehu stevehu closed this as completed Dec 15, 2020
younggwon1 pushed a commit to younggwon1/light-4j that referenced this issue Feb 10, 2024
* - solved networknt#840
- audit request if bodyHandler enabled
- audit query parameters if request contains it
- audit response on error

* - auditing all request components
- auditing serviceId

* - added more test cases
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Issue: Enhancement
Projects
None yet
Development

No branches or pull requests

3 participants