当前位置: 首页 > 知识库问答 >
问题:

Spring Security-访问被拒绝(用户不是匿名的)spring-security-core-4.0.3.RELEASE

闻深
2023-03-14

有人能在这个Spring Security配置文件中看到失败吗?

登录后,我得到一条调试消息:

拒绝访问(用户不是匿名的);委托给AccessDeniedHandler org . spring framework . security . Access . accessdeniedexception:访问被拒绝

但我可以访问应用程序

     @Override
  protected void configure(HttpSecurity http) throws Exception {
    http.
      authorizeRequests().antMatchers("/register/verification/*/*").anonymous()
      .and().authorizeRequests().antMatchers("/register/test").anonymous()
      .and().authorizeRequests().antMatchers("/register").anonymous()
      .and().authorizeRequests().antMatchers("/forgot_password").anonymous().and().authorizeRequests().antMatchers("/triggeredBy/password**").permitAll()
      .and().authorizeRequests().antMatchers("/err/403").permitAll()
      .and().authorizeRequests().antMatchers("/login").anonymous()
      .and().authorizeRequests().anyRequest().authenticated()
      .and().formLogin().loginPage("/login").defaultSuccessUrl("/landingPage", true).failureUrl("/login?error=true").usernameParameter(
      "username").passwordParameter("password").and().logout().logoutUrl("/logout").logoutSuccessUrl("/login?logout").and()
      .rememberMe().rememberMeCookieName("REMEMBER_ME").rememberMeParameter("remember_me").tokenValiditySeconds(123456).key(
      "49874795145977617241")
      .and().exceptionHandling().accessDeniedPage("/err/403");
  }

堆栈跟踪:

