• 怕什么抱紧我

    第三章 自定义认证与授权有问题的可以看下我的配置,和你的对比下;

    @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();
        }
    }
    
    怕什么抱紧我发表于 2020/4/14 0:06:48
  • 切yi

    30页的loginProcessingUrl(“/login”)这一段没有加permitAll();
    但我自定义认证后,返回的都是错登录失败,我的用户名和密码是正确的。
    我也不知道这返回的对不对

    切yi发表于 2020/2/22 22:25:00
  • 刘子文

    真的时日了狗了,作者不是程序员或者从事it相关行业的人吧?代码有错误也不放源码上去,这书基本废了。

    刘子文发表于 2020/2/21 16:09:28
    • 怕什么抱紧我

      你看到哪节了!

      怕什么抱紧我发表于 2020/4/13 23:46:10
    • 刘子文

      @怕什么抱紧我 没看了,直接扔了。书不行,现在我看官方的demo了

      刘子文发表于 2020/11/8 11:29:57
  • huaiwen

    书里面很多内容没讲清楚,比较浮于表面,看目录是不错,但是很多地方没讲清楚,也没给代码,不好

    huaiwen发表于 2020/1/1 22:43:48
  • 一二三

    作者你好,书的第四部分在securityconfiguration配置类中配置是不安全的,那么应该怎么安全地配置security配置呢?

    一二三发表于 2019/12/30 16:28:49
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • ...
  • 8