【发布时间】:2016-05-09 05:10:55
【问题描述】:
我正在尝试在 spring 项目中从 angular js 配置登录视图。下面是我拥有的 spring security xml 设置..
<http auto-config="false" entry-point-ref="loginUrlAuthenticationEntryPoint">
<intercept-url pattern="/**" access="ROLE_ADMIN"/>
<custom-filter position="FORM_LOGIN_FILTER" ref="theiaFormAuthenticationFilter"/>
<custom-filter ref="theiaRestDigestFilter" after="FORM_LOGIN_FILTER" />
<logout logout-success-url="/#/login" />
<session-management invalid-session-url="/#/login" />
<access-denied-handler error-page="/loginFailed"/>
</http>
每当我尝试转到任何页面时,它都会给我ERR_TOO_MANY_REDIRECTS,甚至是localhost/#/login。请帮忙。从过去两天开始一直在研究这个问题,但无处可去。
谢谢。
更新:
实际上,现在我更改了代码以使用 Spring 安全配置类。它能够提供 Spring Security 附带的默认登录页面。但我无法添加用于登录的 angularjs 路由。以下是安全代码:
@Configuration
@EnableWebSecurity
public class SecurityConfiguration extends WebSecurityConfigurerAdapter {
@Autowired
public void configureGlobalSecurity(AuthenticationManagerBuilder auth) throws Exception {
auth.inMemoryAuthentication().withUser("bill").password("abc123").roles("USER");
auth.inMemoryAuthentication().withUser("admin").password("root123").roles("ADMIN");
auth.inMemoryAuthentication().withUser("dba").password("root123").roles("ADMIN","DBA");
}
@Override
protected void configure(HttpSecurity http) throws Exception {
log.info("Configuring theia security settings.");
http.authorizeRequests()
.antMatchers("/libs/**").permitAll()
.anyRequest().authenticated()
.and()
.formLogin()
.loginPage("/#/login").permitAll()
.and()
.logout().permitAll();
}
}
它似乎无法识别/#/login。在这个应用程序中,我们没有索引页面。它必须直接进入登录页面。无论如何要在配置文件中添加角度路线?我错过了什么吗?
我现在正在学习本教程:https://www.youtube.com/watch?v=1zu8COg80q4
【问题讨论】:
-
'theiaFormAuthenticationFilter' 和 'loginUrlAuthenticationEntryPoint' 的定义是什么?
-
您调用哪个 url,以及重定向到哪个 url? (尝试排除受保护的登录网址,还要考虑资源(js、css、图像...))
-
实际上我现在更改了代码以使用 Spring 安全配置类。它能够提供 Spring Security 附带的默认登录页面。但我无法添加用于登录的 angularjs 路由。以下是安全代码:
标签: angularjs spring spring-mvc spring-security