使用spring-boot安全性进行身份验证的问题

时间:2017-03-29 20:08:34

标签: hibernate spring-boot login spring-security spring-data-jpa

我在登录模块中面临弹簧启动和弹簧安全问题,这让我发疯。

这是表格登录:

<form id="login" th:action="@{/login}" method="POST">
                        <fieldset>
                          <div th:if="${param.error}">
                            <li><span style="color:#FF1493; float:left;" th:text="#{labels.menu.errormessage}"></span></li>
                          </div>
                          <div class="form-group label-floating">
                            <div class="input-group">
                              <span class="input-group-addon">
                                <i class="zmdi zmdi-account"></i>
                              </span>
                              <label class="control-label" for="ms-form-user">Usuário (e-mail)</label>
                              <input type="text" id="login" class="form-control" name="username"/> </div>
                          </div>
                          <div class="form-group label-floating">
                            <div class="input-group">
                              <span class="input-group-addon">
                                <i class="zmdi zmdi-lock"></i>
                              </span>
                              <label class="control-label" for="ms-form-pass">Senha</label>
                              <input type="password" id="login" class="form-control" name="password"/> </div>
                          </div>
                          <div class="row mt-2">
                            <div class="col-md-6">
                              <div class="form-group no-mt">
                                <div class="checkbox">
                                  <label>
                                    <input type="checkbox" id="remember-me" name="remember-me"/> Manter conectado </label>
                                </div>
                              </div>
                            </div>
                            <div class="col-md-6">
                              <button class="btn btn-raised btn-primary pull-right" type="submit">Entrar</button>
                            </div>
                          </div>
                        </fieldset>
                      </form>

这是我的WebSecurityConfig.java

@Configuration
@EnableWebSecurity
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {

    @Autowired
    public AuthenticationProviderConfig authenticationProviderConfig;

    @Autowired
    public Encrypt encrypt;

    @Autowired
    CustomSuccessHandler customSuccessHandler;

    @Autowired
    public void configAuthentication(AuthenticationManagerBuilder auth) throws Exception {

        auth.userDetailsService(authenticationProviderConfig.userDetailsService())
                .passwordEncoder(encrypt.passwordEncoder());
    }

    @Override
    protected void configure(HttpSecurity http) throws Exception {

        http.authorizeRequests()
        .antMatchers("/").permitAll()
        .antMatchers("/panel").access("hasRole('USER')")
        .anyRequest().authenticated();

    http.formLogin()
        .loginPage("/")
        .failureUrl("/login?error=fail")
        .successHandler(customSuccessHandler)
        .usernameParameter("username")
        .passwordParameter("password")
        .permitAll()
        .and()
    .sessionManagement()
        .maximumSessions(1)
        .expiredUrl("/login?expired")
        .sessionRegistry(sessionRegistry())
        .and().and().csrf().disable()
    .logout()
        .logoutUrl("/logout")
        .logoutSuccessUrl("/login?logout")
        .invalidateHttpSession(true)
        .permitAll()
        .and()
    .rememberMe()
        .tokenValiditySeconds(1209600)
        .and();

    }

    @Override
    public void configure(WebSecurity web) throws Exception {
        web.ignoring()
           .antMatchers("/assets/**", "/js/**", "/css/**", "/img/**", "/fonts/**","/font-awesome/**","/");
    }


    @Bean(name = "sessionRegistry")
    public SessionRegistry sessionRegistry() {
        return new SessionRegistryImpl();
    }
}

这是我的AuthenticationProviderConfig.java

package blowmind.Configs;


@Configuration
public class AuthenticationProviderConfig {

    @Autowired
    private DatabaseConfig databaseConfig;

    @Autowired
    public UserDetailsService userDetailsService() {
        JdbcDaoImpl jdbcImpl = new JdbcDaoImpl();
        jdbcImpl.setDataSource(databaseConfig.dataSource());

        jdbcImpl.setUsersByUsernameQuery("SELECT email as username, password, confirmed as enabled, CONCAT(SUBSTRING_INDEX(name, ' ', 1),' ',SUBSTRING_INDEX(name, ' ', -1)) AS name FROM users where email=?");
        jdbcImpl.setAuthoritiesByUsernameQuery("SELECT email as username, role FROM users where email=?");

        return jdbcImpl;
    }

}

