0

I have an spring boot application serving restful api's.

I'd like to make sure that certain fields are masked / encrypted at the earliest possible time so that they are not shown in clear text in the application log ... via logback.

Is there an entry point / filter / sprint aspect I can implement so a to achieve this ?

Joe Daly
  • 33
  • 4

1 Answers1

0

As cearly explained in Ali Dehghani's Answer in this post the best place to do what you want to, is in a Response filter. So you have to write a class that implements the Filter interface and you filter your response in the doFilter method.

@Component
public class YourResponseFilter implements Filter {
 
  @Override
  public void doFilter(
    ServletRequest request, 
    ServletResponse response, 
    FilterChain chain) throws IOException, ServletException {
    ...
    // do your work there
  }
}

You may or may not use the annotate your filter with @Component, depending in the fact if you want to filter all your reponses or not. If you need more help let me know.

Community
  • 1
  • 1
Meziane
  • 1,586
  • 1
  • 12
  • 22