-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Actuator HTTP trace data not reported for OAuth endpoints #760
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
Comments
@mikesaurus the HttpTraceFilter default order is The solution is to create a HttpTrace bean and specify its order lower than spring security FilterChain order. @Configuration
public class WebConfig {
@Bean
HttpTraceFilter httpTraceFilter(HttpTraceRepository repository, HttpExchangeTracer tracer, SecurityProperties securityProperties) {
HttpTraceFilter httpTraceFilter = new HttpTraceFilter(repository, tracer);
httpTraceFilter.setOrder(securityProperties.getFilter().getOrder() - 1);
return httpTraceFilter;
}
} |
@pxzxj Thank you! Tested this solution out with the sample project and it works as you said. We'll look to incorporate this into our authorization server implementation. While this is a simple fix for an application to make, it feels like an application should expect to get this behavior by default. It doesn't seem right to have to customize base Spring filter configurations for what should be plain vanilla usage of Spring Auth Server and Spring Boot Actuator. I can understand why Spring's default ordering is configured the way it is, but the OAuth2 endpoint filters are functional endpoints and not layered application security. It feels like this solution should be incorporated into the Spring Auth Server lib to ensure that provided functional behavior can be traced appropriately with standard Spring tooling. |
let me make some additions. public class DefaultLogoutPageGeneratingFilter extends OncePerRequestFilter {
private RequestMatcher matcher = new AntPathRequestMatcher("/logout", "GET");
@Override
protected void doFilterInternal(HttpServletRequest request,
HttpServletResponse response, FilterChain filterChain)
throws ServletException, IOException {
if (this.matcher.matches(request)) {
renderLogout(request, response);
} else {
filterChain.doFilter(request, response);
}
}
private void renderLogout(HttpServletRequest request, HttpServletResponse response)
throws IOException {
String page = "<!DOCTYPE html>\n"
+ "<html lang=\"en\">\n"
// logout page content
+ "</html>";
response.setContentType("text/html;charset=UTF-8");
response.getWriter().write(page);
}
} The same goes for oauth2 filters used to process oauth2 requests. So subsequent filters will not be called after processing the oauth2 request. |
@pxzxj Thank you for providing the configuration that resolves this issue!
Since I added an item in gh-673 to track this issue. Closing this as a duplicate. |
hi, @jgrandja , as my comment above said,i don't think changing the filter order is the right solution for this problem. HttpTraceFilter is generally on ApplicationFilterChain but OAuth2Filter is on SecurityFilterChain. changing their order is not simple. |
Which |
Almost any Spring Security filter that writes content to the response. public final class OAuth2TokenEndpointFilter extends OncePerRequestFilter {
@Override
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain)
throws ServletException, IOException {
if (!this.tokenEndpointMatcher.matches(request)) {
filterChain.doFilter(request, response);
return;
}
// these code generate token and write it to response,but filterChain never been called to execute follow-up filters
}
} |
@pxzxj If the incoming request is an OAuth2 access token request then |
Any update on this with the newer versions of spring and /httptrace became deprecated? I have the same issue and would want to see information on /token and /authorize |
@saldanaj27 See comment. Also, logging was added in gh-159. You can enable |
Describe the bug
When implementing Spring Authorization Server and Spring Boot Actuator with the HTTP Trace endpoint enabled, Spring Boot Actuator does not report any trace data for requests to OAuth endpoints (
/authorize
,/token
, etc.). Non-OAuth requests, such as the requests to the Actuator endpoints are reported as expected.This was first discovered with our authorization server that implements a custom authorization consent page and integrates with Spring Boot Admin. Spring Boot Admin reports (via the authorization server Actuator endpoints) requests for Actuator endpoints and the custom authorization consent page (mapped in a custom controller). However, HTTP Trace data does not include the OAuth endpoint requests. This behavior was reproduced using the samples in the spring-authorization-server project.
To Reproduce
.gradle
fileimplementation "org.springframework.boot:spring-boot-starter-actuator"
application.yaml
filedefault-authorizationserver
,messages-resource
, andmessages-client
samples according to the READMEhttp://127.0.0.1:8080
and run through the sample workflowhttp://127.0.0.1:9000/actuator/httptrace
and view the HTTP Trace dataExpected behavior
Requests/responses for all OAuth endpoints are reported via the
/actuator/httptrace
endpoint.Sample
https://github.com/spring-projects/spring-authorization-server/tree/main/samples
The text was updated successfully, but these errors were encountered: