dengsixing 3 vuotta sitten
vanhempi
commit
81f410a69a

+ 0 - 23
4dkankan-center-auth/pom.xml

@@ -59,29 +59,6 @@
 			<groupId>com.alibaba.cloud</groupId>
 			<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
 		</dependency>
-
-<!--		<dependency>-->
-<!--			<groupId>org.springframework.boot</groupId>-->
-<!--			<artifactId>spring-boot-starter-security</artifactId>-->
-<!--		</dependency>-->
-
-<!--		<dependency>-->
-<!--			<groupId>org.springframework.security</groupId>-->
-<!--			<artifactId>spring-security-jwt</artifactId>-->
-<!--			<version>1.1.1.RELEASE</version>-->
-<!--		</dependency>-->
-
-<!--		<dependency>-->
-<!--			<groupId>org.springframework.security.oauth</groupId>-->
-<!--			<artifactId>spring-security-oauth2</artifactId>-->
-<!--			<version>2.3.6.RELEASE</version>-->
-<!--		</dependency>-->
-
-		<dependency>
-			<groupId>com.auth0</groupId>
-			<artifactId>java-jwt</artifactId>
-		</dependency>
-
 	</dependencies>
 
 	<build>

+ 0 - 88
4dkankan-center-auth/src/main/java/com/fdkankan/auth/config/AuthorizationJwtServerConfig.java

@@ -1,88 +0,0 @@
-package com.fdkankan.auth.config;
-
-import javax.annotation.Resource;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.data.redis.connection.RedisConnectionFactory;
-import org.springframework.security.authentication.AuthenticationManager;
-import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
-import org.springframework.security.oauth2.config.annotation.configurers.ClientDetailsServiceConfigurer;
-import org.springframework.security.oauth2.config.annotation.web.configuration.AuthorizationServerConfigurerAdapter;
-import org.springframework.security.oauth2.config.annotation.web.configuration.EnableAuthorizationServer;
-import org.springframework.security.oauth2.config.annotation.web.configurers.AuthorizationServerEndpointsConfigurer;
-import org.springframework.security.oauth2.provider.token.TokenStore;
-import org.springframework.security.oauth2.provider.token.store.JwtAccessTokenConverter;
-import org.springframework.security.oauth2.provider.token.store.JwtTokenStore;
-import org.springframework.security.oauth2.provider.token.store.redis.RedisTokenStore;
-
-/**
- * <p>
- * TODO
- * </p>
- *
- * @author dengsixing
- * @since 2022/4/2
- **/
-@Configuration
-@EnableAuthorizationServer
-public class AuthorizationJwtServerConfig extends AuthorizationServerConfigurerAdapter {
-    @Resource
-    private RedisConnectionFactory redisConnectionFactory;
-
-    @Resource
-    private AuthenticationManager authenticationManager;
-
-    @Bean
-    public TokenStore tokenStore() {
-//        return new RedisTokenStore(redisConnectionFactory);
-        return new JwtTokenStore(jwtAccessTokenConverter());
-    }
-
-    /**
-     * jwt token转换器
-     * @return
-     */
-    @Bean
-    public JwtAccessTokenConverter jwtAccessTokenConverter() {
-        JwtAccessTokenConverter jwtAccessTokenConverter = new JwtAccessTokenConverter();
-        // 签名
-        jwtAccessTokenConverter.setSigningKey("test");
-        return jwtAccessTokenConverter;
-    }
-
-
-
-    /**
-     * 暴露授权服务
-     * @param endpoints
-     * @throws Exception
-     */
-    @Override
-    public void configure(AuthorizationServerEndpointsConfigurer endpoints) throws Exception {
-//        endpoints.tokenStore(tokenStore())
-//        //下面这句是密码模式需要用到的
-//        .authenticationManager(authenticationManager);
-
-        endpoints.accessTokenConverter(jwtAccessTokenConverter());
-    }
-
-//    @Override
-//    public void configure(ClientDetailsServiceConfigurer clients) throws Exception {
-//        clients.inMemory()
-//            // 第三方应用客户端id,相当于账号,可自定义
-//            .withClient("web")
-//            // 第三方应用密码,需要加密,相当于密码,可自定义
-//            .secret(new BCryptPasswordEncoder().encode("web"))
-//            // 第三方作用域,自定义
-//            .scopes("read")
-//            // 授权类型,使用code码
-////            .authorizedGrantTypes("authorization_code")
-//            //密码授权
-//            .authorizedGrantTypes("password")
-////            .autoApprove(true)
-//            // 有效时间
-//            .accessTokenValiditySeconds(7200)
-//            // 重定向url,必须是公网地址,必须是https
-//            .redirectUris("https://www.baidu.com");
-//    }
-}

+ 0 - 173
4dkankan-center-auth/src/main/java/com/fdkankan/auth/config/WebSecurityConfig.java

@@ -1,173 +0,0 @@
-package com.fdkankan.auth.config;
-
-import com.alibaba.fastjson.JSON;
-import com.auth0.jwt.JWT;
-import com.auth0.jwt.algorithms.Algorithm;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fdkankan.auth.service.impl.UserDetailsServiceImpl;
-import com.fdkankan.common.constant.ErrorCode;
-import com.fdkankan.common.filter.JwtTokenFilter;
-import com.fdkankan.common.response.ResultData;
-import com.fdkankan.redis.util.RedisUtil;
-import java.io.PrintWriter;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
-import javax.annotation.Resource;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.security.authentication.AuthenticationManager;
-import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
-import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
-import org.springframework.security.config.annotation.web.builders.HttpSecurity;
-import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
-import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
-import org.springframework.security.core.GrantedAuthority;
-import org.springframework.security.core.userdetails.User;
-import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
-import org.springframework.security.web.authentication.AuthenticationFailureHandler;
-import org.springframework.security.web.authentication.AuthenticationSuccessHandler;
-import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;
-
-/**
- * <p>
- * TODO
- * </p>
- *
- * @author dengsixing
- * @since 2022/4/2
- **/
-@Configuration
-@EnableWebSecurity
-@EnableGlobalMethodSecurity(prePostEnabled = true) // 开启方法级别安全
-public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
-    @Resource
-    private UserDetailsServiceImpl userDetailsService;
-
-    @Autowired
-    private RedisUtil redisUtil;
-
-    @Resource
-    private JwtTokenFilter jwtTokenFilter;
-
-    @Bean
-    public BCryptPasswordEncoder bCryptPasswordEncoder() {
-        return new BCryptPasswordEncoder();
-    }
-
-    /**
-     * 一些简单的配置
-     */
-    @Override
-    protected void configure(HttpSecurity http) throws Exception {
-        http.addFilterBefore(jwtTokenFilter, UsernamePasswordAuthenticationFilter.class);
-
-        // 禁用session
-        http.sessionManagement().disable();
-        http.csrf().disable();
-        http.formLogin()
-            // 自定义登录成功后路径
-            .successHandler(authenticationSuccessHandler())
-            // 自定义登录路径
-            .failureHandler(authenticationFailureHandler());
-        // 可以匿名访问
-        http.authorizeRequests()
-            .antMatchers("/auth/login").anonymous()
-            .anyRequest().authenticated()
-        ;
-    }
-
-    @Override
-    protected void configure(AuthenticationManagerBuilder auth) throws Exception {
-        // 用户数据从数据库获取
-        auth.userDetailsService(userDetailsService);
-    }
-
-    /**
-     * 用密码模式授权认证管理器
-     * @return
-     * @throws Exception
-     */
-    @Bean
-    @Override
-    public AuthenticationManager authenticationManager() throws Exception{
-        return super.authenticationManager();
-    }
-
-
-    /**
-     * 登录成功处理器
-     */
-    @Bean
-    public AuthenticationSuccessHandler authenticationSuccessHandler() {
-        return ((httpServletRequest, httpServletResponse, authentication) -> {
-            httpServletResponse.setContentType("application/json;charset=utf-8");
-            User user = (User)authentication.getPrincipal();
-            // 用户名
-            String username = user.getUsername();
-            // 密码
-            String password = user.getPassword();
-            // 权限
-            Collection<GrantedAuthority> grantedAuthorities =  user.getAuthorities();
-            List<String> roleList = new ArrayList<>();
-            grantedAuthorities.forEach(grantedAuthority -> {
-                roleList.add(grantedAuthority.getAuthority());
-            });
-            String[] roles = new String[roleList.size()];
-            // 用jwt生成token
-            HashMap<String, Object> headMap = new HashMap<>(16);
-            // 使用的算法
-            headMap.put("alg", "HS256");
-            headMap.put("typ", "JWT");
-            Date nowDate = new Date();
-            // 过期时间可以自定义
-            Date expDate = new Date(nowDate.getTime() + 2 * 60 * 60 * 1000);
-            String jwt = JWT.create().withHeader(headMap)
-                .withIssuedAt(nowDate)
-                .withExpiresAt(expDate)
-                // 主题,自定义
-                .withSubject("demo")
-                .withClaim("username", username)
-                .withClaim("password", password)
-                .withArrayClaim("role", roleList.toArray(roles))
-                // 签名,自定义,同一个项目中签名是唯一
-                .sign(Algorithm.HMAC256("test"));
-            // 保存token到redis
-            redisUtil.set("token:" + jwt, JSON.toJSONString(user), 7200);
-            // 返回token
-            HashMap<String, Object> hashMap = new HashMap<>(16);
-            hashMap.put("username", username);
-            hashMap.put("create_time", nowDate);
-            hashMap.put("expires_time", expDate);
-            hashMap.put("access_token", jwt);
-            hashMap.put("type", "bearer");
-            ObjectMapper objectMapper = new ObjectMapper();
-            String s = objectMapper.writeValueAsString(hashMap);
-            PrintWriter printWriter = httpServletResponse.getWriter();
-            printWriter.write(s);
-            printWriter.flush();
-            printWriter.close();
-        });
-    }
-
-    /**
-     * 登录失败处理器
-     */
-    @Bean
-    public AuthenticationFailureHandler authenticationFailureHandler() {
-        return ((httpServletRequest, httpServletResponse, e) -> {
-            httpServletResponse.setCharacterEncoding("UTF-8");
-            ResultData error = ResultData.error(ErrorCode.PASSWORD_ERROR);
-            ObjectMapper objectMapper = new ObjectMapper();
-            String s = objectMapper.writeValueAsString(error);
-            PrintWriter printWriter = httpServletResponse.getWriter();
-            printWriter.write(s);
-            printWriter.flush();
-            printWriter.close();
-        });
-    }
-
-}

+ 0 - 35
4dkankan-center-auth/src/main/java/com/fdkankan/auth/controller/TestController.java

@@ -1,35 +0,0 @@
-package com.fdkankan.auth.controller;
-
-import com.fdkankan.common.response.ResultData;
-import org.springframework.security.access.prepost.PreAuthorize;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
-
-/**
- * <p>
- * TODO
- * </p>
- *
- * @author dengsixing
- * @since 2022/4/2
- **/
-@RestController
-@RequestMapping("/test")
-public class TestController {
-
-    @GetMapping("/hello")
-    public ResultData hello(){
-        return ResultData.ok("hello!");
-    }
-
-
-    @PreAuthorize("hasAuthority('test')")
-    @GetMapping("/test")
-    public ResultData test(){
-        return ResultData.ok("牛逼!");
-    }
-
-
-}

+ 0 - 78
4dkankan-center-auth/src/main/java/com/fdkankan/auth/filter/JwtTokenFilter.java

@@ -1,78 +0,0 @@
-package com.fdkankan.auth.filter;
-
-import cn.hutool.core.util.StrUtil;
-import com.alibaba.fastjson.JSON;
-import com.auth0.jwt.JWT;
-import com.auth0.jwt.JWTVerifier;
-import com.auth0.jwt.algorithms.Algorithm;
-import com.auth0.jwt.interfaces.DecodedJWT;
-import com.fdkankan.common.constant.ErrorCode;
-import com.fdkankan.common.response.ResultData;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-import javax.servlet.FilterChain;
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
-import org.springframework.security.core.authority.SimpleGrantedAuthority;
-import org.springframework.security.core.context.SecurityContextHolder;
-import org.springframework.web.filter.OncePerRequestFilter;
-
-/**
- * <p>
- * TODO
- * </p>
- *
- * @author dengsixing
- * @since 2022/4/6
- **/
-@Configuration
-public class JwtTokenFilter extends OncePerRequestFilter {
-
-    @Override
-    protected void doFilterInternal(
-        HttpServletRequest httpServletRequest,
-        HttpServletResponse httpServletResponse,
-        FilterChain filterChain) throws ServletException, IOException {
-
-        String path = httpServletRequest.getRequestURI();
-        String method = httpServletRequest.getMethod();
-        // 对于登录直接放行
-        if ("/auth/login".equals(path) && "POST".equals(method)) {
-            filterChain.doFilter(httpServletRequest, httpServletResponse);
-            return;
-        }
-        // 获取token并验证
-        String authorization = httpServletRequest.getHeader("Authorization");
-        if (!StrUtil.hasBlank(authorization)) {
-            String jwt = authorization.replaceAll("Bearer ", "");
-            // 创建一个token解析器(test作为jwt生成token的签名是自定义的,一般是作为配置固定值)
-            JWTVerifier jwtVerifier = JWT.require(Algorithm.HMAC256("test")).build();
-            DecodedJWT decodedJwt;
-            try {
-                decodedJwt = jwtVerifier.verify(jwt);
-            } catch (Exception e) {
-                httpServletResponse.getWriter().write("token验证失败");
-                return;
-            }
-            // 获取用户名,密码,角色权限
-            String username = decodedJwt.getClaim("username").asString();
-            String password = decodedJwt.getClaim("password").asString();
-            List<String> roles = decodedJwt.getClaim("role").asList(String.class);
-            List<SimpleGrantedAuthority> roleList = new ArrayList<>();
-            roles.forEach(role -> {
-                roleList.add(new SimpleGrantedAuthority(role));
-            });
-            UsernamePasswordAuthenticationToken usernamePasswordAuthenticationToken =
-                new UsernamePasswordAuthenticationToken(username, password, roleList);
-            SecurityContextHolder.getContext().setAuthentication(usernamePasswordAuthenticationToken);
-            filterChain.doFilter(httpServletRequest, httpServletResponse);
-            return;
-        }
-        httpServletResponse.setCharacterEncoding("UTF-8");
-        httpServletResponse.getWriter().write(JSON.toJSONString(ResultData.error(ErrorCode.TOKEN_NOT_FOUND)));
-    }
-}

