2016-05-18 5 views
0

Я следовал за весенним учебником «SSO с OAuth2: Angular JS и Spring V Part V».Spring Boot Oauth Custom Login Form

Я преобразовал «authserver» -project из maven в gradle, после чего пользовательская форма входа больше не работает.

Заданы ли wro задачи в файле pom.xml для формы входа в систему?

Я также попробовал этот учебник, но он не работает в моем сценарии либо: http://docs.spring.io/spring-security/site/docs/3.2.x/guides/form.html

Я надеюсь, что вы можете мне помочь.

Logfile:

2016-05-18 11: 14: 53,667 ОТЛАДКА 22312 --- [NiO-9999-Exec-9] ossecurity.web.FilterChainProxy:/Войти в положении 5 14 в дополнительной цепи фильтра; firing Filter: 'LogoutFilter' 2016-05-18 11: 14: 53.667 DEBUG 22312 --- [nio-9999-exec-9] osswumatcher.AntPathRequestMatcher: запрос 'GET/login' не соответствует 'POST/logout 2016-05-18 11: 14: 53.667 DEBUG 22312 --- [nio-9999-exec-9] ossecurity.web.FilterChainProxy:/логин в позиции 6 из 14 в дополнительной цепочке фильтров; firing Filter: 'UsernamePasswordAuthenticationFilter' 2016-05-18 11: 14: 53.667 DEBUG 22312 --- [nio-9999-exec-9] osswumatcher.AntPathRequestMatcher: запрос «GET/login» не соответствует «POST/login» 2016-05-18 11: 14: 53.667 DEBUG 22312 --- [nio-9999-exec-9] ossecurity.web.FilterChainProxy:/логин в позиции 7 из 14 в дополнительной цепочке фильтров; firing Filter: 'DefaultLoginPageGeneratingFilter' 2016-05-18 11: 14: 53.667 DEBUG 22312 --- [nio-9999-exec-9] wcHttpSessionSecurityContextRepository: SecurityContext пуст или содержимое анонимно - контекст не будет сохранен в HttpSession.

Код в OAuth2ServerConfiguration:

@Override 
    public void configure(HttpSecurity http) throws Exception { 
     http.formLogin().loginPage("/login").permitAll() 
      .and().requestMatchers() 
       .antMatchers("/login", "/oauth/authorize", "/oauth/confirm_access") 
      .and().authorizeRequests() 
       .anyRequest().authenticated(); 
    } 

MainAuthserverApplication.java: @ComponentScan @SessionAttributes("authorizationRequest") @EnableAutoConfiguration() @EnableConfigurationProperties ({AuthProperties.class}) public class MainAuthserverApplication extends WebMvcConfigurerAdapter {

@Override 
public void addViewControllers(ViewControllerRegistry registry) { 
    registry.addViewController("/login").setViewName("login"); 
    registry.setOrder(Ordered.HIGHEST_PRECEDENCE); 
    registry.addViewController("/oauth/confirm_access").setViewName("authorize"); 
} 

ответ

0

Я уже неподвижная й е проблема сам:

Кажется, что эти два метода должны быть в том же классе:

@Configuration 
@Order(-20) 
protected static class LoginConfig extends WebSecurityConfigurerAdapter { 

    @Autowired 
    private AuthenticationManager authenticationManager; 

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


     // @formatter:off 
     http.formLogin().loginPage("/login").permitAll().and().requestMatchers() 
      .antMatchers("/login", "/oauth/authorize", "/oauth/confirm_access").and().authorizeRequests() 
      .anyRequest().authenticated(); 
     // @formatter:on 
    } 

    @Override 
    protected void configure(AuthenticationManagerBuilder auth) throws Exception { 
     auth.parentAuthenticationManager(authenticationManager); 
    } 
} 
Смежные вопросы