Skip to content

Commit

Permalink
Ensure filter order.
Browse files Browse the repository at this point in the history
  • Loading branch information
maciejwalkowiak committed Jul 14, 2021
1 parent 4d30a62 commit c71230f
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,13 @@ static class HubConfiguration {
@Open
static class SentryWebMvcConfiguration {

private static int SENTRY_SPRING_FILTER_PRECEDENCE = Ordered.HIGHEST_PRECEDENCE;

@Configuration(proxyBeanMethods = false)
@ConditionalOnClass(SecurityContextHolder.class)
@Open
static class SentrySecurityConfiguration {

/**
* Configures {@link SpringSecuritySentryUserProvider} only if Spring Security is on the
* classpath. Its order is set to be higher than {@link
Expand Down Expand Up @@ -184,7 +187,7 @@ static class SentrySecurityConfiguration {
final @NotNull IHub hub, final @NotNull SentryRequestResolver requestResolver) {
FilterRegistrationBean<SentrySpringFilter> filter =
new FilterRegistrationBean<>(new SentrySpringFilter(hub, requestResolver));
filter.setOrder(Ordered.HIGHEST_PRECEDENCE);
filter.setOrder(SENTRY_SPRING_FILTER_PRECEDENCE);
return filter;
}

Expand All @@ -195,7 +198,7 @@ public FilterRegistrationBean<SentryTracingFilter> sentryTracingFilter(
final @NotNull IHub hub) {
FilterRegistrationBean<SentryTracingFilter> filter =
new FilterRegistrationBean<>(new SentryTracingFilter(hub));
filter.setOrder(Ordered.HIGHEST_PRECEDENCE + 1); // must run after SentrySpringFilter
filter.setOrder(SENTRY_SPRING_FILTER_PRECEDENCE + 1); // must run after SentrySpringFilter
return filter;
}

Expand Down

0 comments on commit c71230f

Please sign in to comment.