和CustomSuccessHandler.java

@Component
public class CustomSuccessHandler extends SimpleUrlAuthenticationSuccessHandler {

    private RedirectStrategy redirectStrategy = new DefaultRedirectStrategy();

    @Override
    protected void handle(HttpServletRequest request, HttpServletResponse response, Authentication authentication)
            throws IOException {
        String targetUrl = determineTargetUrl(authentication);

        if (response.isCommitted()) {
            System.out.println("Can't redirect");
            return;
        }

        redirectStrategy.sendRedirect(request, response, targetUrl);
    }


    protected String determineTargetUrl(Authentication authentication) {
        String url = "";

        Collection<? extends GrantedAuthority> authorities = authentication.getAuthorities();

        List<String> roles = new ArrayList<String>();

        for (GrantedAuthority a : authorities) {
            roles.add(a.getAuthority());
        }

        if (isUser(roles)) {
            url = "/panel";
        } else if (isAdmin(roles)) {
            url = "/adminPanel";
        } else {
            url = "/accessDenied";
        }

        return url;
    }

    private boolean isAdmin(List<String> roles) {
        if (roles.contains("ROLE_ADMIN")) {
            return true;
        }
        return false;
    }

    private boolean isUser(List<String> roles) {
        if (roles.contains("ROLE_USER")) {
            return true;
        }
        return false;
    }

    public void setRedirectStrategy(RedirectStrategy redirectStrategy) {
        this.redirectStrategy = redirectStrategy;
    }

    protected RedirectStrategy getRedirectStrategy() {
        return redirectStrategy;
    }

}

最后数据库有一个表格如下:

电子邮件名称 tuliomartins@gmail.comTúlioMartins
密码角色 $ 2a $ 10 $ e5V5nh.uDVcmbYIw5p3EKepqziUa3jDEByOKaVmXbUwx9ohrHBQPu ROLE_USER

当我尝试登录时,我有错误:

2017-03-29 16:45:33.880 DEBUG 22281 --- [nio-8080-exec-6] o.s.security.web.FilterChainProxy        : /login at position 1 of 12 in additional filter chain; firing Filter: 'WebAsyncManagerIntegrationFilter'
2017-03-29 16:45:33.880 DEBUG 22281 --- [nio-8080-exec-6] o.s.security.web.FilterChainProxy        : /login at position 2 of 12 in additional filter chain; firing Filter: 'SecurityContextPersistenceFilter'
2017-03-29 16:45:33.880 DEBUG 22281 --- [nio-8080-exec-6] w.c.HttpSessionSecurityContextRepository : No HttpSession currently exists
2017-03-29 16:45:33.880 DEBUG 22281 --- [nio-8080-exec-6] w.c.HttpSessionSecurityContextRepository : No SecurityContext was available from the HttpSession: null. A new one will be created.
2017-03-29 16:45:33.880 DEBUG 22281 --- [nio-8080-exec-6] o.s.security.web.FilterChainProxy        : /login at position 3 of 12 in additional filter chain; firing Filter: 'HeaderWriterFilter'
2017-03-29 16:45:33.880 DEBUG 22281 --- [nio-8080-exec-6] o.s.s.w.header.writers.HstsHeaderWriter  : Not injecting HSTS header since it did not match the requestMatcher org.springframework.security.web.header.writers.HstsHeaderWriter$SecureRequestMatcher@683603ff
2017-03-29 16:45:33.880 DEBUG 22281 --- [nio-8080-exec-6] o.s.security.web.FilterChainProxy        : /login at position 4 of 12 in additional filter chain; firing Filter: 'LogoutFilter'
2017-03-29 16:45:33.880 DEBUG 22281 --- [nio-8080-exec-6] o.s.s.web.util.matcher.OrRequestMatcher  : Trying to match using Ant [pattern='/logout', GET]
2017-03-29 16:45:33.883 DEBUG 22281 --- [nio-8080-exec-6] o.s.s.w.u.matcher.AntPathRequestMatcher  : Request 'POST /login' doesn't match 'GET /logout
2017-03-29 16:45:33.883 DEBUG 22281 --- [nio-8080-exec-6] o.s.s.web.util.matcher.OrRequestMatcher  : Trying to match using Ant [pattern='/logout', POST]
2017-03-29 16:45:33.883 DEBUG 22281 --- [nio-8080-exec-6] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/login'; against '/logout'
2017-03-29 16:45:33.883 DEBUG 22281 --- [nio-8080-exec-6] o.s.s.web.util.matcher.OrRequestMatcher  : Trying to match using Ant [pattern='/logout', PUT]
2017-03-29 16:45:33.883 DEBUG 22281 --- [nio-8080-exec-6] o.s.s.w.u.matcher.AntPathRequestMatcher  : Request 'POST /login' doesn't match 'PUT /logout
2017-03-29 16:45:33.883 DEBUG 22281 --- [nio-8080-exec-6] o.s.s.web.util.matcher.OrRequestMatcher  : Trying to match using Ant [pattern='/logout', DELETE]
2017-03-29 16:45:33.883 DEBUG 22281 --- [nio-8080-exec-6] o.s.s.w.u.matcher.AntPathRequestMatcher  : Request 'POST /login' doesn't match 'DELETE /logout
2017-03-29 16:45:33.884 DEBUG 22281 --- [nio-8080-exec-6] o.s.s.web.util.matcher.OrRequestMatcher  : No matches found
2017-03-29 16:45:33.884 DEBUG 22281 --- [nio-8080-exec-6] o.s.security.web.FilterChainProxy        : /login at position 5 of 12 in additional filter chain; firing Filter: 'UsernamePasswordAuthenticationFilter'
2017-03-29 16:45:33.884 DEBUG 22281 --- [nio-8080-exec-6] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/login'; against '/login'
2017-03-29 16:45:33.884 DEBUG 22281 --- [nio-8080-exec-6] w.a.UsernamePasswordAuthenticationFilter : Request is to process authentication
2017-03-29 16:45:33.884 DEBUG 22281 --- [nio-8080-exec-6] o.s.s.authentication.ProviderManager     : Authentication attempt using org.springframework.security.authentication.dao.DaoAuthenticationProvider
2017-03-29 16:45:34.069 DEBUG 22281 --- [nio-8080-exec-6] s.CompositeSessionAuthenticationStrategy : Delegating to org.springframework.security.web.authentication.session.ConcurrentSessionControlAuthenticationStrategy@7a06ac3a
2017-03-29 16:45:34.070 DEBUG 22281 --- [nio-8080-exec-6] s.CompositeSessionAuthenticationStrategy : Delegating to org.springframework.security.web.authentication.session.ChangeSessionIdAuthenticationStrategy@9929cd2
2017-03-29 16:45:34.070 DEBUG 22281 --- [nio-8080-exec-6] s.CompositeSessionAuthenticationStrategy : Delegating to org.springframework.security.web.authentication.session.RegisterSessionAuthenticationStrategy@5db30482
2017-03-29 16:45:34.113 DEBUG 22281 --- [nio-8080-exec-6] o.s.s.core.session.SessionRegistryImpl   : Registering session 87AB2C996D332C4F446696526922BCC8, for principal org.springframework.security.core.userdetails.User@efbd50f8: Username: tuliomartins@gmail.com; Password: [PROTECTED]; Enabled: true; AccountNonExpired: true; credentialsNonExpired: true; AccountNonLocked: true; Granted Authorities: ROLE_USER
2017-03-29 16:45:34.113 DEBUG 22281 --- [nio-8080-exec-6] w.a.UsernamePasswordAuthenticationFilter : Authentication success. Updating SecurityContextHolder to contain: org.springframework.security.authentication.UsernamePasswordAuthenticationToken@aba0e1ac: Principal: org.springframework.security.core.userdetails.User@efbd50f8: Username: tuliomartins@gmail.com; Password: [PROTECTED]; Enabled: true; AccountNonExpired: true; credentialsNonExpired: true; AccountNonLocked: true; Granted Authorities: ROLE_USER; Credentials: [PROTECTED]; Authenticated: true; Details: org.springframework.security.web.authentication.WebAuthenticationDetails@b364: RemoteIpAddress: 0:0:0:0:0:0:0:1; SessionId: null; Granted Authorities: ROLE_USER
2017-03-29 16:45:34.119 DEBUG 22281 --- [nio-8080-exec-6] o.s.s.web.DefaultRedirectStrategy        : Redirecting to '/panel'
2017-03-29 16:45:34.121 DEBUG 22281 --- [nio-8080-exec-6] w.c.HttpSessionSecurityContextRepository : SecurityContext 'org.springframework.security.core.context.SecurityContextImpl@aba0e1ac: Authentication: org.springframework.security.authentication.UsernamePasswordAuthenticationToken@aba0e1ac: Principal: org.springframework.security.core.userdetails.User@efbd50f8: Username: tuliomartins@gmail.com; Password: [PROTECTED]; Enabled: true; AccountNonExpired: true; credentialsNonExpired: true; AccountNonLocked: true; Granted Authorities: ROLE_USER; Credentials: [PROTECTED]; Authenticated: true; Details: org.springframework.security.web.authentication.WebAuthenticationDetails@b364: RemoteIpAddress: 0:0:0:0:0:0:0:1; SessionId: null; Granted Authorities: ROLE_USER' stored to HttpSession: 'org.apache.catalina.session.StandardSessionFacade@348c2e31
2017-03-29 16:45:34.122 DEBUG 22281 --- [nio-8080-exec-6] s.s.w.c.SecurityContextPersistenceFilter : SecurityContextHolder now cleared, as request processing completed
2017-03-29 16:45:34.131 DEBUG 22281 --- [nio-8080-exec-6] o.s.security.web.FilterChainProxy        : /panel at position 1 of 12 in additional filter chain; firing Filter: 'WebAsyncManagerIntegrationFilter'
2017-03-29 16:45:34.131 DEBUG 22281 --- [nio-8080-exec-6] o.s.security.web.FilterChainProxy        : /panel at position 2 of 12 in additional filter chain; firing Filter: 'SecurityContextPersistenceFilter'
2017-03-29 16:45:34.131 DEBUG 22281 --- [nio-8080-exec-6] w.c.HttpSessionSecurityContextRepository : No HttpSession currently exists
2017-03-29 16:45:34.131 DEBUG 22281 --- [nio-8080-exec-6] w.c.HttpSessionSecurityContextRepository : No SecurityContext was available from the HttpSession: null. A new one will be created.
2017-03-29 16:45:34.131 DEBUG 22281 --- [nio-8080-exec-6] o.s.security.web.FilterChainProxy        : /panel at position 3 of 12 in additional filter chain; firing Filter: 'HeaderWriterFilter'
2017-03-29 16:45:34.132 DEBUG 22281 --- [nio-8080-exec-6] o.s.s.w.header.writers.HstsHeaderWriter  : Not injecting HSTS header since it did not match the requestMatcher org.springframework.security.web.header.writers.HstsHeaderWriter$SecureRequestMatcher@683603ff
2017-03-29 16:45:34.132 DEBUG 22281 --- [nio-8080-exec-6] o.s.security.web.FilterChainProxy        : /panel at position 4 of 12 in additional filter chain; firing Filter: 'LogoutFilter'
2017-03-29 16:45:34.132 DEBUG 22281 --- [nio-8080-exec-6] o.s.s.web.util.matcher.OrRequestMatcher  : Trying to match using Ant [pattern='/logout', GET]
2017-03-29 16:45:34.132 DEBUG 22281 --- [nio-8080-exec-6] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/panel'; against '/logout'
2017-03-29 16:45:34.132 DEBUG 22281 --- [nio-8080-exec-6] o.s.s.web.util.matcher.OrRequestMatcher  : Trying to match using Ant [pattern='/logout', POST]
2017-03-29 16:45:34.132 DEBUG 22281 --- [nio-8080-exec-6] o.s.s.w.u.matcher.AntPathRequestMatcher  : Request 'GET /panel' doesn't match 'POST /logout
2017-03-29 16:45:34.132 DEBUG 22281 --- [nio-8080-exec-6] o.s.s.web.util.matcher.OrRequestMatcher  : Trying to match using Ant [pattern='/logout', PUT]
2017-03-29 16:45:34.132 DEBUG 22281 --- [nio-8080-exec-6] o.s.s.w.u.matcher.AntPathRequestMatcher  : Request 'GET /panel' doesn't match 'PUT /logout
2017-03-29 16:45:34.132 DEBUG 22281 --- [nio-8080-exec-6] o.s.s.web.util.matcher.OrRequestMatcher  : Trying to match using Ant [pattern='/logout', DELETE]
2017-03-29 16:45:34.132 DEBUG 22281 --- [nio-8080-exec-6] o.s.s.w.u.matcher.AntPathRequestMatcher  : Request 'GET /panel' doesn't match 'DELETE /logout
2017-03-29 16:45:34.132 DEBUG 22281 --- [nio-8080-exec-6] o.s.s.web.util.matcher.OrRequestMatcher  : No matches found
2017-03-29 16:45:34.132 DEBUG 22281 --- [nio-8080-exec-6] o.s.security.web.FilterChainProxy        : /panel at position 5 of 12 in additional filter chain; firing Filter: 'UsernamePasswordAuthenticationFilter'
2017-03-29 16:45:34.132 DEBUG 22281 --- [nio-8080-exec-6] o.s.s.w.u.matcher.AntPathRequestMatcher  : Request 'GET /panel' doesn't match 'POST /login
2017-03-29 16:45:34.132 DEBUG 22281 --- [nio-8080-exec-6] o.s.security.web.FilterChainProxy        : /panel at position 6 of 12 in additional filter chain; firing Filter: 'ConcurrentSessionFilter'
2017-03-29 16:45:34.132 DEBUG 22281 --- [nio-8080-exec-6] o.s.security.web.FilterChainProxy        : /panel at position 7 of 12 in additional filter chain; firing Filter: 'RequestCacheAwareFilter'
2017-03-29 16:45:34.132 DEBUG 22281 --- [nio-8080-exec-6] o.s.security.web.FilterChainProxy        : /panel at position 8 of 12 in additional filter chain; firing Filter: 'SecurityContextHolderAwareRequestFilter'
2017-03-29 16:45:34.132 DEBUG 22281 --- [nio-8080-exec-6] o.s.security.web.FilterChainProxy        : /panel at position 9 of 12 in additional filter chain; firing Filter: 'AnonymousAuthenticationFilter'
2017-03-29 16:45:34.132 DEBUG 22281 --- [nio-8080-exec-6] o.s.s.w.a.AnonymousAuthenticationFilter  : Populated SecurityContextHolder with anonymous token: 'org.springframework.security.authentication.AnonymousAuthenticationToken@9055c2bc: Principal: anonymousUser; Credentials: [PROTECTED]; Authenticated: true; Details: org.springframework.security.web.authentication.WebAuthenticationDetails@b364: RemoteIpAddress: 0:0:0:0:0:0:0:1; SessionId: null; Granted Authorities: ROLE_ANONYMOUS'
2017-03-29 16:45:34.133 DEBUG 22281 --- [nio-8080-exec-6] o.s.security.web.FilterChainProxy        : /panel at position 10 of 12 in additional filter chain; firing Filter: 'SessionManagementFilter'
2017-03-29 16:45:34.133 DEBUG 22281 --- [nio-8080-exec-6] o.s.security.web.FilterChainProxy        : /panel at position 11 of 12 in additional filter chain; firing Filter: 'ExceptionTranslationFilter'
2017-03-29 16:45:34.133 DEBUG 22281 --- [nio-8080-exec-6] o.s.security.web.FilterChainProxy        : /panel at position 12 of 12 in additional filter chain; firing Filter: 'FilterSecurityInterceptor'
2017-03-29 16:45:34.133 DEBUG 22281 --- [nio-8080-exec-6] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/panel'; against '/js/**'
2017-03-29 16:45:34.133 DEBUG 22281 --- [nio-8080-exec-6] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/panel'; against '/css/**'
2017-03-29 16:45:34.133 DEBUG 22281 --- [nio-8080-exec-6] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/panel'; against '/assets/**'
2017-03-29 16:45:34.133 DEBUG 22281 --- [nio-8080-exec-6] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/panel'; against '/fonts/**'
2017-03-29 16:45:34.133 DEBUG 22281 --- [nio-8080-exec-6] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/panel'; against '/img/**'
2017-03-29 16:45:34.133 DEBUG 22281 --- [nio-8080-exec-6] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/panel'; against '/less/**'
2017-03-29 16:45:34.133 DEBUG 22281 --- [nio-8080-exec-6] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/panel'; against '/'
2017-03-29 16:45:34.133 DEBUG 22281 --- [nio-8080-exec-6] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/panel'; against '/beAModel'
2017-03-29 16:45:34.133 DEBUG 22281 --- [nio-8080-exec-6] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/panel'; against 'login'
2017-03-29 16:45:34.133 DEBUG 22281 --- [nio-8080-exec-6] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/panel'; against '/signIn'
2017-03-29 16:45:34.133 DEBUG 22281 --- [nio-8080-exec-6] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/panel'; against '/signInConfirm'
2017-03-29 16:45:34.133 DEBUG 22281 --- [nio-8080-exec-6] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/panel'; against '/signInComplete'
2017-03-29 16:45:34.133 DEBUG 22281 --- [nio-8080-exec-6] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/panel'; against '/signInFoto'
2017-03-29 16:45:34.133 DEBUG 22281 --- [nio-8080-exec-6] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/panel'; against '/acquireCredits'
2017-03-29 16:45:34.133 DEBUG 22281 --- [nio-8080-exec-6] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/panel'; against '/getSession'
2017-03-29 16:45:34.133 DEBUG 22281 --- [nio-8080-exec-6] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/panel'; against '/search'
2017-03-29 16:45:34.133 DEBUG 22281 --- [nio-8080-exec-6] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/panel'; against '/dat'
2017-03-29 16:45:34.133 DEBUG 22281 --- [nio-8080-exec-6] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/panel'; against '/panel'
2017-03-29 16:45:34.133 DEBUG 22281 --- [nio-8080-exec-6] o.s.s.w.a.i.FilterSecurityInterceptor    : Secure object: FilterInvocation: URL: /panel; Attributes: [hasRole('USER')]
2017-03-29 16:45:34.133 DEBUG 22281 --- [nio-8080-exec-6] o.s.s.w.a.i.FilterSecurityInterceptor    : Previously Authenticated: org.springframework.security.authentication.AnonymousAuthenticationToken@9055c2bc: Principal: anonymousUser; Credentials: [PROTECTED]; Authenticated: true; Details: org.springframework.security.web.authentication.WebAuthenticationDetails@b364: RemoteIpAddress: 0:0:0:0:0:0:0:1; SessionId: null; Granted Authorities: ROLE_ANONYMOUS
2017-03-29 16:45:34.134 DEBUG 22281 --- [nio-8080-exec-6] o.s.s.access.vote.AffirmativeBased       : Voter: org.springframework.security.web.access.expression.WebExpressionVoter@2f205ccc, returned: -1
2017-03-29 16:45:34.153 DEBUG 22281 --- [nio-8080-exec-6] o.s.s.w.a.ExceptionTranslationFilter     : Access is denied (user is anonymous); redirecting to authentication entry point

org.springframework.security.access.AccessDeniedException: Access is denied
    at org.springframework.security.access.vote.AffirmativeBased.decide(AffirmativeBased.java:84) ~[spring-security-core-4.2.2.RELEASE.jar:4.2.2.RELEASE]
    at org.springframework.security.access.intercept.AbstractSecurityInterceptor.beforeInvocation(AbstractSecurityInterceptor.java:233) ~[spring-security-core-4.2.2.RELEASE.jar:4.2.2.RELEASE]
    at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:124) ~[spring-security-web-4.2.2.RELEASE.jar:4.2.2.RELEASE]
    at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:91) ~[spring-security-web-4.2.2.RELEASE.jar:4.2.2.RELEASE]
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331) [spring-security-web-4.2.2.RELEASE.jar:4.2.2.RELEASE]
    at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:114) ~[spring-security-web-4.2.2.RELEASE.jar:4.2.2.RELEASE]
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331) [spring-security-web-4.2.2.RELEASE.jar:4.2.2.RELEASE]
    at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:137) [spring-security-web-4.2.2.RELEASE.jar:4.2.2.RELEASE]
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331) [spring-security-web-4.2.2.RELEASE.jar:4.2.2.RELEASE]
    at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:111) [spring-security-web-4.2.2.RELEASE.jar:4.2.2.RELEASE]
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331) [spring-security-web-4.2.2.RELEASE.jar:4.2.2.RELEASE]
    at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:170) [spring-security-web-4.2.2.RELEASE.jar:4.2.2.RELEASE]
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331) [spring-security-web-4.2.2.RELEASE.jar:4.2.2.RELEASE]
    at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:63) [spring-security-web-4.2.2.RELEASE.jar:4.2.2.RELEASE]
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331) [spring-security-web-4.2.2.RELEASE.jar:4.2.2.RELEASE]
    at org.springframework.security.web.session.ConcurrentSessionFilter.doFilter(ConcurrentSessionFilter.java:155) [spring-security-web-4.2.2.RELEASE.jar:4.2.2.RELEASE]
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331) [spring-security-web-4.2.2.RELEASE.jar:4.2.2.RELEASE]
    at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:200) [spring-security-web-4.2.2.RELEASE.jar:4.2.2.RELEASE]
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331) [spring-security-web-4.2.2.RELEASE.jar:4.2.2.RELEASE]
    at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:116) [spring-security-web-4.2.2.RELEASE.jar:4.2.2.RELEASE]
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331) [spring-security-web-4.2.2.RELEASE.jar:4.2.2.RELEASE]
    at org.springframework.security.web.header.HeaderWriterFilter.doFilterInternal(HeaderWriterFilter.java:64) [spring-security-web-4.2.2.RELEASE.jar:4.2.2.RELEASE]
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) [spring-web-4.3.7.RELEASE.jar:4.3.7.RELEASE]
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331) [spring-security-web-4.2.2.RELEASE.jar:4.2.2.RELEASE]
    at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:105) [spring-security-web-4.2.2.RELEASE.jar:4.2.2.RELEASE]
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331) [spring-security-web-4.2.2.RELEASE.jar:4.2.2.RELEASE]
    at org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:56) [spring-security-web-4.2.2.RELEASE.jar:4.2.2.RELEASE]
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) [spring-web-4.3.7.RELEASE.jar:4.3.7.RELEASE]
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331) [spring-security-web-4.2.2.RELEASE.jar:4.2.2.RELEASE]
    at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:214) [spring-security-web-4.2.2.RELEASE.jar:4.2.2.RELEASE]
    at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:177) [spring-security-web-4.2.2.RELEASE.jar:4.2.2.RELEASE]
    at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:346) [spring-web-4.3.7.RELEASE.jar:4.3.7.RELEASE]
    at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:262) [spring-web-4.3.7.RELEASE.jar:4.3.7.RELEASE]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192) [tomcat-embed-core-8.5.11.jar:8.5.11]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165) [tomcat-embed-core-8.5.11.jar:8.5.11]
    at 

我真的看不出问题为什么会发生,我需要解决它,希望有人可以帮助我! TKS ...

0 个答案:

没有答案