+ 0 - 100
4dkankan-center-auth/src/main/java/com/fdkankan/auth/generate/AutoGenerate.java

@@ -1,100 +0,0 @@
-package com.fdkankan.auth.generate;
-
-import com.baomidou.mybatisplus.core.mapper.BaseMapper;
-import com.baomidou.mybatisplus.generator.FastAutoGenerator;
-import com.baomidou.mybatisplus.generator.config.OutputFile;
-import com.baomidou.mybatisplus.generator.config.rules.DateType;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-
-public class AutoGenerate {
-
-
-    public static void main(String[] args) {
-
-        System.out.println("相对路径指定到:"+ System.getProperty("user.dir"));
-
-
-        String path =System.getProperty("user.dir") + "\\4dkankan-center-auth";
-
-        generate(path,"auth", getTables(new String[]{
-                "t_account", "t_permission","t_role","t_role_permission","t_account_role"
-        }));
-
-//        generate(path,"goods", getTables(new String[]{
-//                        "t_camera","t_camera_detail","t_camera_out","t_camera_space","t_camera_version",
-//                        "t_company","t_goods","t_goods_sku","t_cart","t_goods_spec",
-//                        "t_goods_spec_value","t_goods_spu_spec","t_sn_code"
-//        }));
-//
-//        generate(path,"order", getTables(new String[]{
-//                        "t_increment_order","t_invoice","t_order","t_order_item",
-//                        "t_pre_sale","t_space_sdk","t_trade_log","t_commerce_order","t_download_order","t_expansion_order"
-//        }));
-//        generate(path,"order", getTables(new String[]{
-//                        "t_virtual_order"
-//        }));
-//
-//        generate(path,"user", getTables(new String[]{
-//                        "t_user","t_user_increment","t_manager","t_province","t_increment_type","t_intercom_message","t_receiver_info"
-//        }));
-    }
-
-    public static List<String> getTables(String [] tableNames){
-        return new ArrayList<>(Arrays.asList(tableNames));
-    }
-
-
-    public static void  generate(String path,String moduleName,  List<String> tables){
-        FastAutoGenerator.create("jdbc:mysql://192.168.0.47:13306/4dkankan-center-auth",
-                "root","4dkk2020cuikuan%")
-                .globalConfig(builder -> {
-                    builder.author("")               //作者
-                            .outputDir(path+"\\src\\main\\java")    //输出路径(写到java目录)
-                            //.enableSwagger()           //开启swagger
-                            .commentDate("yyyy-MM-dd")
-                            .dateType(DateType.ONLY_DATE)
-                            .fileOverride();            //开启覆盖之前生成的文件
-
-                })
-                .packageConfig(builder -> {
-                    builder.parent("com.fdkankan")
-                            .moduleName(moduleName)
-                            .entity("entity")
-                            .service("service")
-                            .serviceImpl("service.impl")
-                            .controller("controller")
-                            .mapper("mapper")
-                            .xml("test.mapper")
-                            .pathInfo(Collections.singletonMap(OutputFile.mapperXml,path+"\\src\\main\\resources\\mapper\\"+moduleName));
-                })
-                .strategyConfig(builder -> {
-                    builder.addInclude(tables)
-                            .addTablePrefix("t_")
-
-                            .serviceBuilder()
-                            .formatServiceFileName("I%sService")
-                            .formatServiceImplFileName("%sServiceImpl")
-
-                            .entityBuilder()
-                            .enableLombok()
-                            .logicDeleteColumnName("tb_status")
-                            .enableTableFieldAnnotation()
-//                            .superClass(BaseEntity.class)
-
-                            .controllerBuilder()
-                            .formatFileName("%sController")
-                            .enableRestStyle()
-
-                            .mapperBuilder()
-                            .superClass(BaseMapper.class)
-                            .formatMapperFileName("I%sMapper")
-                            .enableMapperAnnotation()
-                            .formatXmlFileName("%sMapper");
-                })
-                // .templateEngine(new FreemarkerTemplateEngine()) // 使用Freemarker引擎模板,默认的是Velocity引擎模板
-                .execute();
-    }
-}

