Конфигурация безопасности Spring; как Basic Auth, так и SiteMinder - PullRequest
0 голосов
/ 13 сентября 2018

У меня есть загрузочное веб-приложение Spring, которое обслуживает как веб-контент, так и предоставляет REST Services. Веб-контент защищен SiteMinder, REST-сервисы защищены "Basic Auth".

Я использую Springs security 4.2.3. Мой Java-код расширяет класс WebSecurityConfigurerAdapter, мой метод configure (HttpSecurity) выглядит следующим образом:

@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);
}

Что-то не так с моей конфигурацией? Создает ли моя конфигурация три отдельных фильтра? Может быть, мой вопрос должен быть, как мне создать три фильтра?

Когда я пытаюсь вызвать службу REST с помощью PostMan / «Basic Auth», я получаю сообщение об ошибке:

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

Я ожидаю, что служба будет вызываться, вместо этого я получаю срабатывание фильтра SiteMinder.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...