2014-01-30 45 views
4

当本地运行此文本时,此文本直接来自我的控制台记录器。第二行紧接着第一行。我不确定后台发生了什么情况,提供拒绝访问异常。Spring Security进行身份验证并立即返回拒绝访问

2014-01-30 07:48:14.854 INFO 5452 --- [nio-8085-exec-3] o.s.b.a.audit.listener.AuditListener  : AuditEvent [timestamp=Thu Jan 30 07:48:14 CST 2014, principal=r2n, type=AUTHENTICATION_SUCCESS, data={details=org.sprin[email protected]957e: RemoteIpAddress: 127.0.0.1; SessionId: 2C7EC273522BB6880EE3410201F8A41F}] 

2014-01-30 07:48:14.859 INFO 5452 --- [nio-8085-exec-4] o.s.b.a.audit.listener.AuditListener  : AuditEvent [timestamp=Thu Jan 30 07:48:14 CST 2014, principal=r2n, type=AUTHORIZATION_FAILURE, data={message=Access is denied, type=org.springframework.security.access.AccessDeniedException}] 

我的代码是使用Spring Boot 1.0.0.RC1,Spring Security 3.1.0.Release和thymeleaf for spring 2.1.1.Release编译的。我知道春季开始使用弹簧4时,与春季3的潜在春季依赖和时间有一些冲突。

我不认为我的问题在于他们。

下面是WebSecurityConfiguration中扩展WebSecurityConfigurerAdapter的代码。我的身份验证正在使用ldap。

@Override 
    protected void configure(HttpSecurity http) throws Exception { 
    http 
     .authorizeRequests() 
      .antMatchers("/error").anonymous() 
      .antMatchers("/navigation").anonymous() 
      .antMatchers("/**").hasRole("ADMIN") // #4 
      .and() 
     .formLogin() 
      .permitAll() 
      .defaultSuccessUrl("/") 
      .and() 
     .csrf().disable(); 
    } 

回答

2

您的“r2n”用户似乎没有“ADMIN”权限。也许你把他设置为“ROLE_ADMIN”,访问规则是“ADMIN”或什么的?

P.S.我认为你的意思是Spring Security 3.2.0.RELEASE(Javaconfig不在3.1中)。

相关问题