Changes:

This PR add toString()method in EndpointRequest.EndpointRequestMatcher as per the bug #33647. Added Test Cases for toString() method in EndpointRequestTest Thanks

Comment From: tvahrst

Hi, it's possible to create EndpointRequestMatcher by providing the corresponding endpoint class. For example:

    return http -> http
        .authorizeRequests()
        .requestMatchers(EndpointRequest.to(InfoEndpoint.class, HealthEndpoint.class)).permitAll()
        .requestMatchers(EndpointRequest.toAnyEndpoint()).hasRole("MANAGEMENT");

This would lead in a toString output printing the full qualified classnames. I would suggest: 1. map the content of include and exclude to EndpointIds: includes.stream().map(this::getEndpointId).collect(Collectors.toList())); // spring 6: toList() 2. an empty includes list means 'include all' (see EndpointReqeust.toAnyEndpoint()) . Maybe the toString method should print a wildcard like include=[*] when include is empty?

Comment From: devrishal

Hi, it's possible to create EndpointRequestMatcher by providing the corresponding endpoint class. For example:

return http -> http .authorizeRequests() .requestMatchers(EndpointRequest.to(InfoEndpoint.class, HealthEndpoint.class)).permitAll() .requestMatchers(EndpointRequest.toAnyEndpoint()).hasRole("MANAGEMENT");

This would lead in a toString output printing the full qualified classnames. I would suggest:

  1. map the content of include and exclude to EndpointIds: includes.stream().map(this::getEndpointId).collect(Collectors.toList())); // spring 6: toList()
  2. an empty includes list means 'include all' (see EndpointReqeust.toAnyEndpoint()) . Maybe the toString method should print a wildcard like include=[*] when include is empty?

Thanks for your suggestions. Added the checks and handled the empty case as well in the latest push. The code snippet for changes is below

if (this.includes.isEmpty()) {
                sb.append("EndpointRequest [includes='[").append("*").append("]'");
            }
            else {
                sb.append("EndpointRequest [includes='")
                        .append(this.includes.stream().map(this::getEndpointId).collect(Collectors.toList()))
                        .append("'");
            }
            sb.append(", Excludes='")
                    .append(this.excludes.stream().map(this::getEndpointId).collect(Collectors.toList())).append("'");

Comment From: wilkinsona

Thanks for the PR but we already have #33654 for this.

Comment From: devrishal

@wilkinsona I am trying to contribute for the first time. Hence, it might sound stupid to you, but could you please compare the PR. As the changes are different and cases are handled including test cases. Anyways Cheers!! will try to contribute in some other ways :)

Comment From: wilkinsona

@devrishal Thank you for your interest in contributing. We don't want implementing something to become a competition to see who can provide the "best" PR. Instead, we prefer to work with the first contributor that shows an interest so that we can iterate and take our time without the contributor worrying that someone else will jump in.

Comment From: devrishal

@devrishal Thank you for your interest in contributing. We don't want implementing something to become a competition to see who can provide the "best" PR. Instead, we prefer to work with the first contributor that shows an interest so that we can iterate and take our time without the contributor worrying that someone else will jump in.

Agreed, that will give the contributor good scope of improvement. Thanks for providing the info. Cheers