2016-01-11 12:09:17.826 DEBUG 1372 --- [nio-8080-exec-9] tRepository$SaveToSessionResponseWrapper : Skip invoking on
2016-01-11 12:09:17.826 DEBUG 1372 --- [nio-8080-exec-8] tRepository$SaveToSessionResponseWrapper : Skip invoking on
2016-01-11 12:09:17.826 DEBUG 1372 --- [nio-8080-exec-5] tRepository$SaveToSessionResponseWrapper : Skip invoking on
2016-01-11 12:09:17.826 DEBUG 1372 --- [nio-8080-exec-3] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/login'; against '/js/**'
2016-01-11 12:09:17.826 DEBUG 1372 --- [nio-8080-exec-7] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/login'; against '/forgot_password'
2016-01-11 12:09:17.826 DEBUG 1372 --- [io-8080-exec-10] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/err/403'; against '/js/**'
2016-01-11 12:09:17.826 DEBUG 1372 --- [nio-8080-exec-9] tRepository$SaveToSessionResponseWrapper : Skip invoking on
2016-01-11 12:09:17.826 DEBUG 1372 --- [nio-8080-exec-8] tRepository$SaveToSessionResponseWrapper : Skip invoking on
2016-01-11 12:09:17.826 DEBUG 1372 --- [nio-8080-exec-5] tRepository$SaveToSessionResponseWrapper : Skip invoking on
2016-01-11 12:09:17.826 DEBUG 1372 --- [nio-8080-exec-3] o.s.s.web.util.matcher.OrRequestMatcher  : Trying to match using Ant [pattern='/images/**']
2016-01-11 12:09:17.826 DEBUG 1372 --- [nio-8080-exec-7] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/login'; against '/triggeredby/password**'
2016-01-11 12:09:17.826 DEBUG 1372 --- [io-8080-exec-10] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/err/403'; against '/img/**'
2016-01-11 12:09:17.826 DEBUG 1372 --- [nio-8080-exec-9] tRepository$SaveToSessionResponseWrapper : Skip invoking on
2016-01-11 12:09:17.826 DEBUG 1372 --- [nio-8080-exec-8] tRepository$SaveToSessionResponseWrapper : Skip invoking on
2016-01-11 12:09:17.826 DEBUG 1372 --- [nio-8080-exec-5] tRepository$SaveToSessionResponseWrapper : Skip invoking on
2016-01-11 12:09:17.826 DEBUG 1372 --- [nio-8080-exec-3] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/login'; against '/images/**'
2016-01-11 12:09:17.826 DEBUG 1372 --- [nio-8080-exec-7] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/login'; against '/err/403'
2016-01-11 12:09:17.826 DEBUG 1372 --- [io-8080-exec-10] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/err/403'; against '/fonts/**'
2016-01-11 12:09:17.826 DEBUG 1372 --- [nio-8080-exec-9] tRepository$SaveToSessionResponseWrapper : Skip invoking on
2016-01-11 12:09:17.826 DEBUG 1372 --- [nio-8080-exec-8] tRepository$SaveToSessionResponseWrapper : Skip invoking on
2016-01-11 12:09:17.826 DEBUG 1372 --- [nio-8080-exec-5] tRepository$SaveToSessionResponseWrapper : Skip invoking on
2016-01-11 12:09:17.826 DEBUG 1372 --- [nio-8080-exec-3] o.s.s.web.util.matcher.OrRequestMatcher  : Trying to match using Ant [pattern='/**/favicon.ico']
2016-01-11 12:09:17.826 DEBUG 1372 --- [nio-8080-exec-7] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/login'; against '/login'
2016-01-11 12:09:17.826 DEBUG 1372 --- [io-8080-exec-10] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/err/403'; against '/favicon.ico'
2016-01-11 12:09:17.826 DEBUG 1372 --- [nio-8080-exec-9] tRepository$SaveToSessionResponseWrapper : Skip invoking on
2016-01-11 12:09:17.826 DEBUG 1372 --- [nio-8080-exec-8] tRepository$SaveToSessionResponseWrapper : Skip invoking on
2016-01-11 12:09:17.826 DEBUG 1372 --- [nio-8080-exec-5] tRepository$SaveToSessionResponseWrapper : Skip invoking on
2016-01-11 12:09:17.826 DEBUG 1372 --- [nio-8080-exec-3] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/login'; against '/**/favicon.ico'
2016-01-11 12:09:17.826 DEBUG 1372 --- [nio-8080-exec-7] o.s.s.w.a.i.FilterSecurityInterceptor    : Secure object: FilterInvocation: URL: /login; Attributes: [anonymous]
2016-01-11 12:09:17.826 DEBUG 1372 --- [nio-8080-exec-9] tRepository$SaveToSessionResponseWrapper : Skip invoking on
2016-01-11 12:09:17.826 DEBUG 1372 --- [io-8080-exec-10] o.s.security.web.FilterChainProxy        : /err/403 at position 1 of 13 in additional filter chain; firing Filter: 'WebAsyncManagerIntegrationFilter'
2016-01-11 12:09:17.826 DEBUG 1372 --- [nio-8080-exec-8] tRepository$SaveToSessionResponseWrapper : Skip invoking on
2016-01-11 12:09:17.826 DEBUG 1372 --- [nio-8080-exec-5] tRepository$SaveToSessionResponseWrapper : Skip invoking on
2016-01-11 12:09:17.826 DEBUG 1372 --- [nio-8080-exec-3] o.s.s.web.util.matcher.OrRequestMatcher  : Trying to match using Ant [pattern='/error']
2016-01-11 12:09:17.826 DEBUG 1372 --- [nio-8080-exec-9] tRepository$SaveToSessionResponseWrapper : Skip invoking on
2016-01-11 12:09:17.826 DEBUG 1372 --- [nio-8080-exec-7] o.s.s.w.a.i.FilterSecurityInterceptor    : Previously Authenticated: org.springframework.security.authentication.UsernamePasswordAuthenticationToken@18b68a6c: Principal: de.upb.msapp.web.model.profiles.Profile@2; Credentials: [PROTECTED]; Authenticated: true; Details: org.springframework.security.web.authentication.WebAuthenticationDetails@2eb76: RemoteIpAddress: 127.0.0.1; SessionId: E46776770A1C922CDF1A00121BB6A4E3; Granted Authorities: ROLE_PATIENT, ROLE_PROFILE
2016-01-11 12:09:17.826 DEBUG 1372 --- [io-8080-exec-10] o.s.security.web.FilterChainProxy        : /err/403 at position 2 of 13 in additional filter chain; firing Filter: 'SecurityContextPersistenceFilter'
2016-01-11 12:09:17.826 DEBUG 1372 --- [nio-8080-exec-8] tRepository$SaveToSessionResponseWrapper : Skip invoking on
2016-01-11 12:09:17.826 DEBUG 1372 --- [nio-8080-exec-5] tRepository$SaveToSessionResponseWrapper : Skip invoking on
2016-01-11 12:09:17.826 DEBUG 1372 --- [nio-8080-exec-3] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/login'; against '/error'
2016-01-11 12:09:17.826 DEBUG 1372 --- [nio-8080-exec-9] tRepository$SaveToSessionResponseWrapper : Skip invoking on
2016-01-11 12:09:17.826 DEBUG 1372 --- [nio-8080-exec-7] o.s.s.access.vote.AffirmativeBased       : Voter: org.springframework.security.web.access.expression.WebExpressionVoter@5b5cddbb, returned: -1
2016-01-11 12:09:17.826 DEBUG 1372 --- [io-8080-exec-10] o.s.security.web.FilterChainProxy        : /err/403 at position 3 of 13 in additional filter chain; firing Filter: 'HeaderWriterFilter'
2016-01-11 12:09:17.826 DEBUG 1372 --- [nio-8080-exec-8] tRepository$SaveToSessionResponseWrapper : Skip invoking on
2016-01-11 12:09:17.826 DEBUG 1372 --- [nio-8080-exec-5] tRepository$SaveToSessionResponseWrapper : Skip invoking on
2016-01-11 12:09:17.826 DEBUG 1372 --- [nio-8080-exec-3] o.s.s.web.util.matcher.OrRequestMatcher  : No matches found
2016-01-11 12:09:17.826 DEBUG 1372 --- [nio-8080-exec-9] tRepository$SaveToSessionResponseWrapper : Skip invoking on
2016-01-11 12:09:17.826 DEBUG 1372 --- [io-8080-exec-10] o.s.security.web.FilterChainProxy        : /err/403 at position 4 of 13 in additional filter chain; firing Filter: 'CsrfFilter'
2016-01-11 12:09:17.826 DEBUG 1372 --- [nio-8080-exec-8] tRepository$SaveToSessionResponseWrapper : Skip invoking on
2016-01-11 12:09:17.826 DEBUG 1372 --- [nio-8080-exec-5] tRepository$SaveToSessionResponseWrapper : Skip invoking on
2016-01-11 12:09:17.826 DEBUG 1372 --- [nio-8080-exec-3] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/login'; against '/static/**'
2016-01-11 12:09:17.826 DEBUG 1372 --- [nio-8080-exec-9] tRepository$SaveToSessionResponseWrapper : Skip invoking on
2016-01-11 12:09:17.826 DEBUG 1372 --- [io-8080-exec-10] o.s.security.web.FilterChainProxy        : /err/403 at position 5 of 13 in additional filter chain; firing Filter: 'LogoutFilter'
2016-01-11 12:09:17.826 DEBUG 1372 --- [nio-8080-exec-8] tRepository$SaveToSessionResponseWrapper : Skip invoking on
2016-01-11 12:09:17.826 DEBUG 1372 --- [nio-8080-exec-5] tRepository$SaveToSessionResponseWrapper : Skip invoking on
2016-01-11 12:09:17.826 DEBUG 1372 --- [nio-8080-exec-3] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/login'; against '/resources/**'
2016-01-11 12:09:17.826 DEBUG 1372 --- [nio-8080-exec-9] tRepository$SaveToSessionResponseWrapper : Skip invoking on
2016-01-11 12:09:17.826 DEBUG 1372 --- [io-8080-exec-10] o.s.s.w.u.matcher.AntPathRequestMatcher  : Request 'GET /err/403' doesn't match 'POST /logout
2016-01-11 12:09:17.826 DEBUG 1372 --- [nio-8080-exec-8] tRepository$SaveToSessionResponseWrapper : Skip invoking on
2016-01-11 12:09:17.826 DEBUG 1372 --- [nio-8080-exec-5] tRepository$SaveToSessionResponseWrapper : Skip invoking on
2016-01-11 12:09:17.826 DEBUG 1372 --- [nio-8080-exec-3] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/login'; against '/uploads/**'
2016-01-11 12:09:17.826 DEBUG 1372 --- [nio-8080-exec-9] tRepository$SaveToSessionResponseWrapper : Skip invoking on
2016-01-11 12:09:17.826 DEBUG 1372 --- [io-8080-exec-10] o.s.security.web.FilterChainProxy        : /err/403 at position 6 of 13 in additional filter chain; firing Filter: 'UsernamePasswordAuthenticationFilter'
2016-01-11 12:09:17.826 DEBUG 1372 --- [nio-8080-exec-8] tRepository$SaveToSessionResponseWrapper : Skip invoking on
2016-01-11 12:09:17.826 DEBUG 1372 --- [nio-8080-exec-5] tRepository$SaveToSessionResponseWrapper : Skip invoking on
2016-01-11 12:09:17.826 DEBUG 1372 --- [nio-8080-exec-3] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/login'; against '/css/**'
2016-01-11 12:09:17.826 DEBUG 1372 --- [nio-8080-exec-9] tRepository$SaveToSessionResponseWrapper : Skip invoking on
2016-01-11 12:09:17.826 DEBUG 1372 --- [io-8080-exec-10] o.s.s.w.u.matcher.AntPathRequestMatcher  : Request 'GET /err/403' doesn't match 'POST /login
2016-01-11 12:09:17.826 DEBUG 1372 --- [nio-8080-exec-8] tRepository$SaveToSessionResponseWrapper : Skip invoking on
2016-01-11 12:09:17.826 DEBUG 1372 --- [nio-8080-exec-5] tRepository$SaveToSessionResponseWrapper : Skip invoking on
2016-01-11 12:09:17.826 DEBUG 1372 --- [nio-8080-exec-3] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/login'; against '/js/**'
2016-01-11 12:09:17.826 DEBUG 1372 --- [nio-8080-exec-9] tRepository$SaveToSessionResponseWrapper : Skip invoking on
2016-01-11 12:09:17.826 DEBUG 1372 --- [io-8080-exec-10] o.s.security.web.FilterChainProxy        : /err/403 at position 7 of 13 in additional filter chain; firing Filter: 'RequestCacheAwareFilter'
2016-01-11 12:09:17.826 DEBUG 1372 --- [nio-8080-exec-8] tRepository$SaveToSessionResponseWrapper : Skip invoking on
2016-01-11 12:09:17.826 DEBUG 1372 --- [nio-8080-exec-5] tRepository$SaveToSessionResponseWrapper : Skip invoking on
2016-01-11 12:09:17.826 DEBUG 1372 --- [nio-8080-exec-3] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/login'; against '/img/**'
2016-01-11 12:09:17.827 DEBUG 1372 --- [nio-8080-exec-9] tRepository$SaveToSessionResponseWrapper : Skip invoking on
2016-01-11 12:09:17.827 DEBUG 1372 --- [io-8080-exec-10] o.s.security.web.FilterChainProxy        : /err/403 at position 8 of 13 in additional filter chain; firing Filter: 'SecurityContextHolderAwareRequestFilter'
2016-01-11 12:09:17.827 DEBUG 1372 --- [nio-8080-exec-8] tRepository$SaveToSessionResponseWrapper : Skip invoking on
2016-01-11 12:09:17.827 DEBUG 1372 --- [nio-8080-exec-5] tRepository$SaveToSessionResponseWrapper : Skip invoking on
2016-01-11 12:09:17.827 DEBUG 1372 --- [nio-8080-exec-3] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/login'; against '/fonts/**'
2016-01-11 12:09:17.827 DEBUG 1372 --- [nio-8080-exec-9] tRepository$SaveToSessionResponseWrapper : Skip invoking on
2016-01-11 12:09:17.827 DEBUG 1372 --- [io-8080-exec-10] o.s.security.web.FilterChainProxy        : /err/403 at position 9 of 13 in additional filter chain; firing Filter: 'RememberMeAuthenticationFilter'
2016-01-11 12:09:17.827 DEBUG 1372 --- [nio-8080-exec-8] tRepository$SaveToSessionResponseWrapper : Skip invoking on
2016-01-11 12:09:17.827 DEBUG 1372 --- [nio-8080-exec-5] tRepository$SaveToSessionResponseWrapper : Skip invoking on
2016-01-11 12:09:17.827 DEBUG 1372 --- [nio-8080-exec-3] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/login'; against '/favicon.ico'
2016-01-11 12:09:17.827 DEBUG 1372 --- [nio-8080-exec-9] tRepository$SaveToSessionResponseWrapper : Skip invoking on
2016-01-11 12:09:17.827 DEBUG 1372 --- [nio-8080-exec-8] tRepository$SaveToSessionResponseWrapper : Skip invoking on
2016-01-11 12:09:17.827 DEBUG 1372 --- [io-8080-exec-10] s.s.w.a.r.RememberMeAuthenticationFilter : SecurityContextHolder not populated with remember-me token, as it already contained: 'org.springframework.security.authentication.UsernamePasswordAuthenticationToken@18b68a6c: Principal: de.upb.msapp.web.model.profiles.Profile@2; Credentials: [PROTECTED]; Authenticated: true; Details: org.springframework.security.web.authentication.WebAuthenticationDetails@2eb76: RemoteIpAddress: 127.0.0.1; SessionId: E46776770A1C922CDF1A00121BB6A4E3; Granted Authorities: ROLE_PATIENT, ROLE_PROFILE'
2016-01-11 12:09:17.827 DEBUG 1372 --- [nio-8080-exec-5] tRepository$SaveToSessionResponseWrapper : Skip invoking on
2016-01-11 12:09:17.827 DEBUG 1372 --- [nio-8080-exec-9] tRepository$SaveToSessionResponseWrapper : Skip invoking on
2016-01-11 12:09:17.827 DEBUG 1372 --- [nio-8080-exec-3] o.s.security.web.FilterChainProxy        : /login at position 1 of 13 in additional filter chain; firing Filter: 'WebAsyncManagerIntegrationFilter'
2016-01-11 12:09:17.827 DEBUG 1372 --- [nio-8080-exec-8] tRepository$SaveToSessionResponseWrapper : Skip invoking on
2016-01-11 12:09:17.827 DEBUG 1372 --- [io-8080-exec-10] o.s.security.web.FilterChainProxy        : /err/403 at position 10 of 13 in additional filter chain; firing Filter: 'AnonymousAuthenticationFilter'
2016-01-11 12:09:17.827 DEBUG 1372 --- [nio-8080-exec-5] tRepository$SaveToSessionResponseWrapper : Skip invoking on
2016-01-11 12:09:17.827 DEBUG 1372 --- [nio-8080-exec-9] tRepository$SaveToSessionResponseWrapper : Skip invoking on
2016-01-11 12:09:17.827 DEBUG 1372 --- [nio-8080-exec-3] o.s.security.web.FilterChainProxy        : /login at position 2 of 13 in additional filter chain; firing Filter: 'SecurityContextPersistenceFilter'
2016-01-11 12:09:17.827 DEBUG 1372 --- [nio-8080-exec-8] tRepository$SaveToSessionResponseWrapper : Skip invoking on
2016-01-11 12:09:17.827 DEBUG 1372 --- [io-8080-exec-10] o.s.s.w.a.AnonymousAuthenticationFilter  : SecurityContextHolder not populated with anonymous token, as it already contained: 'org.springframework.security.authentication.UsernamePasswordAuthenticationToken@18b68a6c: Principal: de.upb.msapp.web.model.profiles.Profile@2; Credentials: [PROTECTED]; Authenticated: true; Details: org.springframework.security.web.authentication.WebAuthenticationDetails@2eb76: RemoteIpAddress: 127.0.0.1; SessionId: E46776770A1C922CDF1A00121BB6A4E3; Granted Authorities: ROLE_PATIENT, ROLE_PROFILE'
2016-01-11 12:09:17.827 DEBUG 1372 --- [nio-8080-exec-5] tRepository$SaveToSessionResponseWrapper : Skip invoking on
2016-01-11 12:09:17.827 DEBUG 1372 --- [nio-8080-exec-7] o.s.s.w.a.ExceptionTranslationFilter     : Access is denied (user is not anonymous); delegating to AccessDeniedHandler

org.springframework.security.access.AccessDeniedException: Access is denied
    at org.springframework.security.access.vote.AffirmativeBased.decide(AffirmativeBased.java:83) ~[spring-security-core-4.0.3.RELEASE.jar:4.0.3.RELEASE]
    at org.springframework.security.access.intercept.AbstractSecurityInterceptor.beforeInvocation(AbstractSecurityInterceptor.java:232) ~[spring-security-core-4.0.3.RELEASE.jar:4.0.3.RELEASE]
    at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:123) ~[spring-security-web-4.0.3.RELEASE.jar:4.0.3.RELEASE]
    at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:90) ~[spring-security-web-4.0.3.RELEASE.jar:4.0.3.RELEASE]
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330) [spring-security-web-4.0.3.RELEASE.jar:4.0.3.RELEASE]
    at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:114) ~[spring-security-web-4.0.3.RELEASE.jar:4.0.3.RELEASE]
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330) [spring-security-web-4.0.3.RELEASE.jar:4.0.3.RELEASE]
    at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:122) [spring-security-web-4.0.3.RELEASE.jar:4.0.3.RELEASE]
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330) [spring-security-web-4.0.3.RELEASE.jar:4.0.3.RELEASE]
    at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:111) [spring-security-web-4.0.3.RELEASE.jar:4.0.3.RELEASE]
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330) [spring-security-web-4.0.3.RELEASE.jar:4.0.3.RELEASE]
    at org.springframework.security.web.authentication.rememberme.RememberMeAuthenticationFilter.doFilter(RememberMeAuthenticationFilter.java:157) [spring-security-web-4.0.3.RELEASE.jar:4.0.3.RELEASE]
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330) [spring-security-web-4.0.3.RELEASE.jar:4.0.3.RELEASE]
    at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:169) [spring-security-web-4.0.3.RELEASE.jar:4.0.3.RELEASE]
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330) [spring-security-web-4.0.3.RELEASE.jar:4.0.3.RELEASE]
    at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:48) [spring-security-web-4.0.3.RELEASE.jar:4.0.3.RELEASE]
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330) [spring-security-web-4.0.3.RELEASE.jar:4.0.3.RELEASE]
    at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:205) [spring-security-web-4.0.3.RELEASE.jar:4.0.3.RELEASE]
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330) [spring-security-web-4.0.3.RELEASE.jar:4.0.3.RELEASE]
    at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:120) [spring-security-web-4.0.3.RELEASE.jar:4.0.3.RELEASE]
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330) [spring-security-web-4.0.3.RELEASE.jar:4.0.3.RELEASE]
    at org.springframework.security.web.csrf.CsrfFilter.doFilterInternal(CsrfFilter.java:96) [spring-security-web-4.0.3.RELEASE.jar:4.0.3.RELEASE]
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) [spring-web-4.2.4.RELEASE.jar:4.2.4.RELEASE]
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330) [spring-security-web-4.0.3.RELEASE.jar:4.0.3.RELEASE]
    at org.springframework.security.web.header.HeaderWriterFilter.doFilterInternal(HeaderWriterFilter.java:64) [spring-security-web-4.0.3.RELEASE.jar:4.0.3.RELEASE]
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) [spring-web-4.2.4.RELEASE.jar:4.2.4.RELEASE]
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330) [spring-security-web-4.0.3.RELEASE.jar:4.0.3.RELEASE]
    at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:91) [spring-security-web-4.0.3.RELEASE.jar:4.0.3.RELEASE]
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330) [spring-security-web-4.0.3.RELEASE.jar:4.0.3.RELEASE]
    at org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:53) [spring-security-web-4.0.3.RELEASE.jar:4.0.3.RELEASE]
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) [spring-web-4.2.4.RELEASE.jar:4.2.4.RELEASE]
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330) [spring-security-web-4.0.3.RELEASE.jar:4.0.3.RELEASE]
    at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:213) [spring-security-web-4.0.3.RELEASE.jar:4.0.3.RELEASE]
    at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:176) [spring-security-web-4.0.3.RELEASE.jar:4.0.3.RELEASE]
    at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:346) [spring-web-4.2.4.RELEASE.jar:4.2.4.RELEASE]
    at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:262) [spring-web-4.2.4.RELEASE.jar:4.2.4.RELEASE]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239) [tomcat-embed-core-8.0.30.jar:8.0.30]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) [tomcat-embed-core-8.0.30.jar:8.0.30]
    at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:99) [spring-web-4.2.4.RELEASE.jar:4.2.4.RELEASE]
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) [spring-web-4.2.4.RELEASE.jar:4.2.4.RELEASE]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239) [tomcat-embed-core-8.0.30.jar:8.0.30]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) [tomcat-embed-core-8.0.30.jar:8.0.30]
    at org.springframework.web.filter.HttpPutFormContentFilter.doFilterInternal(HttpPutFormContentFilter.java:87) [spring-web-4.2.4.RELEASE.jar:4.2.4.RELEASE]
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) [spring-web-4.2.4.RELEASE.jar:4.2.4.RELEASE]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239) [tomcat-embed-core-8.0.30.jar:8.0.30]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) [tomcat-embed-core-8.0.30.jar:8.0.30]
    at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:77) [spring-web-4.2.4.RELEASE.jar:4.2.4.RELEASE]
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) [spring-web-4.2.4.RELEASE.jar:4.2.4.RELEASE]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239) [tomcat-embed-core-8.0.30.jar:8.0.30]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) [tomcat-embed-core-8.0.30.jar:8.0.30]
    at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:121) [spring-web-4.2.4.RELEASE.jar:4.2.4.RELEASE]
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) [spring-web-4.2.4.RELEASE.jar:4.2.4.RELEASE]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239) [tomcat-embed-core-8.0.30.jar:8.0.30]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) [tomcat-embed-core-8.0.30.jar:8.0.30]
    at org.springframework.boot.actuate.autoconfigure.MetricsFilter.doFilterInternal(MetricsFilter.java:103) [spring-boot-actuator-1.3.1.RELEASE.jar:1.3.1.RELEASE]
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) [spring-web-4.2.4.RELEASE.jar:4.2.4.RELEASE]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239) [tomcat-embed-core-8.0.30.jar:8.0.30]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) [tomcat-embed-core-8.0.30.jar:8.0.30]
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:212) [tomcat-embed-core-8.0.30.jar:8.0.30]
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106) [tomcat-embed-core-8.0.30.jar:8.0.30]
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502) [tomcat-embed-core-8.0.30.jar:8.0.30]
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:141) [tomcat-embed-core-8.0.30.jar:8.0.30]
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79) [tomcat-embed-core-8.0.30.jar:8.0.30]
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88) [tomcat-embed-core-8.0.30.jar:8.0.30]
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:521) [tomcat-embed-core-8.0.30.jar:8.0.30]
    at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1096) [tomcat-embed-core-8.0.30.jar:8.0.30]
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:674) [tomcat-embed-core-8.0.30.jar:8.0.30]
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1500) [tomcat-embed-core-8.0.30.jar:8.0.30]
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1456) [tomcat-embed-core-8.0.30.jar:8.0.30]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [na:1.8.0_60]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [na:1.8.0_60]
    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) [tomcat-embed-core-8.0.30.jar:8.0.30]
    at java.lang.Thread.run(Thread.java:745) [na:1.8.0_60]

2016-01-11 12:09:17.827 DEBUG 1372 --- [nio-8080-exec-9] tRepository$SaveToSessionResponseWrapper : Skip invoking on
2016-01-11 12:09:17.827 DEBUG 1372 --- [nio-8080-exec-8] tRepository$SaveToSessionResponseWrapper : Skip invoking on

共有3个答案

柳轶
2023-03-14

请尝试下面的代码。它对我有用。

     http
    .csrf().disable()
    .authorizeRequests()

    .antMatchers("/login**", "/").permitAll()        
    .antMatchers("/user/**").access("hasAnyAuthority('USER')")
    .antMatchers("/admin/**").access("hasAnyAuthority('ADMIN')")

    .anyRequest().fullyAuthenticated()
        .and()
    .formLogin();
汲涵育
2023-03-14

这对我有效-< code > has authority(" ROLE _ USER ")

尝试使用@Rlet准许("USER")而不是@Rtis准许("ROLE_USER")。最终,您可以使用hasAuthory("ROLE_USER")hasRole("USER")而不是hasRole("ROLE_USER")

曾新立
2023-03-14

从Spring保安留档

匿名()指定匿名用户允许URL。

让我们看看您的一些代码:

.and().authorizeRequests().antMatchers("/login").anonymous()

您告诉系统只允许匿名用户(ROLE_anonymous)调用/login映射。

当您使用用户登录时,该用户具有另一个角色,不再是匿名的。对于这个代码示例,您应该使用permitAll()

最有可能的是,您还想在其他请求匹配器上使用 permitAll(),在您的情况下,我也只会对 /login 使用一个映射 -

 类似资料:
  • 登录成功,但即使我允许访问USER,Spring安全也会阻止url。我如何管理这个东西? 登录控制器。JAVA 1.登录成功后,页面重定向到欢迎页面,但url仍然是localhost:8080/Login,而不是localhost:8080/welcome。 2.重定向到URL localhost:8080/sales后,403访问被拒绝。

  • 我已经尝试了几乎所有关于它的其他帖子,没有任何一个与我的问题相关。

  • 此url<code>http://localhost:8070/produits与Postman一起工作很好。它返回以下内容: 添加Spring Security性后,此url返回403访问被拒绝,即使用户名和密码正确。 安全配置.java 宁静的服务

  • 我已经将Spring security添加到我的项目中,并将其配置为 我有没有搞错。

  • 我试图使用spring boot oauth2来完成无状态身份验证和授权。然而,我正在努力工作。 下面是我的代码: 授权配置: 资源服务器配置: 控制器: 我可以用邮递员拿到访问令牌。我在标题中使用相同的访问令牌来获取用户详细信息,例如。但是,我会得到登录页面html响应,下面是登录控制台: 但是,当我第一次调用以获取对的访问令牌时,似乎已经通过了身份验证: 可能是我配置错误。我在这里漏掉了什么?

  • 问题内容: 我正在尝试从数据库中获取记录。但我正面临拒绝访问的问题。我尝试了在堆栈溢出中提到的其他解决方案,例如向用户授予特权。 访问数据库的代码: 错误的堆栈跟踪: 在这种情况下可能是什么问题。我尝试创建一个新的数据库,但是也没有用。 问题答案: 问题是授予表根用户的权限。’root’@’%’没有任何权限。.就像我以前用作连接地址一样,因此它给出了拒绝访问错误.. 是IP地址的通配符。所以mys