+ 43 - 43
4dkankan-center-auth/src/main/java/com/fdkankan/auth/schedul/DeveloperSchedul.java

@@ -1,43 +1,43 @@
-//package com.fdkankan.auth.schedul;
-//
-//import com.alibaba.fastjson.JSON;
-//import com.fdkankan.auth.entity.TmDeveloper;
-//import com.fdkankan.auth.service.ITmDeveloperService;
-//import com.fdkankan.redis.constant.RedisKey;
-//import com.fdkankan.redis.util.RedisUtil;
-//import lombok.extern.slf4j.Slf4j;
-//import org.springframework.beans.factory.annotation.Autowired;
-//import org.springframework.scheduling.annotation.Scheduled;
-//import org.springframework.stereotype.Component;
-//
-//import java.util.List;
-//
-//@Component
-//@Slf4j
-//public class DeveloperSchedul {
-//
-//
-//    @Autowired
-//    private ITmDeveloperService tmDeveloperService;
-//
-//    @Autowired
-//    private RedisUtil redisUtil;
-//
-//
-//    /**
-//     * 加载开发者信息到缓存,上一次执行完毕后五分钟执行
-//     */
-//    @Scheduled(fixedDelay=300000)
-//    public void loadTmDeveloperToRedisCache(){
-//        log.info("-----从mysql中加载开发者信息表到redis缓存定时任务开始执行------");
-//        List<TmDeveloper> list = tmDeveloperService.list();
-//        list.stream().forEach(tmDeveloper -> {
-//            String key = String.format(RedisKey.TM_DEVELOPER, tmDeveloper.getAppId());
-//            redisUtil.set(key, JSON.toJSONString(tmDeveloper));
-//        });
-//        log.info("-----从mysql中加载开发者信息表到redis缓存定时任务执行结束------");
-//
-//
-//    }
-//
-//}
+package com.fdkankan.auth.schedul;
+
+import com.alibaba.fastjson.JSON;
+import com.fdkankan.auth.entity.TmDeveloper;
+import com.fdkankan.auth.service.ITmDeveloperService;
+import com.fdkankan.redis.constant.RedisKey;
+import com.fdkankan.redis.util.RedisUtil;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.scheduling.annotation.Scheduled;
+import org.springframework.stereotype.Component;
+
+import java.util.List;
+
+@Component
+@Slf4j
+public class DeveloperSchedul {
+
+
+    @Autowired
+    private ITmDeveloperService tmDeveloperService;
+
+    @Autowired
+    private RedisUtil redisUtil;
+
+
+    /**
+     * 加载开发者信息到缓存,上一次执行完毕后五分钟执行
+     */
+    @Scheduled(fixedDelay=300000)
+    public void loadTmDeveloperToRedisCache(){
+        log.info("-----从mysql中加载开发者信息表到redis缓存定时任务开始执行------");
+        List<TmDeveloper> list = tmDeveloperService.list();
+        list.stream().forEach(tmDeveloper -> {
+            String key = String.format(RedisKey.TM_DEVELOPER, tmDeveloper.getAppId());
+            redisUtil.set(key, JSON.toJSONString(tmDeveloper));
+        });
+        log.info("-----从mysql中加载开发者信息表到redis缓存定时任务执行结束------");
+
+
+    }
+
+}

