Skip to content

Better logging support by id in RequestMatcher #6308

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

Closed
wants to merge 1 commit into from

Conversation

ankurpathak
Copy link
Contributor

  1. Added default method getId in RequestMatcher and
    marked it as FunctionalInterface
  2. Created Class AbstractRequestMatcher with default
    support for getId logging things
  3. Implemented build in matchers using AbstractRequestMatcher
  4. Changed toString methods of build in matchers to reflect
    id.

Fixes: gh-6274

1. Added default method getId in RequestMatcher and
marked it as FunctionalInterface
2. Created Class AbstractRequestMatcher with default
support for getId logging things
3. Implemented build in matchers using AbstractRequestMatcher
4. Changed toString methods of build in matchers to reflect
id.
5. Modified Regex and El RequestMatcher toString tests to
reflect new toString.

Fixes: spring-projectsgh-6274
@rwinch rwinch mentioned this pull request Dec 19, 2018
7 tasks
@rwinch
Copy link
Member

rwinch commented Dec 19, 2018

Thanks for the PR @ankurpathak!

After some more thought I think we need to take a more holistic approach to logging improvements. I created gh-6311 for us to improve logging within Spring Security as a whole. We will keep this ticket open and potentially merge these changes depending on the findings of that ticket

Copy link

@dkapil dkapil left a comment

Choose a reason for hiding this comment

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

some basic review, there are many instances where new changes have been introduced to change in formatter.
Here is the guidelines on managing whitespace/formatting issues https://github.com/spring-projects/spring-security/blob/master/CONTRIBUTING.md#mind-the-whitespace

@@ -89,11 +90,11 @@ public boolean matches(HttpServletRequest request) {
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("ExactUrl [processUrl='").append(processUrl).append("']");
sb.append("ExactUrl [processUrl='").append(processUrl).append("', id=").append(getId()).append("]");
Copy link

Choose a reason for hiding this comment

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

I think we can live away with String builder now, by-default string concatenations internally invoke string builder only. Plus it will result in cleaner code

}
Copy link

Choose a reason for hiding this comment

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

let's use the existing formatter so this does not occur

/**
* Standard implementation of {@code SecurityFilterChain}.
*
* @author Luke Taylor
*
* @since 3.1
*/
public final class DefaultSecurityFilterChain implements SecurityFilterChain {
public final class DefaultSecurityFilterChain implements SecurityFilterChain{
Copy link

Choose a reason for hiding this comment

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

let's use the existing formatter so this does not occur

@@ -61,4 +63,5 @@ public boolean matches(HttpServletRequest request) {
public String toString() {
return "[ " + requestMatcher + ", " + filters + "]";
}

Copy link

Choose a reason for hiding this comment

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

let's use the existing formatter so this does not occur

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What do you mean by existing formatter??

Copy link

@dkapil dkapil Mar 27, 2019

Choose a reason for hiding this comment

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

I meant, these whitespaces means that the code formatter we have used for this PR does not match the one used originally. Formatter can also mean any settings in your IDE that indents/formats/structures code. Please see the section on whitespaces in contributing guidelines. Hope this helps

@@ -76,6 +75,6 @@ public boolean matches(HttpServletRequest request) {

@Override
public String toString() {
return "AndRequestMatcher [requestMatchers=" + requestMatchers + "]";
return "AndRequestMatcher [requestMatchers=" + requestMatchers + ", id=" + getId()+"]";
Copy link

Choose a reason for hiding this comment

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

is code formatted correctly?

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label May 7, 2019
@eleftherias eleftherias added in: web An issue in web modules (web, webmvc) status: blocked An issue that's blocked on an external project change type: enhancement A general enhancement and removed status: waiting-for-triage An issue we've not yet triaged labels Nov 5, 2019
@jgrandja
Copy link
Contributor

@ankurpathak I'm going to close this PR as it's quite old and would need to be rebased off main. As well, there are a few logging improvement commits you'll notice linked in gh-6311.

If you feel the updates provided in this PR are still required, please submit a new PR rebased off main and align with the logging improvements already merged and referenced in gh-6311.

@jgrandja jgrandja closed this Nov 18, 2021
@jgrandja jgrandja added status: declined A suggestion or change that we don't feel we should currently apply and removed status: blocked An issue that's blocked on an external project change labels Nov 18, 2021
@jgrandja jgrandja self-assigned this Nov 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: web An issue in web modules (web, webmvc) status: declined A suggestion or change that we don't feel we should currently apply type: enhancement A general enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Give SecurityFilterChain a name for tracing!
6 participants