logbook icon indicating copy to clipboard operation
logbook copied to clipboard

Help Needed. I can't seem to override the body replacers

Open Samicheaterb opened this issue 3 years ago • 1 comments

I have a custom sink, which allows me to persist everything to the database. The problem is when we get a request like this:

curl --location --request POST 'localhost:8083/fnc/navyfcu'
--header 'Cookie: JSESSIONID=8A529625489AE1E82A6305A559EEECFB'
--form 'XMLData="<PUSHORDER>

</PUSHORDER>"'

which is directed at spring controller:

@PostMapping("/fnc/navyfcu") public ResponseEntity<String> dorequest(@RequestParam(value = "XMLData") String payload) { logger.info("Handling request: {}", payload);

    return handleResponse(integrationService.handleRequest(IntegrationName.FNC, payload));
}

logbook filter: public LogbookFilterConfig(HttpTraceService httpTraceService) { this.httpTraceService = httpTraceService; }

public Logbook build(HttpTraceType type) {
    return Logbook.builder()
            .sink(
                    new Sink() {
                        @Override
                        public void write(Precorrelation precorrelation, HttpRequest request) {
                            logger.trace(request.getRequestUri());
                        }

                        @Override
                        public void write(Correlation correlation, HttpRequest request, HttpResponse response) {
                            try {
                                httpTraceService.handleNewTrace(request, response, type);
                            }
                            catch (Exception e) {
                                logger.error("failed in logbook trace", e);
                            }
                        }
                    }
            )
            .build();

}

which gets put in the WebSecurityConfigurerAdapter like so:

@Override
protected void configure(final HttpSecurity http) throws Exception {
    http
            .sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS)
            .and()
            .headers().frameOptions().disable()
            .and()
            .csrf().disable()
            .authorizeRequests()
            .antMatchers(HttpMethod.GET,"/*.js", "/libraries/**/*.js", "/*.css", "/libraries/**/*.css", "/*.ico", "/*.png").permitAll()
            .antMatchers(HttpMethod.GET, "/encompass/standalone/**", "/encompass/authenticate/**", "/encompass/ui", "encompass/error", "encompass/error/*", "/encompass/transaction/**/files/**").permitAll()
            .antMatchers(HttpMethod.GET,"/public/**").permitAll()
            .antMatchers(HttpMethod.POST,"/encompass/webhook/**").permitAll()
            .antMatchers(HttpMethod.POST, "/api/v1/push", "/realec", "/fnc/bok", "/test", "/fnc/navyfcu").permitAll()
            .anyRequest().fullyAuthenticated()
            .and().addFilterBefore(jwtTokenFilter(), UsernamePasswordAuthenticationFilter.class)
            .addFilterBefore(new LogbookFilter(logbookFilterConfig.build(HttpTraceType.INCOMING)), JwtTokenFilter.class);
}

every way via adding properties such as logbook.servlet.form-request = parameter and the form-request-mode i think it is. as well as doing "clearRequestFilters()" in the builder (i tried doing clear*all filters as well) I tried implementing my own filters. Seemingly no matter what, if I have the default it prints out "", but if i clear the filters it will just print out nothing. I was wondering if you have a way where i could get the xmlData request param printed?

Samicheaterb avatar Oct 30 '21 01:10 Samicheaterb

curl --location --request POST 'localhost:8083/fnc/navyfcu'
--header 'Cookie: JSESSIONID=8A529625489AE1E82A6305A559EEECFB'
--form 'XMLData="PUSHORDER></PUSHORDER"' heres the request again, looks like it may have been trunicated before, its actually xml, but i had to delete the outside tags for it to show up

Samicheaterb avatar Oct 30 '21 01:10 Samicheaterb

In order to prioritize the support for Logbook, we would like to check whether the old issues are still relevant. This issue has not been updated for over a year.

  • Please check if it is still relevant in latest version of the Logbook.
  • If so, please add a descriptive comment to keep the issue open.
  • Otherwise, the issue will automatically be closed after a week.

github-actions[bot] avatar Jul 14 '23 15:07 github-actions[bot]

This issue has automatically been closed due to no activities. If the issue still exists in the latest version of the Logbook, please feel free to re-open it.

github-actions[bot] avatar Jul 24 '23 01:07 github-actions[bot]