2

I have a Spring boot web app that serves up both web content and exposes REST Services. The web content is protected by SiteMinder, the REST Services are protected by "Basic Auth".

I using Springs security 4.2.3. My Java code is extending the class WebSecurityConfigurerAdapter, my configure(HttpSecurity) method looks like:

@Override
protected void configure(HttpSecurity http) throws Exception {

    RequestHeaderAuthenticationFilter siteMinderFilter = new RequestHeaderAuthenticationFilter();
    siteMinderFilter.setAuthenticationManager(authenticationManager());

    http
      // Error page is for everyone
      .authorizeRequests()
      .antMatchers("/error.html")
      .permitAll()
      .anyRequest()
      .anonymous()

      // Basic Auth for our REST services
      .and()
      .authorizeRequests()
      .antMatchers("/services/**")
      .permitAll()
      .anyRequest()
      .authenticated()
      .and()
      .httpBasic()
      .authenticationEntryPoint(authenticationEntryPoint)

      // Site-Minder protection for the web content
      .and()
      .addFilter(siteMinderFilter)
      .authorizeRequests()
      .antMatchers("/**").permitAll()
      .anyRequest().hasRole(ApplicationConstants.SITE_MINDER_AUTHORITY);

    http.addFilterAfter(new CustomFilter(), BasicAuthenticationFilter.class);
}

Is there something wrong with my configuration? Does my configuration create three separate filters? Maybe my question should be, how do I create the three filters?

When I attempt to call the REST Service using PostMan / "Basic Auth", I get the error message:

  org.springframework.security.web.authentication.preauth.PreAuthenticatedCredentialsNotFoundException: SM_USER header not found in request.

I expect the service to get called, instead I get the SiteMinder filter firing.

  • What is happening with this config? – rick Sep 13 '18 at 15:03
  • Hi @rick, I added the error message to the original posting. Thanks for pointing out that I forgot it... – user2608333 Sep 13 '18 at 15:12
  • I deleted the answer cause I found another on her : https://stackoverflow.com/questions/33037559/spring-rest-security-secure-different-urls-differently In the comments of the answer you can find a case similar to yours – rick Sep 13 '18 at 16:38
  • Thanks @rick. You're help moved me forward in my solution. – user2608333 Sep 13 '18 at 17:30

0 Answers0