【发布时间】:2015-07-15 06:58:49
【问题描述】:
我在我的应用程序上使用 Spring Security 4。在我的应用程序中,我有注册页面,我想将此页面排除在检查身份验证之外。 如何排除特定控制器方法的身份验证?
我的安全配置:
http.antMatcher("/test")
.httpBasic()
.and()
.authorizeRequests()
.antMatchers("/index.html", "/login.html", "/", "/scripts/**",
"/bower_components/**", "/styles/**", "/views/**",
"/login", "/api/user/*").permitAll().anyRequest()
.authenticated().and().logout().logoutUrl("/api/logout").and()
.csrf().csrfTokenRepository(csrfTokenRepository()).and()
.addFilterAfter(csrfHeaderFilter(), CsrfFilter.class);
我的控制器方法:
@RequestMapping(method = RequestMethod.POST, value = "/registration")
public ResponseEntity<RestUser> registration(
@RequestBody RestUser restuser, Principal p) throws Exception {
}
【问题讨论】:
-
向我们展示您的控制器和弹簧安全配置 ..stackoverflow.com/help/how-to-ask
-
编辑了我的问题。谢谢
标签: java spring spring-security