Skip to content

Commit

Permalink
Reintrodusert (custom) log filter, POST only.
Browse files Browse the repository at this point in the history
  • Loading branch information
rfc3092 committed Feb 23, 2024
1 parent 3201a6f commit f5e3a20
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 4 deletions.
5 changes: 1 addition & 4 deletions apps/inntektsmelding-service/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,7 @@ dependencies {
implementation 'no.nav.testnav.libs:servlet-security'

implementation 'org.springframework.cloud:spring-cloud-vault-config-databases'
implementation('org.springframework.boot:spring-boot-starter-web') {
exclude group: 'org.springframework.boot', module: 'org.springframework.boot'
}
implementation 'org.springframework.boot:spring-boot-starter-undertow'
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.boot:spring-boot-starter-oauth2-client'
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-webflux'
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package no.nav.registre.testnav.inntektsmeldingservice.config;

import jakarta.servlet.http.HttpServletRequest;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.web.FilterChainProxy;
import org.springframework.web.filter.CommonsRequestLoggingFilter;

@Configuration
@Slf4j
class RequestLoggingFilterConfig {

@Bean
PostOnlyRequestLoggingFilter logFilter(FilterChainProxy filterChainProxy) {

log.info("Filter chain: {}", filterChainProxy.getFilterChains());

var filter = new PostOnlyRequestLoggingFilter();
filter.setIncludeClientInfo(true);
filter.setIncludeHeaders(true);
filter.setIncludePayload(true);
filter.setIncludeQueryString(true);
filter.setMaxPayloadLength(10000);
filter.setAfterMessagePrefix("REQUEST: ");
return filter;
}

private static class PostOnlyRequestLoggingFilter extends CommonsRequestLoggingFilter {

@Override
protected boolean shouldLog(HttpServletRequest request) {
return "POST".equalsIgnoreCase(request.getMethod());
}

}

}

0 comments on commit f5e3a20

Please sign in to comment.