0
votes

I need to implement REST Basic authentication in my application. In which the request will contain a header with the value of the username:password encrypted to base64.

My application uses DaoAuthenticationProvider. This way, the provider expects username & password in order to do the authentication process.

From the configuration of the authentication filter, I saw that the filter has two properties (usernameParameter and passwordParameter). In my case, the username and password will not be sent as parameters so I thought to have a filter before the authentication processing filter which retrieve the required data from the request header, then pass it to the next filter.

My questions:

  1. Is this the proper way to do rest basic authentication? Or there are any other ways?
  2. Is there any example for having a custom filter before the authentication processing filter?
1

1 Answers

1
votes

You're probably looking at the wrong filter because there is one that does HTTP basic auth already (see e.g. docs here). Example:

protected void configure(HttpSecurity http) throws Exception {
    http.authorizeRequests()
        .anyRequest().authenticated()
        .and()
     .httpBasic();
}