还原子杰代码
This commit is contained in:
@@ -1,24 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
|
||||||
<parent>
|
|
||||||
<groupId>com.tashow.cloud</groupId>
|
|
||||||
<artifactId>tashow-module</artifactId>
|
|
||||||
<version>${revision}</version>
|
|
||||||
</parent>
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
|
||||||
<modules>
|
|
||||||
<module>tashow-module-sso-api</module>
|
|
||||||
<module>tashow-module-sso-biz</module>
|
|
||||||
</modules>
|
|
||||||
<artifactId>tashow-module-sso</artifactId>
|
|
||||||
<packaging>pom</packaging>
|
|
||||||
|
|
||||||
<name>${project.artifactId}</name>
|
|
||||||
<description>
|
|
||||||
system 模块下,我们放通用业务,支撑上层的核心业务。
|
|
||||||
例如说:用户、部门、权限、数据字典等等
|
|
||||||
</description>
|
|
||||||
|
|
||||||
</project>
|
|
||||||
@@ -1,48 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
|
||||||
<parent>
|
|
||||||
<groupId>com.tashow.cloud</groupId>
|
|
||||||
<artifactId>tashow-module-sso</artifactId>
|
|
||||||
<version>${revision}</version>
|
|
||||||
</parent>
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
|
||||||
<artifactId>tashow-module-sso-api</artifactId>
|
|
||||||
<packaging>jar</packaging>
|
|
||||||
|
|
||||||
<name>${project.artifactId}</name>
|
|
||||||
<description>
|
|
||||||
system 模块 API,暴露给其它模块调用
|
|
||||||
</description>
|
|
||||||
|
|
||||||
<dependencies>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.tashow.cloud</groupId>
|
|
||||||
<artifactId>tashow-common</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- Web 相关 -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springdoc</groupId> <!-- 接口文档:使用最新版本的 Swagger 模型 -->
|
|
||||||
<artifactId>springdoc-openapi-starter-webmvc-api</artifactId>
|
|
||||||
<scope>provided</scope>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- 参数校验 -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-starter-validation</artifactId>
|
|
||||||
<optional>true</optional>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- RPC 远程调用相关 -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.cloud</groupId>
|
|
||||||
<artifactId>spring-cloud-starter-openfeign</artifactId>
|
|
||||||
<optional>true</optional>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
</dependencies>
|
|
||||||
|
|
||||||
</project>
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
package com.tashow.cloud;
|
|
||||||
|
|
||||||
import org.springframework.boot.SpringApplication;
|
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
|
||||||
|
|
||||||
@SpringBootApplication
|
|
||||||
public class TashowModuleSsoApiApplication {
|
|
||||||
|
|
||||||
public static void main(String[] args) {
|
|
||||||
SpringApplication.run(TashowModuleSsoApiApplication.class, args);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,211 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
|
||||||
<parent>
|
|
||||||
<groupId>com.tashow.cloud</groupId>
|
|
||||||
<artifactId>tashow-module-sso</artifactId>
|
|
||||||
<version>${revision}</version>
|
|
||||||
</parent>
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
|
||||||
<artifactId>tashow-module-sso-biz</artifactId>
|
|
||||||
<packaging>jar</packaging>
|
|
||||||
|
|
||||||
<name>${project.artifactId}</name>
|
|
||||||
<description>
|
|
||||||
system 模块下,我们放通用业务,支撑上层的核心业务。
|
|
||||||
例如说:用户、部门、权限、数据字典等等
|
|
||||||
</description>
|
|
||||||
|
|
||||||
<dependencies>
|
|
||||||
<!-- Spring Cloud 基础 -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.tashow.cloud</groupId>
|
|
||||||
<artifactId>tashow-framework-env</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- 依赖服务 -->
|
|
||||||
<!-- <dependency>
|
|
||||||
<groupId>com.tashow.cloud</groupId>
|
|
||||||
<artifactId>tashow-module-system-api</artifactId>
|
|
||||||
<version>${revision}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.tashow.cloud</groupId>
|
|
||||||
<artifactId>tashow-module-infra-api</artifactId>
|
|
||||||
<version>${revision}</version>
|
|
||||||
</dependency>-->
|
|
||||||
|
|
||||||
<!-- 业务组件 -->
|
|
||||||
<!-- <dependency>-->
|
|
||||||
<!-- <groupId>com.tashow.cloud</groupId>-->
|
|
||||||
<!-- <artifactId>tashow-data-permission</artifactId>-->
|
|
||||||
<!-- </dependency>-->
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.tashow.cloud</groupId>
|
|
||||||
<artifactId>tashow-framework-tenant</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- Web 相关 -->
|
|
||||||
<!-- <dependency>-->
|
|
||||||
<!-- <groupId>com.tashow.cloud</groupId>-->
|
|
||||||
<!-- <artifactId>tashow-framework-security</artifactId>-->
|
|
||||||
<!-- </dependency>-->
|
|
||||||
|
|
||||||
<!-- DB 相关 -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.tashow.cloud</groupId>
|
|
||||||
<artifactId>tashow-data-mybatis</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.tashow.cloud</groupId>
|
|
||||||
<artifactId>tashow-data-redis</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- RPC 远程调用相关 -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.tashow.cloud</groupId>
|
|
||||||
<artifactId>tashow-framework-rpc</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- Registry 注册中心相关 -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.alibaba.cloud</groupId>
|
|
||||||
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- Config 配置中心相关 -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.alibaba.cloud</groupId>
|
|
||||||
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- Job 定时任务相关 -->
|
|
||||||
<!-- <dependency>
|
|
||||||
<groupId>com.tashow.cloud</groupId>
|
|
||||||
<artifactId>tashow-framework-job</artifactId>
|
|
||||||
</dependency>-->
|
|
||||||
|
|
||||||
<!-- 消息队列相关
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.tashow.cloud</groupId>
|
|
||||||
<artifactId>tashow-framework-mq</artifactId>
|
|
||||||
</dependency> -->
|
|
||||||
|
|
||||||
<!-- 服务保障相关 TODO 芋艿:暂时去掉 -->
|
|
||||||
<!-- <dependency>-->
|
|
||||||
<!-- <groupId>com.tashow.cloud</groupId>-->
|
|
||||||
<!-- <artifactId>yudao-spring-boot-starter-protection</artifactId>-->
|
|
||||||
<!-- </dependency>-->
|
|
||||||
|
|
||||||
<!-- 工具类相关 -->
|
|
||||||
<!-- <dependency>
|
|
||||||
<groupId>com.tashow.cloud</groupId>
|
|
||||||
<artifactId>tashow-data-excel</artifactId>
|
|
||||||
</dependency> -->
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-starter-mail</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- 监控相关 -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.tashow.cloud</groupId>
|
|
||||||
<artifactId>tashow-framework-monitor</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- 三方云服务相关 -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.xingyuv</groupId>
|
|
||||||
<artifactId>spring-boot-starter-justauth</artifactId> <!-- 社交登陆(例如说,个人微信、企业微信等等) -->
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.xingyuv</groupId>
|
|
||||||
<artifactId>spring-boot-starter-captcha-plus</artifactId> <!-- 验证码,一般用于登录使用 -->
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.dromara.hutool</groupId>
|
|
||||||
<artifactId>hutool-extra</artifactId> <!-- 邮件 -->
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
|
|
||||||
<!-- Sa-Token 权限认证(Reactor响应式集成),在线文档:https://sa-token.cc -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>cn.dev33</groupId>
|
|
||||||
<artifactId>sa-token-reactor-spring-boot3-starter</artifactId>
|
|
||||||
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>cn.dev33</groupId>
|
|
||||||
<artifactId>sa-token-spring-boot3-starter</artifactId>
|
|
||||||
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- Sa-Token 插件:整合SSO -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>cn.dev33</groupId>
|
|
||||||
<artifactId>sa-token-sso</artifactId>
|
|
||||||
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- Sa-Token OAuth2.0 模块 -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>cn.dev33</groupId>
|
|
||||||
<artifactId>sa-token-oauth2</artifactId>
|
|
||||||
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- Sa-Token 整合 Redis (使用 jackson 序列化方式) -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>cn.dev33</groupId>
|
|
||||||
<artifactId>sa-token-redis-jackson</artifactId>
|
|
||||||
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.dtflys.forest</groupId>
|
|
||||||
<artifactId>forest-spring-boot-starter</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.apache.commons</groupId>
|
|
||||||
<artifactId>commons-pool2</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>cn.dev33</groupId>
|
|
||||||
<artifactId>sa-token-alone-redis</artifactId>
|
|
||||||
<version>1.42.0</version>
|
|
||||||
</dependency>
|
|
||||||
<!-- 视图引擎(在前后端不分离模式下提供视图支持) -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-starter-thymeleaf</artifactId>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
|
|
||||||
<build>
|
|
||||||
<!-- 设置构建的 jar 包名 -->
|
|
||||||
<finalName>${project.artifactId}</finalName>
|
|
||||||
<plugins>
|
|
||||||
<!-- 打包 -->
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
|
||||||
<version>${spring.boot.version}</version>
|
|
||||||
<executions>
|
|
||||||
<execution>
|
|
||||||
<goals>
|
|
||||||
<goal>repackage</goal> <!-- 将引入的 jar 打入其中 -->
|
|
||||||
</goals>
|
|
||||||
</execution>
|
|
||||||
</executions>
|
|
||||||
</plugin>
|
|
||||||
</plugins>
|
|
||||||
</build>
|
|
||||||
|
|
||||||
</project>
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
package com.tashow.cloud;
|
|
||||||
|
|
||||||
import cn.dev33.satoken.oauth2.SaOAuth2Manager;
|
|
||||||
import org.springframework.boot.SpringApplication;
|
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
|
||||||
|
|
||||||
@SpringBootApplication
|
|
||||||
public class TashowModuleSsoBizApplication {
|
|
||||||
public static void main(String[] args) {
|
|
||||||
SpringApplication.run(TashowModuleSsoBizApplication.class, args);
|
|
||||||
System.out.println("Sa-Token-OAuth2 Server端启动成功,配置如下:");
|
|
||||||
System.out.println(SaOAuth2Manager.getServerConfig());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
package com.tashow.cloud.sso.config;
|
|
||||||
|
|
||||||
import org.springframework.context.annotation.Bean;
|
|
||||||
import org.springframework.context.annotation.Configuration;
|
|
||||||
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* SSO模块安全配置类
|
|
||||||
*/
|
|
||||||
@Configuration
|
|
||||||
public class SsoSecurityConfig {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 配置密码编码器
|
|
||||||
* 使用BCrypt强哈希算法
|
|
||||||
*/
|
|
||||||
@Bean
|
|
||||||
public BCryptPasswordEncoder passwordEncoder() {
|
|
||||||
return new BCryptPasswordEncoder();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,53 +0,0 @@
|
|||||||
package com.tashow.cloud.sso.controller;
|
|
||||||
import cn.dev33.satoken.sso.processor.SaSsoServerProcessor;
|
|
||||||
import cn.dev33.satoken.sso.template.SaSsoUtil;
|
|
||||||
import cn.dev33.satoken.stp.StpUtil;
|
|
||||||
import cn.dev33.satoken.util.SaResult;
|
|
||||||
import com.tashow.cloud.sso.model.SystemUser;
|
|
||||||
import com.tashow.cloud.sso.service.SystemUserService;
|
|
||||||
import jakarta.annotation.security.PermitAll;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.web.bind.annotation.*;
|
|
||||||
/**
|
|
||||||
* Sa-Token-SSO Server端 Controller
|
|
||||||
*/
|
|
||||||
@RestController
|
|
||||||
public class SsoServerController {
|
|
||||||
@Autowired
|
|
||||||
private SystemUserService systemUserService;
|
|
||||||
/**
|
|
||||||
* SSO-Server端:处理所有SSO相关请求 (下面的章节我们会详细列出开放的接口)
|
|
||||||
*/
|
|
||||||
@RequestMapping("sso/*")
|
|
||||||
@PermitAll
|
|
||||||
public Object ssoRequest() {
|
|
||||||
return SaSsoServerProcessor.instance.dister();
|
|
||||||
}
|
|
||||||
|
|
||||||
// 测试登录,浏览器访问: http://localhost:48083/doLogin?username=zhang&password=123456
|
|
||||||
@RequestMapping("doLogin")
|
|
||||||
@PermitAll
|
|
||||||
public String doLogin(String username, String password) {
|
|
||||||
// 此处仅作模拟示例,真实项目需要从数据库中查询数据进行比对
|
|
||||||
if("zhang".equals(username) && "123456".equals(password)) {
|
|
||||||
StpUtil.login(10001);
|
|
||||||
return "登录成功";
|
|
||||||
}
|
|
||||||
return "登录失败";
|
|
||||||
}
|
|
||||||
// 返回SSO认证中心登录地址
|
|
||||||
@PermitAll
|
|
||||||
@RequestMapping("sso/getSsoAuthUrl")
|
|
||||||
public SaResult getSsoAuthUrl(String clientLoginUrl) {
|
|
||||||
String serverAuthUrl = SaSsoUtil.buildServerAuthUrl(clientLoginUrl, "");
|
|
||||||
return SaResult.data(serverAuthUrl);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// 查询登录状态,浏览器访问: http://localhost:48083/isLogin
|
|
||||||
@RequestMapping("isLogin")
|
|
||||||
@PermitAll
|
|
||||||
public String isLogin() {
|
|
||||||
return "当前会话是否登录:" + StpUtil.isLogin();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,49 +0,0 @@
|
|||||||
package com.tashow.cloud.sso.framework.core;
|
|
||||||
import com.xingyuv.captcha.service.CaptchaCacheService;
|
|
||||||
import lombok.Setter;
|
|
||||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
|
||||||
|
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 基于 Redis 实现验证码的存储
|
|
||||||
*
|
|
||||||
* @author 星语
|
|
||||||
*/
|
|
||||||
@Setter
|
|
||||||
public class RedisCaptchaServiceImpl implements CaptchaCacheService {
|
|
||||||
|
|
||||||
private StringRedisTemplate stringRedisTemplate;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String type() {
|
|
||||||
return "redis";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void set(String key, String value, long expiresInSeconds) {
|
|
||||||
stringRedisTemplate.opsForValue().set(key, value, expiresInSeconds, TimeUnit.SECONDS);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean exists(String key) {
|
|
||||||
return Boolean.TRUE.equals(stringRedisTemplate.hasKey(key));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void delete(String key) {
|
|
||||||
stringRedisTemplate.delete(key);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String get(String key) {
|
|
||||||
return stringRedisTemplate.opsForValue().get(key);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Long increment(String key, long val) {
|
|
||||||
return stringRedisTemplate.opsForValue().increment(key,val);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
package com.tashow.cloud.sso.mapper;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
|
||||||
import com.tashow.cloud.sso.model.SystemRole;
|
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 系统角色Mapper接口
|
|
||||||
*/
|
|
||||||
@Mapper
|
|
||||||
public interface SystemRoleMapper extends BaseMapper<SystemRole> {
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
package com.tashow.cloud.sso.mapper;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
|
||||||
import com.tashow.cloud.sso.model.SystemUser;
|
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 系统用户Mapper接口
|
|
||||||
*/
|
|
||||||
@Mapper
|
|
||||||
public interface SystemUserMapper extends BaseMapper<SystemUser> {
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
package com.tashow.cloud.sso.mapper;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
|
||||||
import com.tashow.cloud.sso.model.SystemUserRole;
|
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 系统用户角色关联Mapper接口
|
|
||||||
*/
|
|
||||||
@Mapper
|
|
||||||
public interface SystemUserRoleMapper extends BaseMapper<SystemUserRole> {
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,92 +0,0 @@
|
|||||||
package com.tashow.cloud.sso.model;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.IdType;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableLogic;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
|
||||||
import lombok.Data;
|
|
||||||
import java.time.LocalDateTime;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 系统角色实体类
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@TableName("system_role")
|
|
||||||
public class SystemRole {
|
|
||||||
/**
|
|
||||||
* 角色ID
|
|
||||||
*/
|
|
||||||
@TableId(type = IdType.AUTO)
|
|
||||||
private Long id;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 角色名称
|
|
||||||
*/
|
|
||||||
private String name;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 角色权限字符串
|
|
||||||
*/
|
|
||||||
private String code;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 显示顺序
|
|
||||||
*/
|
|
||||||
private Integer sort;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 数据范围(1:全部数据权限 2:自定数据权限 3:本部门数据权限 4:本部门及以下数据权限)
|
|
||||||
*/
|
|
||||||
private Integer dataScope;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 数据范围(指定部门数组)
|
|
||||||
*/
|
|
||||||
private String dataScopeDeptIds;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 角色状态(0正常 1停用)
|
|
||||||
*/
|
|
||||||
private Integer status;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 角色类型
|
|
||||||
*/
|
|
||||||
private Integer type;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 备注
|
|
||||||
*/
|
|
||||||
private String remark;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 创建者
|
|
||||||
*/
|
|
||||||
private String creator;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 创建时间
|
|
||||||
*/
|
|
||||||
private LocalDateTime createTime;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新者
|
|
||||||
*/
|
|
||||||
private String updater;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新时间
|
|
||||||
*/
|
|
||||||
private LocalDateTime updateTime;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 是否删除
|
|
||||||
*/
|
|
||||||
@TableLogic
|
|
||||||
private Boolean deleted;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 租户编号
|
|
||||||
*/
|
|
||||||
private Long tenantId;
|
|
||||||
}
|
|
||||||
@@ -1,112 +0,0 @@
|
|||||||
package com.tashow.cloud.sso.model;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
|
||||||
import lombok.Data;
|
|
||||||
import java.time.LocalDateTime;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 系统用户实体类
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@TableName("system_users")
|
|
||||||
public class SystemUser {
|
|
||||||
/**
|
|
||||||
* 用户ID
|
|
||||||
*/
|
|
||||||
private Long id;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 用户账号
|
|
||||||
*/
|
|
||||||
private String username;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 密码
|
|
||||||
*/
|
|
||||||
private String password;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 用户昵称
|
|
||||||
*/
|
|
||||||
private String nickname;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 备注
|
|
||||||
*/
|
|
||||||
private String remark;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 部门ID
|
|
||||||
*/
|
|
||||||
private Long deptId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 岗位编号数组
|
|
||||||
*/
|
|
||||||
private String postIds;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 用户邮箱
|
|
||||||
*/
|
|
||||||
private String email;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 手机号码
|
|
||||||
*/
|
|
||||||
private String mobile;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 用户性别
|
|
||||||
*/
|
|
||||||
private Integer sex;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 头像地址
|
|
||||||
*/
|
|
||||||
private String avatar;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 帐号状态(0正常 1停用)
|
|
||||||
*/
|
|
||||||
private Integer status;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 最后登录IP
|
|
||||||
*/
|
|
||||||
private String loginIp;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 最后登录时间
|
|
||||||
*/
|
|
||||||
private LocalDateTime loginDate;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 创建者
|
|
||||||
*/
|
|
||||||
private String creator;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 创建时间
|
|
||||||
*/
|
|
||||||
private LocalDateTime createTime;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新者
|
|
||||||
*/
|
|
||||||
private String updater;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* a更新时间
|
|
||||||
*/
|
|
||||||
private LocalDateTime updateTime;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 是否删除
|
|
||||||
*/
|
|
||||||
private Boolean deleted;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 租户编号
|
|
||||||
*/
|
|
||||||
private Long tenantId;
|
|
||||||
}
|
|
||||||
@@ -1,63 +0,0 @@
|
|||||||
package com.tashow.cloud.sso.model;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.IdType;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableLogic;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 用户角色关联实体类
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@TableName("system_user_role")
|
|
||||||
public class SystemUserRole {
|
|
||||||
/**
|
|
||||||
* 自增编号
|
|
||||||
*/
|
|
||||||
@TableId(type = IdType.AUTO)
|
|
||||||
private Long id;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 用户ID
|
|
||||||
*/
|
|
||||||
private Long userId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 角色ID
|
|
||||||
*/
|
|
||||||
private Long roleId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 创建者
|
|
||||||
*/
|
|
||||||
private String creator;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 创建时间
|
|
||||||
*/
|
|
||||||
private LocalDateTime createTime;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新者
|
|
||||||
*/
|
|
||||||
private String updater;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新时间
|
|
||||||
*/
|
|
||||||
private LocalDateTime updateTime;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 是否删除
|
|
||||||
*/
|
|
||||||
@TableLogic
|
|
||||||
private Boolean deleted;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 租户编号
|
|
||||||
*/
|
|
||||||
private Long tenantId;
|
|
||||||
}
|
|
||||||
@@ -1,48 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2020-2099 sa-token.cc
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
package com.tashow.cloud.sso.security.config;
|
|
||||||
|
|
||||||
import cn.dev33.satoken.reactor.context.SaReactorSyncHolder;
|
|
||||||
import cn.dev33.satoken.stp.StpUtil;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
import org.springframework.web.server.ServerWebExchange;
|
|
||||||
import org.springframework.web.server.WebFilter;
|
|
||||||
import org.springframework.web.server.WebFilterChain;
|
|
||||||
import reactor.core.publisher.Mono;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 自定义过滤器
|
|
||||||
*/
|
|
||||||
@Component
|
|
||||||
public class MyFilter implements WebFilter {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Mono<Void> filter(ServerWebExchange exchange, WebFilterChain chain) {
|
|
||||||
System.out.println("进入自定义过滤器");
|
|
||||||
|
|
||||||
try {
|
|
||||||
// 先 set 上下文,再调用 Sa-Token 同步 API,并在 finally 里清除上下文
|
|
||||||
SaReactorSyncHolder.setContext(exchange);
|
|
||||||
System.out.println(StpUtil.isLogin());
|
|
||||||
}
|
|
||||||
finally {
|
|
||||||
SaReactorSyncHolder.clearContext();
|
|
||||||
}
|
|
||||||
|
|
||||||
return chain.filter(exchange);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,43 +0,0 @@
|
|||||||
package com.tashow.cloud.sso.security.config;
|
|
||||||
|
|
||||||
import com.tashow.cloud.security.security.config.AuthorizeRequestsCustomizer;
|
|
||||||
import com.tashow.cloud.systemapi.enums.ApiConstants;
|
|
||||||
import org.springframework.context.annotation.Bean;
|
|
||||||
import org.springframework.context.annotation.Configuration;
|
|
||||||
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
|
||||||
import org.springframework.security.config.annotation.web.configurers.AuthorizeHttpRequestsConfigurer;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* System 模块的 Security 配置
|
|
||||||
*/
|
|
||||||
@Configuration(proxyBeanMethods = false, value = "systemSecurityConfiguration")
|
|
||||||
public class SecurityConfiguration {
|
|
||||||
|
|
||||||
@Bean("systemAuthorizeRequestsCustomizer")
|
|
||||||
public AuthorizeRequestsCustomizer authorizeRequestsCustomizer() {
|
|
||||||
return new AuthorizeRequestsCustomizer() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void customize(AuthorizeHttpRequestsConfigurer<HttpSecurity>.AuthorizationManagerRequestMatcherRegistry registry) {
|
|
||||||
// TODO 芋艿:这个每个项目都需要重复配置,得捉摸有没通用的方案
|
|
||||||
// Swagger 接口文档
|
|
||||||
registry.requestMatchers("/v3/api-docs/**").permitAll()
|
|
||||||
.requestMatchers("/webjars/**").permitAll()
|
|
||||||
.requestMatchers("/swagger-ui").permitAll()
|
|
||||||
.requestMatchers("/swagger-ui/**").permitAll()
|
|
||||||
.requestMatchers("/oauth2/**").permitAll()
|
|
||||||
.requestMatchers("/sso/**").permitAll()
|
|
||||||
;
|
|
||||||
// Druid 监控
|
|
||||||
registry.requestMatchers("/druid/**").permitAll();
|
|
||||||
// Spring Boot Actuator 的安全配置
|
|
||||||
registry.requestMatchers("/actuator").permitAll()
|
|
||||||
.requestMatchers("/actuator/**").permitAll();
|
|
||||||
// RPC 服务的安全配置
|
|
||||||
registry.requestMatchers(ApiConstants.PREFIX + "/**").permitAll();
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
package com.tashow.cloud.sso.service;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
|
||||||
import com.tashow.cloud.sso.model.SystemRole;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 系统角色服务接口
|
|
||||||
*/
|
|
||||||
public interface SystemRoleService extends IService<SystemRole> {
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
package com.tashow.cloud.sso.service;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
|
||||||
import com.tashow.cloud.sso.model.SystemUserRole;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 系统用户角色关联服务接口
|
|
||||||
*/
|
|
||||||
public interface SystemUserRoleService extends IService<SystemUserRole> {
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,36 +0,0 @@
|
|||||||
package com.tashow.cloud.sso.service;
|
|
||||||
|
|
||||||
import com.tashow.cloud.sso.model.SystemUser;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 系统用户服务接口
|
|
||||||
*/
|
|
||||||
public interface SystemUserService {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据用户名查询用户
|
|
||||||
*
|
|
||||||
* @param username 用户名
|
|
||||||
* @return 用户信息
|
|
||||||
*/
|
|
||||||
SystemUser getUserByUsername(String username);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 验证用户密码
|
|
||||||
*
|
|
||||||
* @param rawPassword 原始密码
|
|
||||||
* @param encodedPassword 编码后的密码
|
|
||||||
* @return 是否匹配
|
|
||||||
*/
|
|
||||||
boolean validatePassword(String rawPassword, String encodedPassword);
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新用户登录信息
|
|
||||||
*
|
|
||||||
* @param userId 用户ID
|
|
||||||
* @param ip 登录IP
|
|
||||||
*/
|
|
||||||
void updateLoginInfo(Long userId, String ip);
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
package com.tashow.cloud.sso.service.impl;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
||||||
import com.tashow.cloud.sso.mapper.SystemRoleMapper;
|
|
||||||
import com.tashow.cloud.sso.model.SystemRole;
|
|
||||||
import com.tashow.cloud.sso.service.SystemRoleService;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 系统角色服务实现类
|
|
||||||
*/
|
|
||||||
@Service
|
|
||||||
public class SystemRoleServiceImpl extends ServiceImpl<SystemRoleMapper, SystemRole> implements SystemRoleService {
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
package com.tashow.cloud.sso.service.impl;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
||||||
import com.tashow.cloud.sso.mapper.SystemUserRoleMapper;
|
|
||||||
import com.tashow.cloud.sso.model.SystemUserRole;
|
|
||||||
import com.tashow.cloud.sso.service.SystemUserRoleService;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 系统用户角色关联服务实现类
|
|
||||||
*/
|
|
||||||
@Service
|
|
||||||
public class SystemUserRoleServiceImpl extends ServiceImpl<SystemUserRoleMapper, SystemUserRole> implements SystemUserRoleService {
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,48 +0,0 @@
|
|||||||
package com.tashow.cloud.sso.service.impl;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
||||||
import com.tashow.cloud.sso.mapper.SystemUserMapper;
|
|
||||||
import com.tashow.cloud.sso.model.SystemUser;
|
|
||||||
import com.tashow.cloud.sso.service.SystemUserService;
|
|
||||||
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
import java.time.LocalDateTime;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 系统用户服务实现类
|
|
||||||
*/
|
|
||||||
@Service
|
|
||||||
public class SystemUserServiceImpl extends ServiceImpl<SystemUserMapper, SystemUser> implements SystemUserService {
|
|
||||||
|
|
||||||
private final BCryptPasswordEncoder passwordEncoder = new BCryptPasswordEncoder();
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public SystemUser getUserByUsername(String username) {
|
|
||||||
return getOne(new LambdaQueryWrapper<SystemUser>()
|
|
||||||
.eq(SystemUser::getUsername, username)
|
|
||||||
.eq(SystemUser::getStatus, 0)
|
|
||||||
.eq(SystemUser::getDeleted, 0));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean validatePassword(String rawPassword, String encodedPassword) {
|
|
||||||
return passwordEncoder.matches(rawPassword, encodedPassword);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void updateLoginInfo(Long userId, String ip) {
|
|
||||||
SystemUser user = new SystemUser();
|
|
||||||
user.setId(userId);
|
|
||||||
user.setLoginIp(ip);
|
|
||||||
LocalDateTime now = LocalDateTime.now();
|
|
||||||
user.setLoginDate(now);
|
|
||||||
user.setUpdateTime(now);
|
|
||||||
updateById(user);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
com.tashow.cloud.sso.framework.core.RedisCaptchaServiceImpl
|
|
||||||
@@ -1,66 +0,0 @@
|
|||||||
--- #################### 注册中心 + 配置中心相关配置 ####################
|
|
||||||
|
|
||||||
spring:
|
|
||||||
cloud:
|
|
||||||
nacos:
|
|
||||||
server-addr: 43.139.42.137:8848 # Nacos 服务器地址
|
|
||||||
username: nacos # Nacos 账号
|
|
||||||
password: nacos # Nacos 密码
|
|
||||||
discovery: # 【配置中心】配置项
|
|
||||||
namespace: 5c8b8fe6-9a89-4ae3-975e-ef3bf560ff82 # 命名空间。这里使用 dev 开发环境
|
|
||||||
group: DEFAULT_GROUP # 使用的 Nacos 配置分组,默认为 DEFAULT_GROUP
|
|
||||||
metadata:
|
|
||||||
version: 1.0.0 # 服务实例的版本号,可用于灰度发布
|
|
||||||
config: # 【注册中心】配置项
|
|
||||||
namespace: 5c8b8fe6-9a89-4ae3-975e-ef3bf560ff82 # 命名空间。这里使用 dev 开发环境
|
|
||||||
group: DEFAULT_GROUP # 使用的 Nacos 配置分组,默认为 DEFAULT_GROUP
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# 数据源配置项
|
|
||||||
autoconfigure:
|
|
||||||
exclude:
|
|
||||||
- de.codecentric.boot.admin.client.config.SpringBootAdminClientAutoConfiguration # 禁用 Spring Boot Admin 的 Client 的自动配置
|
|
||||||
datasource:
|
|
||||||
druid: # Druid 【监控】相关的全局配置
|
|
||||||
web-stat-filter:
|
|
||||||
enabled: true
|
|
||||||
stat-view-servlet:
|
|
||||||
enabled: true
|
|
||||||
allow: # 设置白名单,不填则允许所有访问
|
|
||||||
url-pattern: /druid/*
|
|
||||||
login-username: # 控制台管理用户名和密码
|
|
||||||
login-password:
|
|
||||||
filter:
|
|
||||||
stat:
|
|
||||||
enabled: true
|
|
||||||
log-slow-sql: true # 慢 SQL 记录
|
|
||||||
slow-sql-millis: 100
|
|
||||||
merge-sql: true
|
|
||||||
wall:
|
|
||||||
config:
|
|
||||||
multi-statement-allow: true
|
|
||||||
dynamic: # 多数据源配置
|
|
||||||
druid: # Druid 【连接池】相关的全局配置
|
|
||||||
initial-size: 1 # 初始连接数
|
|
||||||
min-idle: 1 # 最小连接池数量
|
|
||||||
max-active: 20 # 最大连接池数量
|
|
||||||
max-wait: 600000 # 配置获取连接等待超时的时间,单位:毫秒
|
|
||||||
time-between-eviction-runs-millis: 60000 # 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位:毫秒
|
|
||||||
min-evictable-idle-time-millis: 300000 # 配置一个连接在池中最小生存的时间,单位:毫秒
|
|
||||||
max-evictable-idle-time-millis: 900000 # 配置一个连接在池中最大生存的时间,单位:毫秒
|
|
||||||
validation-query: SELECT 1 FROM DUAL # 配置检测连接是否有效
|
|
||||||
test-while-idle: true
|
|
||||||
test-on-borrow: false
|
|
||||||
test-on-return: false
|
|
||||||
primary: master
|
|
||||||
datasource:
|
|
||||||
master:
|
|
||||||
url: jdbc:mysql://43.139.42.137:8406/tashow-platform?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true&rewriteBatchedStatements=true # MySQL Connector/J 8.X 连接的示例
|
|
||||||
username: tashow-platform
|
|
||||||
password: tashow123,
|
|
||||||
# slave: # 模拟从库,可根据自己需要修改
|
|
||||||
# lazy: true # 开启懒加载,保证启动速度
|
|
||||||
# url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true&rewriteBatchedStatements=true
|
|
||||||
# username: root
|
|
||||||
# password: 123456
|
|
||||||
@@ -1,237 +0,0 @@
|
|||||||
server:
|
|
||||||
port: 48083
|
|
||||||
spring:
|
|
||||||
application:
|
|
||||||
name: sso-server
|
|
||||||
profiles:
|
|
||||||
active: local
|
|
||||||
main:
|
|
||||||
allow-circular-references: true # 允许循环依赖,因为项目是三层架构,无法避免这个情况。
|
|
||||||
allow-bean-definition-overriding: true # 允许 Bean 覆盖,例如说 Feign 等会存在重复定义的服务
|
|
||||||
config:
|
|
||||||
import:
|
|
||||||
- optional:classpath:application-${spring.profiles.active}.yaml # 加载【本地】配置
|
|
||||||
- optional:nacos:${spring.application.name}-${spring.profiles.active}.yaml # 加载【Nacos】的配置
|
|
||||||
# Servlet 配置
|
|
||||||
servlet:
|
|
||||||
# 文件上传相关配置项
|
|
||||||
multipart:
|
|
||||||
max-file-size: 16MB # 单个文件大小
|
|
||||||
max-request-size: 32MB # 设置总上传的文件大小
|
|
||||||
# Jackson 配置项
|
|
||||||
jackson:
|
|
||||||
serialization:
|
|
||||||
write-dates-as-timestamps: true # 设置 LocalDateTime 的格式,使用时间戳
|
|
||||||
write-date-timestamps-as-nanoseconds: false # 设置不使用 nanoseconds 的格式。例如说 1611460870.401,而是直接 1611460870401
|
|
||||||
write-durations-as-timestamps: true # 设置 Duration 的格式,使用时间戳
|
|
||||||
fail-on-empty-beans: false # 允许序列化无属性的 Bean
|
|
||||||
# Cache 配置项
|
|
||||||
cache:
|
|
||||||
type: REDIS
|
|
||||||
redis:
|
|
||||||
time-to-live: 1h # 设置过期时间为 1 小时
|
|
||||||
|
|
||||||
|
|
||||||
logging:
|
|
||||||
file:
|
|
||||||
name: ${user.home}/logs/${spring.application.name}.log # 日志文件名,全路径
|
|
||||||
|
|
||||||
--- #################### 接口文档配置 ####################
|
|
||||||
|
|
||||||
springdoc:
|
|
||||||
api-docs:
|
|
||||||
enabled: true # 1. 是否开启 Swagger 接文档的元数据
|
|
||||||
path: /v3/api-docs
|
|
||||||
swagger-ui:
|
|
||||||
enabled: true # 2.1 是否开启 Swagger 文档的官方 UI 界面
|
|
||||||
path: /swagger-ui
|
|
||||||
default-flat-param-object: true # 参见 https://doc.xiaominfo.com/docs/faq/v4/knife4j-parameterobject-flat-param 文档
|
|
||||||
|
|
||||||
knife4j:
|
|
||||||
enable: true # 2.2 是否开启 Swagger 文档的 Knife4j UI 界面
|
|
||||||
setting:
|
|
||||||
language: zh_cn
|
|
||||||
|
|
||||||
# MyBatis Plus 的配置项
|
|
||||||
mybatis-plus:
|
|
||||||
configuration:
|
|
||||||
map-underscore-to-camel-case: true #虽然默认为 true ,但是还是显示去指定下。
|
|
||||||
global-config:
|
|
||||||
db-config:
|
|
||||||
id-type: NONE # "智能"模式,基于 IdTypeEnvironmentPostProcessor + 数据源的类型,自动适配成 AUTO、INPUT 模式。
|
|
||||||
logic-delete-value: 1 # 逻辑已删除值(默认为 1)
|
|
||||||
logic-not-delete-value: 0 # 逻辑未删除值(默认为 0)
|
|
||||||
banner: false # 关闭控制台的 Banner 打印
|
|
||||||
type-aliases-package: ${tashow.info.base-package}.dal.dataobject
|
|
||||||
encryptor:
|
|
||||||
password: XDV71a+xqStEA3WH # 加解密的秘钥,可使用 https://www.imaegoo.com/2020/aes-key-generator/ 网站生成
|
|
||||||
|
|
||||||
mybatis-plus-join:
|
|
||||||
banner: false # 关闭控制台的 Banner 打印
|
|
||||||
|
|
||||||
# Spring Data Redis 配置
|
|
||||||
spring:
|
|
||||||
data:
|
|
||||||
redis:
|
|
||||||
repositories:
|
|
||||||
enabled: false # 项目未使用到 Spring Data Redis 的 Repository,所以直接禁用,保证启动速度
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# VO 转换(数据翻译)相关
|
|
||||||
easy-trans:
|
|
||||||
is-enable-global: true # 启用全局翻译(拦截所有 SpringMVC ResponseBody 进行自动翻译 )。如果对于性能要求很高可关闭此配置,或通过 @IgnoreTrans 忽略某个接口
|
|
||||||
|
|
||||||
--- #################### RPC 远程调用相关配置 ####################
|
|
||||||
|
|
||||||
--- #################### 消息队列相关 ####################
|
|
||||||
spring:
|
|
||||||
# Kafka 配置项,对应 KafkaProperties 配置类
|
|
||||||
kafka:
|
|
||||||
# Kafka Producer 配置项
|
|
||||||
producer:
|
|
||||||
acks: 1 # 0-不应答。1-leader 应答。all-所有 leader 和 follower 应答。
|
|
||||||
retries: 3 # 发送失败时,重试发送的次数
|
|
||||||
value-serializer: org.springframework.kafka.support.serializer.JsonSerializer # 消息的 value 的序列化
|
|
||||||
# Kafka Consumer 配置项
|
|
||||||
consumer:
|
|
||||||
auto-offset-reset: earliest # 设置消费者分组最初的消费进度为 earliest 。可参考博客 https://blog.csdn.net/lishuangzhe7047/article/details/74530417 理解
|
|
||||||
value-deserializer: org.springframework.kafka.support.serializer.JsonDeserializer
|
|
||||||
properties:
|
|
||||||
spring.json.trusted.packages: '*'
|
|
||||||
# Kafka Consumer Listener 监听器配置
|
|
||||||
listener:
|
|
||||||
missing-topics-fatal: false # 消费监听接口监听的主题不存在时,默认会报错。所以通过设置为 false ,解决报错
|
|
||||||
|
|
||||||
--- #################### 定时任务相关配置 ####################
|
|
||||||
|
|
||||||
xxl:
|
|
||||||
job:
|
|
||||||
executor:
|
|
||||||
appname: ${spring.application.name} # 执行器 AppName
|
|
||||||
logpath: ${user.home}/logs/xxl-job/${spring.application.name} # 执行器运行日志文件存储磁盘路径
|
|
||||||
accessToken: default_token # 执行器通讯TOKEN
|
|
||||||
|
|
||||||
--- #################### 验证码相关配置 ####################
|
|
||||||
|
|
||||||
aj:
|
|
||||||
captcha:
|
|
||||||
jigsaw: classpath:images/jigsaw # 滑动验证,底图路径,不配置将使用默认图片;以 classpath: 开头,取 resource 目录下路径
|
|
||||||
pic-click: classpath:images/pic-click # 滑动验证,底图路径,不配置将使用默认图片;以 classpath: 开头,取 resource 目录下路径
|
|
||||||
cache-type: redis # 缓存 local/redis...
|
|
||||||
cache-number: 1000 # local 缓存的阈值,达到这个值,清除缓存
|
|
||||||
timing-clear: 180 # local定时清除过期缓存(单位秒),设置为0代表不执行
|
|
||||||
type: blockPuzzle # 验证码类型 default两种都实例化。 blockPuzzle 滑块拼图 clickWord 文字点选
|
|
||||||
water-mark: 他秀 # 右下角水印文字(我的水印),可使用 https://tool.chinaz.com/tools/unicode.aspx 中文转 Unicode,Linux 可能需要转 unicode
|
|
||||||
interference-options: 0 # 滑动干扰项(0/1/2)
|
|
||||||
req-frequency-limit-enable: false # 接口请求次数一分钟限制是否开启 true|false
|
|
||||||
req-get-lock-limit: 5 # 验证失败5次,get接口锁定
|
|
||||||
req-get-lock-seconds: 10 # 验证失败后,锁定时间间隔
|
|
||||||
req-get-minute-limit: 30 # get 接口一分钟内请求数限制
|
|
||||||
req-check-minute-limit: 60 # check 接口一分钟内请求数限制
|
|
||||||
req-verify-minute-limit: 60 # verify 接口一分钟内请求数限制
|
|
||||||
|
|
||||||
--- #################### 芋道相关配置 ####################
|
|
||||||
|
|
||||||
tashow:
|
|
||||||
info:
|
|
||||||
version: 1.0.0
|
|
||||||
base-package: com.tashow.cloud
|
|
||||||
web:
|
|
||||||
admin-ui:
|
|
||||||
url: http://dashboard.yudao.iocoder.cn # Admin 管理后台 UI 的地址
|
|
||||||
xss:
|
|
||||||
enable: false
|
|
||||||
exclude-urls: # 如下 url,仅仅是为了演示,去掉配置也没关系
|
|
||||||
- ${management.endpoints.web.base-path}/** # 不处理 Actuator 的请求
|
|
||||||
swagger:
|
|
||||||
title: 管理后台
|
|
||||||
description: 提供管理员管理的所有功能
|
|
||||||
version: ${tashow.info.version}
|
|
||||||
tenant: # 多租户相关配置项
|
|
||||||
enable: true
|
|
||||||
ignore-urls:
|
|
||||||
- /admin-api/system/tenant/get-id-by-name # 基于名字获取租户,不许带租户编号
|
|
||||||
- /admin-api/system/tenant/get-by-website # 基于域名获取租户,不许带租户编号
|
|
||||||
- /admin-api/system/captcha/get-image # 获取图片验证码,和租户无关
|
|
||||||
- /admin-api/system/captcha/get # 获取图片验证码,和租户无关
|
|
||||||
- /admin-api/system/captcha/check # 校验图片验证码,和租户无关
|
|
||||||
- /admin-api/system/sms/callback/* # 短信回调接口,无法带上租户编号
|
|
||||||
- /rpc-api/system/tenant/valid # 防止递归。避免调用 /rpc-api/system/tenant/valid 接口时,又去触发 /rpc-api/system/tenant/valid 去校验
|
|
||||||
- /rpc-api/system/tenant/id-list # 获得租户列表的时候,无需传递租户编号
|
|
||||||
- /rpc-api/system/oauth2/token/check # 访问令牌校验时,无需传递租户编号;主要解决上传文件的场景,前端不会传递 tenant-id!
|
|
||||||
# - /oauth2/* # OAuth2相关接口,无需传递租户编号
|
|
||||||
# - /oauth2/login # OAuth2登录接口,无需传递租户编号
|
|
||||||
ignore-tables:
|
|
||||||
- system_tenant
|
|
||||||
- system_tenant_package
|
|
||||||
- system_dict_data
|
|
||||||
- system_dict_type
|
|
||||||
- system_error_code
|
|
||||||
- system_menu
|
|
||||||
- system_sms_channel
|
|
||||||
- system_sms_template
|
|
||||||
- system_sms_log
|
|
||||||
- system_sensitive_word
|
|
||||||
- system_oauth2_client
|
|
||||||
- system_mail_account
|
|
||||||
- system_mail_template
|
|
||||||
- system_mail_log
|
|
||||||
- system_notify_template
|
|
||||||
ignore-caches:
|
|
||||||
- user_role_ids
|
|
||||||
- permission_menu_ids
|
|
||||||
- oauth_client
|
|
||||||
- notify_template
|
|
||||||
- mail_account
|
|
||||||
- mail_template
|
|
||||||
- sms_template
|
|
||||||
sms-code: # 短信验证码相关的配置项
|
|
||||||
expire-times: 10m
|
|
||||||
send-frequency: 1m
|
|
||||||
send-maximum-quantity-per-day: 10
|
|
||||||
begin-code: 9999 # 这里配置 9999 的原因是,测试方便。
|
|
||||||
end-code: 9999 # 这里配置 9999 的原因是,测试方便。
|
|
||||||
|
|
||||||
debug: false
|
|
||||||
|
|
||||||
|
|
||||||
sa-token:
|
|
||||||
# token 名称(同时也是 cookie 名称)
|
|
||||||
token-name: token
|
|
||||||
# token 有效期(单位:秒) 默认30天,-1 代表永久有效
|
|
||||||
timeout: 2592000
|
|
||||||
# token 最低活跃频率(单位:秒),如果 token 超过此时间没有访问系统就会被冻结,默认-1 代表不限制,永不冻结
|
|
||||||
active-timeout: -1
|
|
||||||
# 是否允许同一账号多地同时登录 (为 true 时允许一起登录, 为 false 时新登录挤掉旧登录)
|
|
||||||
is-concurrent: true
|
|
||||||
# 在多人登录同一账号时,是否共用一个 token (为 true 时所有登录共用一个 token, 为 false 时每次登录新建一个 token)
|
|
||||||
is-share: false
|
|
||||||
# token 风格(默认可取值:uuid、simple-uuid、random-32、random-64、random-128、tik)
|
|
||||||
token-style: uuid
|
|
||||||
# 是否输出操作日志
|
|
||||||
is-log: true
|
|
||||||
|
|
||||||
# OAuth2相关配置
|
|
||||||
oauth2:
|
|
||||||
is-code: true
|
|
||||||
is-implicit: true
|
|
||||||
is-password: true
|
|
||||||
is-client: true
|
|
||||||
is-refresh: true
|
|
||||||
# 授权码有效期 (单位: 秒)
|
|
||||||
code-timeout: 300
|
|
||||||
# Access-Token有效期 (单位: 秒)
|
|
||||||
access-token-timeout: 7200
|
|
||||||
# Refresh-Token有效期 (单位: 秒)
|
|
||||||
refresh-token-timeout: 604800
|
|
||||||
# 客户端模式 Access-Token 有效期 (单位: 秒)
|
|
||||||
client-token-timeout: 7200
|
|
||||||
# 登录后的默认跳转页面
|
|
||||||
home-route: "/oauth2/login-success"
|
|
||||||
sign:
|
|
||||||
# API 接口调用秘钥
|
|
||||||
secret-key: kQwIOrYvnXmSDkwEiFngrKidMcdrgKor
|
|
||||||
# ---- 除了以上配置项,你还需要为 Sa-Token 配置http请求处理器(文档有步骤说明)
|
|
||||||
|
|
||||||
Binary file not shown.
|
Before Width: | Height: | Size: 2.2 KiB |
@@ -1,76 +0,0 @@
|
|||||||
<configuration>
|
|
||||||
<!-- 引用 Spring Boot 的 logback 基础配置 -->
|
|
||||||
<include resource="org/springframework/boot/logging/logback/defaults.xml" />
|
|
||||||
<!-- 变量 yudao.info.base-package,基础业务包 -->
|
|
||||||
<springProperty scope="context" name="tashow.info.base-package" source="tashow.info.base-package"/>
|
|
||||||
<!-- 格式化输出:%d 表示日期,%X{tid} SkWalking 链路追踪编号,%thread 表示线程名,%-5level:级别从左显示 5 个字符宽度,%msg:日志消息,%n是换行符 -->
|
|
||||||
<property name="PATTERN_DEFAULT" value="%d{${LOG_DATEFORMAT_PATTERN:-yyyy-MM-dd HH:mm:ss.SSS}} | %highlight(${LOG_LEVEL_PATTERN:-%5p} ${PID:- }) | %boldYellow(%thread [%tid]) %boldGreen(%-40.40logger{39}) | %m%n${LOG_EXCEPTION_CONVERSION_WORD:-%wEx}"/>
|
|
||||||
|
|
||||||
<!-- 控制台 Appender -->
|
|
||||||
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
|
|
||||||
<encoder class="ch.qos.logback.core.encoder.LayoutWrappingEncoder">
|
|
||||||
<layout class="org.apache.skywalking.apm.toolkit.log.logback.v1.x.TraceIdPatternLogbackLayout">
|
|
||||||
<pattern>${PATTERN_DEFAULT}</pattern>
|
|
||||||
</layout>
|
|
||||||
</encoder>
|
|
||||||
</appender>
|
|
||||||
|
|
||||||
<!-- 文件 Appender -->
|
|
||||||
<!-- 参考 Spring Boot 的 file-appender.xml 编写 -->
|
|
||||||
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
|
||||||
<encoder class="ch.qos.logback.core.encoder.LayoutWrappingEncoder">
|
|
||||||
<layout class="org.apache.skywalking.apm.toolkit.log.logback.v1.x.TraceIdPatternLogbackLayout">
|
|
||||||
<pattern>${PATTERN_DEFAULT}</pattern>
|
|
||||||
</layout>
|
|
||||||
</encoder>
|
|
||||||
<!-- 日志文件名 -->
|
|
||||||
<file>${LOG_FILE}</file>
|
|
||||||
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
|
|
||||||
<!-- 滚动后的日志文件名 -->
|
|
||||||
<fileNamePattern>${LOGBACK_ROLLINGPOLICY_FILE_NAME_PATTERN:-${LOG_FILE}.%d{yyyy-MM-dd}.%i.gz}</fileNamePattern>
|
|
||||||
<!-- 启动服务时,是否清理历史日志,一般不建议清理 -->
|
|
||||||
<cleanHistoryOnStart>${LOGBACK_ROLLINGPOLICY_CLEAN_HISTORY_ON_START:-false}</cleanHistoryOnStart>
|
|
||||||
<!-- 日志文件,到达多少容量,进行滚动 -->
|
|
||||||
<maxFileSize>${LOGBACK_ROLLINGPOLICY_MAX_FILE_SIZE:-10MB}</maxFileSize>
|
|
||||||
<!-- 日志文件的总大小,0 表示不限制 -->
|
|
||||||
<totalSizeCap>${LOGBACK_ROLLINGPOLICY_TOTAL_SIZE_CAP:-0}</totalSizeCap>
|
|
||||||
<!-- 日志文件的保留天数 -->
|
|
||||||
<maxHistory>${LOGBACK_ROLLINGPOLICY_MAX_HISTORY:-30}</maxHistory>
|
|
||||||
</rollingPolicy>
|
|
||||||
</appender>
|
|
||||||
<!-- 异步写入日志,提升性能 -->
|
|
||||||
<appender name="ASYNC" class="ch.qos.logback.classic.AsyncAppender">
|
|
||||||
<!-- 不丢失日志。默认的,如果队列的 80% 已满,则会丢弃 TRACT、DEBUG、INFO 级别的日志 -->
|
|
||||||
<discardingThreshold>0</discardingThreshold>
|
|
||||||
<!-- 更改默认的队列的深度,该值会影响性能。默认值为 256 -->
|
|
||||||
<queueSize>256</queueSize>
|
|
||||||
<appender-ref ref="FILE"/>
|
|
||||||
</appender>
|
|
||||||
|
|
||||||
<!-- SkyWalking GRPC 日志收集,实现日志中心。注意:SkyWalking 8.4.0 版本开始支持 -->
|
|
||||||
<appender name="GRPC" class="org.apache.skywalking.apm.toolkit.log.logback.v1.x.log.GRPCLogClientAppender">
|
|
||||||
<encoder class="ch.qos.logback.core.encoder.LayoutWrappingEncoder">
|
|
||||||
<layout class="org.apache.skywalking.apm.toolkit.log.logback.v1.x.TraceIdPatternLogbackLayout">
|
|
||||||
<pattern>${PATTERN_DEFAULT}</pattern>
|
|
||||||
</layout>
|
|
||||||
</encoder>
|
|
||||||
</appender>
|
|
||||||
|
|
||||||
<!-- 本地环境 -->
|
|
||||||
<springProfile name="local">
|
|
||||||
<root level="INFO">
|
|
||||||
<appender-ref ref="STDOUT"/>
|
|
||||||
<appender-ref ref="GRPC"/> <!-- 本地环境下,如果不想接入 SkyWalking 日志服务,可以注释掉本行 -->
|
|
||||||
<appender-ref ref="ASYNC"/> <!-- 本地环境下,如果不想打印日志,可以注释掉本行 -->
|
|
||||||
</root>
|
|
||||||
</springProfile>
|
|
||||||
<!-- 其它环境 -->
|
|
||||||
<springProfile name="dev,test,stage,prod,default">
|
|
||||||
<root level="INFO">
|
|
||||||
<appender-ref ref="STDOUT"/>
|
|
||||||
<appender-ref ref="ASYNC"/>
|
|
||||||
<appender-ref ref="GRPC"/>
|
|
||||||
</root>
|
|
||||||
</springProfile>
|
|
||||||
|
|
||||||
</configuration>
|
|
||||||
Reference in New Issue
Block a user