+ 0 - 49
4dkankan-center-auth/src/main/java/com/fdkankan/auth/service/impl/UserDetailsServiceImpl.java

@@ -1,49 +0,0 @@
-package com.fdkankan.auth.service.impl;
-
-import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
-import com.fdkankan.auth.entity.Account;
-import com.fdkankan.auth.mapper.IAccountMapper;
-import com.fdkankan.auth.service.IAccountService;
-import java.util.ArrayList;
-import java.util.List;
-import javax.annotation.Resource;
-import org.springframework.security.core.GrantedAuthority;
-import org.springframework.security.core.authority.SimpleGrantedAuthority;
-import org.springframework.security.core.userdetails.User;
-import org.springframework.security.core.userdetails.UserDetails;
-import org.springframework.security.core.userdetails.UserDetailsService;
-import org.springframework.security.core.userdetails.UsernameNotFoundException;
-import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
-import org.springframework.stereotype.Service;
-
-/**
- * <p>
- * TODO
- * </p>
- *
- * @author dengsixing
- * @since 2022/4/2
- **/
-@Service
-public class UserDetailsServiceImpl implements UserDetailsService {
-    @Resource
-    private BCryptPasswordEncoder bCryptPasswordEncoder;
-
-    @Resource
-    private IAccountService accountService;
-
-    @Override
-    public UserDetails loadUserByUsername(String s) throws UsernameNotFoundException {
-        /* 用户在登录时,会进入此方法(在配置类中进行配置),参数是用户名,这里使用了mybatisplus
-         * 做了一个简单的通过用户名查询用户,springsecurity会自动对密码进行匹配
-         */
-        Account account = accountService
-            .getOne(new LambdaQueryWrapper<Account>().eq(Account::getUserName, s));
-        String password = account.getPassword();
-        List<GrantedAuthority> userList = new ArrayList<>();
-        // userList是权限集合,这里也是做一个简单的权限添加
-        userList.add(new SimpleGrantedAuthority("add"));
-        // springsecurity5.0后密码需要加密一次,不然会报错
-        return new User("user", bCryptPasswordEncoder.encode(password), userList);
-    }
-}

+ 1 - 1
pom.xml

@@ -8,7 +8,7 @@
         <module>4dkankan-center-scene</module>
         <module>4dkankan-center-platform</module>
         <module>4dkankan-center-api</module>
-        <module>4dkankan-center-auth</module>
+<!--        <module>4dkankan-center-auth</module>-->
         <module>4dkankan-center-log</module>
         <module>4dkankan-center-modeling</module>
         <module>4dkankan-center-statistics</module>