第三章 自定义认证与授权有问题的可以看下我的配置,和你的对比下;
@EnableWebSecurity public class WebSecurityConfig extends WebSecurityConfigurerAdapter { @Resource(name="myUserDetailsService") private UserDetailsService userDetailsService; /** * 配置授权 * @param http * @throws Exception */ @Override protected void configure(HttpSecurity http) throws Exception { http.authorizeRequests() .antMatchers("/admin/api/**").hasRole("ADMIN") .antMatchers("/user/api/**").hasRole("USER") .antMatchers("/app/api/**").permitAll() .anyRequest().authenticated() .and() .formLogin().permitAll() .and() .csrf().disable(); } /** * 配置认证 * @param auth * @throws Exception */ @Override protected void configure(AuthenticationManagerBuilder auth) throws Exception { //配置自己刚才注入的类 auth.userDetailsService(userDetailsService); } /** * 因为数据库的密码是明文,所以要配置不加解密的密码器; * @return */ @Bean public PasswordEncoder passwordEncoder(){ return NoOpPasswordEncoder.getInstance(); } }
30页的loginProcessingUrl(“/login”)这一段没有加permitAll();但我自定义认证后,返回的都是错登录失败,我的用户名和密码是正确的。我也不知道这返回的对不对
真的时日了狗了,作者不是程序员或者从事it相关行业的人吧?代码有错误也不放源码上去,这书基本废了。
你看到哪节了!
@怕什么抱紧我 没看了,直接扔了。书不行,现在我看官方的demo了
书里面很多内容没讲清楚,比较浮于表面,看目录是不错,但是很多地方没讲清楚,也没给代码,不好
作者你好,书的第四部分在securityconfiguration配置类中配置是不安全的,那么应该怎么安全地配置security配置呢?
第三章 自定义认证与授权有问题的可以看下我的配置,和你的对比下;
30页的loginProcessingUrl(“/login”)这一段没有加permitAll();
但我自定义认证后,返回的都是错登录失败,我的用户名和密码是正确的。
我也不知道这返回的对不对
真的时日了狗了,作者不是程序员或者从事it相关行业的人吧?代码有错误也不放源码上去,这书基本废了。
书里面很多内容没讲清楚,比较浮于表面,看目录是不错,但是很多地方没讲清楚,也没给代码,不好
作者你好,书的第四部分在securityconfiguration配置类中配置是不安全的,那么应该怎么安全地配置security配置呢?