Конфигурация множественного входа в систему для безопасности Spring? - PullRequest
0 голосов
/ 12 ноября 2018

Я хочу настроить учетную запись таким образом, чтобы для URL с определенными типами /mvc/** попадал в определенное место для входа в систему, а все остальное /** попадало на другой URL. Ниже мой код. Что я делаю неправильно . Это работает, если мой муравейник /rest/**, но мне нужно, чтобы он работал с /**.

 @Configuration
    @Order(1)
    public static class App1ConfigurationAdapter extends WebSecurityConfigurerAdapter {
        public App1ConfigurationAdapter() {
            super();
        }

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

             http
    .antMatcher("/ui/**")
    .headers()
    .frameOptions().sameOrigin() // needed for H2 console to work
    .and()
    .csrf().disable()
    .exceptionHandling()
    .authenticationEntryPoint(new ContinueAuthenticationEntryPoint(“/login”))
    .and()
    .authorizeRequests()
    .antMatchers("/doImport").permitAll()
    .antMatchers("/health", "/info").permitAll()
    .anyRequest().authenticated()
    .and()
    .formLogin()
    .loginPage("/login").permitAll()
    .and()
    .logout().permitAll()
    .and()
    .sessionManagement().sessionCreationPolicy(SessionCreationPolicy.NEVER)
    .and()
    .httpBasic()
    .and()
    .exceptionHandling().accessDeniedPage("/access-denied");
        }
    }

И 2-я часть конфигурации

Configuration
@Order(2)
public static class App1ConfigurationAdapter extends WebSecurityConfigurerAdapter {
    public App1ConfigurationAdapter() {
        super();
    }

    @Override
    protected void configure(HttpSecurity http) throws Exception {
        http
    .antMatcher("/**")
    .headers()
    .frameOptions().sameOrigin() // needed for H2 console to work
    .and()
    .csrf().disable()
    .exceptionHandling()
    .authenticationEntryPoint(new ContinueAuthenticationEntryPoint(“/login”))
    .and()
    .authorizeRequests()
    .antMatchers("/doImport").permitAll()
    .antMatchers("/health", "/info").permitAll()
    .anyRequest().authenticated()
    .and()
    .formLogin()
    .loginPage("/login2").permitAll()
    .and()
    .logout().permitAll()
    .and()

  .sessionManagement().sessionCreationPolicy(SessionCreationPolicy.NEVER)
    .and()
    .httpBasic()
    .and()
    .exceptionHandling().accessDeniedPage("/access-denied");

    }
}

Но каждый раз, когда вызывается второй, а не первый.

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