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

feat(jans-auth-server): log httpresponse body configurated by httpLoggingResponseBodyContent #349 #4417

Merged

Conversation

jmunozherbas
Copy link
Contributor

@jmunozherbas jmunozherbas commented Mar 31, 2023

Prepare


Description

A new AppConfiguration param for logging response body.

Target issue

#349

closes #349

Implementation Details

The response body is logged if param "httpLoggingResponseBodyContent" is true in jans-auth AppConfiguration.
(ConfDynamic)
If param not exist or is false, then response body is not logged.


Test and Document the changes

  • Static code analysis has been run locally and issues have been fixed
  • Relevant unit and integration tests have been added/updated
  • Relevant documentation has been updated if any (i.e. user guides, installation and configuration guides, technical design docs etc)

Closes #4418,

@mo-auto
Copy link
Member

mo-auto commented Mar 31, 2023

Error: Hi @jmunozherbas, You did not reference an open issue in your PR. I attempted to create an issue for you.
Please update that issues' title and body and make sure I correctly referenced it in the above PRs body.

@mo-auto mo-auto added area-documentation Documentation needs to change as part of issue or PR comp-jans-auth-server Component affected by issue or PR kind-feature Issue or PR is a new feature request labels Mar 31, 2023
@jmunozherbas jmunozherbas changed the title feat(jans-auth-server): log httpresponse body configurated by httpLoggingResponseBodyContent feat(jans-auth-server): log httpresponse body configurated by httpLoggingResponseBodyContent #349 Mar 31, 2023
Copy link
Contributor

@yuriyz yuriyz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See inline comment

if (appConfiguration.getHttpLoggingResponseBodyContent()) {
httpResponse.setStatus(((ReadableResponseWrapper) responseWrapper).getStatus());
httpResponse.setHeaders(((ReadableResponseWrapper) responseWrapper).getHeaders());
httpResponse.setBody(((ReadableResponseWrapper) responseWrapper).readBodyValue());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jmunozherbas would you please extensively test this change and confirm it works good ? Because this line sounds like we read from writer and close it. So down the chain filters will not be able to process it. As result it can cause not returing response out of the server. It's similar problem as reading input stream in request which can make it unavailable further.

See this https://stackoverflow.com/questions/10210645/http-servlet-request-lose-params-from-post-body-after-read-it-once

Copy link
Contributor Author

@jmunozherbas jmunozherbas May 5, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have applied some changes.
I have tested with jans-auth-client heap of tests, and results are similar than before the change.
Clarification.- The changes and new flows just be applied if the parameter "httpLoggingResponseBodyContent" is enabled, if this parameter doesn´t exist or is false, then the flow is executed as usual.

The code to read body from response is based on next example:

search "Logging requests and responses" in next page:
https://spaces.at.internet2.edu/display/Grouper/Grouper+Web+Services

code repository:
https://github.com/Internet2/grouper/tree/master/grouper-ws/grouper-ws/src/grouper-ws/edu/internet2/middleware/grouper/ws/j2ee

maven repository of this code library:
https://mvnrepository.com/artifact/edu.internet2.middleware.grouper/grouper-ws/5.0.3

There is an example to read request body too, maybe could be implemented.
The log printting in just one line (request and response) could be implemented too, similar to the example code.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If all tests are passed with httpLoggingResponseBodyContent=true then I guess we are good to merge.

@sonarcloud
Copy link

sonarcloud bot commented Apr 26, 2023

[Jans authentication server parent] SonarCloud Quality Gate failed.    Quality Gate failed

Bug D 1 Bug
Vulnerability A 0 Vulnerabilities
Security Hotspot E 1 Security Hotspot
Code Smell A 7 Code Smells

0.0% 0.0% Coverage
0.0% 0.0% Duplication

@yuriyz
Copy link
Contributor

yuriyz commented May 5, 2023

Lets correct sonar reports before merge.

@sonarcloud
Copy link

sonarcloud bot commented May 7, 2023

[jans-cli] Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

@sonarcloud
Copy link

sonarcloud bot commented May 7, 2023

[jans-linux-setup] Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

@sonarcloud
Copy link

sonarcloud bot commented May 7, 2023

[agama parent] Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

@sonarcloud
Copy link

sonarcloud bot commented May 7, 2023

[jans-core] Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

@sonarcloud
Copy link

sonarcloud bot commented May 7, 2023

[jans-pycloudlib] Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

@sonarcloud
Copy link

sonarcloud bot commented May 7, 2023

[notify] Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

@sonarcloud
Copy link

sonarcloud bot commented May 7, 2023

[jans-config-api-parent] Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

@sonarcloud
Copy link

sonarcloud bot commented May 7, 2023

[SCIM API] Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

@yuriyz yuriyz merged commit 08d92b3 into main May 8, 2023
@yuriyz yuriyz deleted the feat-jans-auth-server-log-httpresponse-body-configurated branch May 8, 2023 09:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-documentation Documentation needs to change as part of issue or PR comp-jans-auth-server Component affected by issue or PR kind-feature Issue or PR is a new feature request
Projects
None yet
3 participants