【发布时间】:2015-12-31 03:06:39
【问题描述】:
我遇到了单页应用程序配置 Spring Security 的问题。
所以,默认配置看起来像
@Configuration
@EnableWebSecurity
public class SecurityConfiguration extends WebSecurityConfigurerAdapter {
@Autowired
@Qualifier("customUserDetailsService")
UserDetailsService userDetailsService;
@Autowired
public void configureGlobalSecurity(AuthenticationManagerBuilder auth) throws Exception {
auth.userDetailsService(userDetailsService);
}
@Override
protected void configure(HttpSecurity http) throws Exception {
http.authorizeRequests()
.antMatchers("/", "/list").permitAll()
.antMatchers("/admin/**").access("hasRole('ADMIN')")
.and().formLogin().loginPage("/login").permitAll()
.usernameParameter("ssoId").passwordParameter("password")
.and().csrf()
.and().exceptionHandling().accessDeniedPage("/Access_Denied");
}
@Bean(name="authenticationManager")
@Override
public AuthenticationManager authenticationManagerBean() throws Exception {
return super.authenticationManagerBean();
}
}
从 Login().loginPage("/login") 方法的文档中说它用于重定向到登录页面。对于单页,此配置不相关。 我应该如何为单页应用程序配置 spring?我的意思是如何在控制器和配置文件中配置登录、注销。
【问题讨论】:
-
您可以查看JHipster 以了解如何使用 Spring 作为后端和 Angular 作为前端来配置登录。
标签: java spring spring-mvc spring-security