1
我被困在这里的一个问题。我正在为我的应用程序使用primefaces的弹簧引导。我正在使用spring安全进行身份验证。不知何故,我得到访问被拒绝。除此之外,用户已经在mongodb中建立起来了,如果我使用spring重定向,那么一切都很好。春季安全春季启动4.x
http.csrf().csrfTokenRepository(csrfTokenRepository()).and().authorizeRequests().antMatchers("/login**").access("permitAll")
.antMatchers("/logout**").access("permitAll")
.antMatchers("/secure/homePage.xhtml").access("hasRole('ADMIN') or hasRole('USER')")
.anyRequest().authenticated().and().formLogin().loginPage("/login").defaultSuccessUrl("/secure/homePage.xhtml")
.failureUrl("/login.xhtml?error").usernameParameter("email").and().logout().logoutUrl("/logout.xhtml")
.logoutSuccessUrl("/login.xhtml").invalidateHttpSession(true).clearAuthentication(true).and()
.exceptionHandling().accessDeniedPage("/accessDenied.xhtml");
顺便说一句,我有我的登录页面如下:
<input type="hidden" name="${_csrf.parameterName}" value="${_csrf.token}"/>
假设参考这个[示例](https://github.com/spring-projects/spring-boot/tree/master/spring -boot-samples/spring-boot-sample-web-method-security)在github上的项目。他们可能有一个解决方案。 –