Skip to content

Commit

Permalink
Merge branch 'jdk17-dev' into jdk17
Browse files Browse the repository at this point in the history
# Conflicts:
#	README.md
  • Loading branch information
lbw committed Jan 3, 2024
2 parents 0f5018e + 8edf693 commit f8214e5
Show file tree
Hide file tree
Showing 12 changed files with 79 additions and 64 deletions.
44 changes: 30 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
<p align="center">
<img src="https://img.shields.io/badge/Pig-3.7-success.svg" alt="Build Status">
<img src="https://img.shields.io/badge/Spring%20Boot-3.2-blue.svg" alt="Downloads">
<img src="https://img.shields.io/badge/Spring%20Cloud-2023.0.0-blue.svg" alt="Coverage Status">
<img src="https://img.shields.io/badge/Spring%20Boot-3.2.1-blue.svg" alt="Downloads">
<img src="https://img.shields.io/badge/Vue-3.2-blue.svg" alt="Downloads">
<img src="https://img.shields.io/github/license/pig-mesh/pig"/>
</p>

## 分支说明

- master: java8 + springboot 2.7 + springcloud 2021
- ⭐️ jdk17: java17 + springboot 3.2 + springcloud 2022
- 🔥 boot: java17 + springboot 3.2 单体版本
- jdk17: java17 + springboot 3.2 + springcloud 2023

## 系统说明

Expand Down Expand Up @@ -41,25 +41,41 @@

| 依赖 | 版本 |
|-----------------------------|------------|
| Spring Boot | 3.2.0 |
| Spring Boot | 3.2.1 |
| Spring Cloud | 2023.0.0 |
| Spring Cloud Alibaba | 2022.0.0.0 |
| Spring Authorization Server | 1.2.0 |
| Mybatis Plus | 3.5.4 |
| hutool | 5.8.22 |
| Spring Authorization Server | 1.2.1 |
| Mybatis Plus | 3.5.5 |
| hutool | 5.8.23 |

### 模块说明

```lua
pig-ui -- https://gitee.com/log4j/pig-ui

├── pig-auth
├── pig-codegen
├── pig-common
├── pig-quartz
├── pig-upms
└── pom.xml

pig
├── pig-auth -- 授权服务提供[3000]
└── pig-common -- 系统公共模块
├── pig-common-bom -- 全局依赖管理控制
├── pig-common-core -- 公共工具类核心包
├── pig-common-datasource -- 动态数据源包
├── pig-common-log -- 日志服务
├── pig-common-oss -- 文件上传工具类
├── pig-common-mybatis -- mybatis 扩展封装
├── pig-common-seata -- 分布式事务
├── pig-common-security -- 安全工具类
├── pig-common-swagger -- 接口文档
├── pig-common-feign -- feign 扩展封装
└── pig-common-xss -- xss 安全封装
├── pig-register -- Nacos Server[8848]
├── pig-gateway -- Spring Cloud Gateway网关[9999]
└── pig-upms -- 通用用户权限管理模块
└── pig-upms-api -- 通用用户权限管理系统公共api模块
└── pig-upms-biz -- 通用用户权限管理系统业务处理模块[4000]
└── pig-visual
└── pig-monitor -- 服务监控 [5001]
├── pig-codegen -- 图形化代码生成 [5002]
└── pig-quartz -- 定时任务管理台 [5007]
```

### 本地开发 运行
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import org.springframework.core.Ordered;
import org.springframework.core.annotation.Order;
import org.springframework.security.authentication.AuthenticationManager;
import org.springframework.security.config.Customizer;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.oauth2.server.authorization.OAuth2AuthorizationService;
import org.springframework.security.oauth2.server.authorization.config.annotation.web.configurers.OAuth2AuthorizationServerConfigurer;
Expand Down Expand Up @@ -65,14 +66,14 @@ public class AuthorizationServerConfiguration {
public SecurityFilterChain authorizationServerSecurityFilterChain(HttpSecurity http) throws Exception {
OAuth2AuthorizationServerConfigurer authorizationServerConfigurer = new OAuth2AuthorizationServerConfigurer();

http.apply(authorizationServerConfigurer.tokenEndpoint((tokenEndpoint) -> {// 个性化认证授权端点
http.with(authorizationServerConfigurer.tokenEndpoint((tokenEndpoint) -> {// 个性化认证授权端点
tokenEndpoint.accessTokenRequestConverter(accessTokenRequestConverter()) // 注入自定义的授权认证Converter
.accessTokenResponseHandler(new PigAuthenticationSuccessEventHandler()) // 登录成功处理器
.errorResponseHandler(new PigAuthenticationFailureEventHandler());// 登录失败处理器
}).clientAuthentication(oAuth2ClientAuthenticationConfigurer -> // 个性化客户端认证
oAuth2ClientAuthenticationConfigurer.errorResponseHandler(new PigAuthenticationFailureEventHandler()))// 处理客户端认证异常
.authorizationEndpoint(authorizationEndpoint -> authorizationEndpoint// 授权码端点个性化confirm页面
.consentPage(SecurityConstants.CUSTOM_CONSENT_PAGE_URI)));
.consentPage(SecurityConstants.CUSTOM_CONSENT_PAGE_URI)), Customizer.withDefaults());

AntPathRequestMatcher[] requestMatchers = new AntPathRequestMatcher[] {
AntPathRequestMatcher.antMatcher("/token/**"), AntPathRequestMatcher.antMatcher("/actuator/**"),
Expand All @@ -83,10 +84,11 @@ public SecurityFilterChain authorizationServerSecurityFilterChain(HttpSecurity h
authorizeRequests.requestMatchers(requestMatchers).permitAll();
authorizeRequests.anyRequest().authenticated();
})
.apply(authorizationServerConfigurer.authorizationService(authorizationService)// redis存储token的实现
.with(authorizationServerConfigurer.authorizationService(authorizationService)// redis存储token的实现
.authorizationServerSettings(
AuthorizationServerSettings.builder().issuer(SecurityConstants.PROJECT_LICENSE).build()));
http.apply(new FormIdentityLoginConfigurer());
AuthorizationServerSettings.builder().issuer(SecurityConstants.PROJECT_LICENSE).build()),
Customizer.withDefaults());
http.with(new FormIdentityLoginConfigurer(), Customizer.withDefaults());
DefaultSecurityFilterChain securityFilterChain = http.build();

// 注入自定义授权模式实现
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import com.pig4cloud.pig.auth.support.core.PigDaoAuthenticationProvider;
import org.springframework.context.annotation.Bean;
import org.springframework.core.annotation.Order;
import org.springframework.security.config.Customizer;
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.configurers.AbstractHttpConfigurer;
Expand Down Expand Up @@ -48,7 +49,7 @@ SecurityFilterChain defaultSecurityFilterChain(HttpSecurity http) throws Excepti
.permitAll()// 开放自定义的部分端点
.anyRequest()
.authenticated()).headers(header -> header.frameOptions(HeadersConfigurer.FrameOptionsConfig::sameOrigin)// 避免iframe同源无法登录许iframe
).apply(new FormIdentityLoginConfigurer()); // 表单登录个性化
).with(new FormIdentityLoginConfigurer(), Customizer.withDefaults()); // 表单登录个性化
// 处理 UsernamePasswordAuthenticationToken
http.authenticationProvider(new PigDaoAuthenticationProvider());
return http.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@
public class CustomeOAuth2AccessTokenGenerator implements OAuth2TokenGenerator<OAuth2AccessToken> {

private OAuth2TokenCustomizer<OAuth2TokenClaimsContext> accessTokenCustomizer;
private final StringKeyGenerator accessTokenGenerator =
new Base64StringKeyGenerator(Base64.getUrlEncoder().withoutPadding(), 96);

private final StringKeyGenerator accessTokenGenerator = new Base64StringKeyGenerator(
Base64.getUrlEncoder().withoutPadding(), 96);

@Nullable
@Override
Expand Down Expand Up @@ -85,8 +85,8 @@ public OAuth2AccessToken generate(OAuth2TokenContext context) {

OAuth2TokenClaimsSet accessTokenClaimsSet = claimsBuilder.build();
return new CustomeOAuth2AccessTokenGenerator.OAuth2AccessTokenClaims(OAuth2AccessToken.TokenType.BEARER,
this.accessTokenGenerator.generateKey(), accessTokenClaimsSet.getIssuedAt(), accessTokenClaimsSet.getExpiresAt(),
context.getAuthorizedScopes(), accessTokenClaimsSet.getClaims());
this.accessTokenGenerator.generateKey(), accessTokenClaimsSet.getIssuedAt(),
accessTokenClaimsSet.getExpiresAt(), context.getAuthorizedScopes(), accessTokenClaimsSet.getClaims());
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ public PigDaoAuthenticationProvider() {
}

@Override
@SuppressWarnings("deprecation")
protected void additionalAuthenticationChecks(UserDetails userDetails,
UsernamePasswordAuthenticationToken authentication) throws AuthenticationException {

Expand Down Expand Up @@ -111,7 +110,7 @@ protected final UserDetails retrieveUser(String username, UsernamePasswordAuthen
.filter(service -> service.support(finalClientId, grantType))
.max(Comparator.comparingInt(Ordered::getOrder));

if (!optional.isPresent()) {
if (optional.isEmpty()) {
throw new InternalAuthenticationServiceException("UserDetailsService error , not register");
}

Expand Down
15 changes: 4 additions & 11 deletions pig-common/pig-common-bom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,8 @@

<properties>
<pig.common.version>${project.version}</pig.common.version>
<spring-boot.version>3.2.0</spring-boot.version>
<spring-boot.version>3.2.1</spring-boot.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<log4j2.version>2.17.1</log4j2.version>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<git.commit.plugin>4.9.9</git.commit.plugin>
Expand All @@ -26,8 +25,7 @@
<knife4j.version>3.0.3</knife4j.version>
<springdoc.version>2.1.0</springdoc.version>
<swagger.core.version>2.2.14</swagger.core.version>
<mybatis-plus.version>3.5.4</mybatis-plus.version>
<mybatis-spring.version>3.0.3</mybatis-spring.version>
<mybatis-plus.version>3.5.5</mybatis-plus.version>
<mysql.version>8.0.33</mysql.version>
<dynamic-ds.version>4.2.0</dynamic-ds.version>
<seata.version>1.7.0</seata.version>
Expand All @@ -36,7 +34,7 @@
<sms.version>3.0.0</sms.version>
<jaxb.version>2.3.5</jaxb.version>
<shardingsphere.version>5.4.1</shardingsphere.version>
<hutool.version>5.8.22</hutool.version>
<hutool.version>5.8.23</hutool.version>
<sentinel.version>1.8.4</sentinel.version>
</properties>

Expand Down Expand Up @@ -151,7 +149,7 @@
<!--orm 相关-->
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
<artifactId>mybatis-plus-spring-boot3-starter</artifactId>
<version>${mybatis-plus.version}</version>
</dependency>
<dependency>
Expand All @@ -164,11 +162,6 @@
<artifactId>mybatis-plus-annotation</artifactId>
<version>${mybatis-plus.version}</version>
</dependency>
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis-spring</artifactId>
<version>${mybatis-spring.version}</version>
</dependency>
<!--hutool bom 工具类-->
<dependency>
<groupId>cn.hutool</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ private Object getFromContext(String name, String type, Class<?> fallbackType, C
Object fallbackInstance = feignClientFactory.getInstance(name, fallbackType);
if (fallbackInstance == null) {
throw new IllegalStateException(String
.format("No %s instance of type %s found for feign client %s", type, fallbackType, name));
.format("No %s instance of type %s found for feign client %s", type, fallbackType, name));
}

if (!targetType.isAssignableFrom(fallbackType)) {
Expand Down
2 changes: 1 addition & 1 deletion pig-upms/pig-upms-biz/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
<!-- orm 模块-->
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
<artifactId>mybatis-plus-spring-boot3-starter</artifactId>
</dependency>
<dependency>
<groupId>com.mysql</groupId>
Expand Down
2 changes: 1 addition & 1 deletion pig-visual/pig-codegen/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
</dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
<artifactId>mybatis-plus-spring-boot3-starter</artifactId>
</dependency>
<dependency>
<groupId>com.mysql</groupId>
Expand Down
2 changes: 1 addition & 1 deletion pig-visual/pig-quartz/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
</dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
<artifactId>mybatis-plus-spring-boot3-starter</artifactId>
</dependency>
<!--数据库-->
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,24 +37,28 @@
@AllArgsConstructor
public class PigInitQuartzJob implements InitializingBean {

private final SysJobService sysJobService;

private final TaskUtil taskUtil;

private final Scheduler scheduler;

@Override
public void afterPropertiesSet() throws Exception {
sysJobService.list().forEach(sysjob -> {
if (PigQuartzEnum.JOB_STATUS_RELEASE.getType().equals(sysjob.getJobStatus())) {
taskUtil.removeJob(sysjob, scheduler);
} else if (PigQuartzEnum.JOB_STATUS_RUNNING.getType().equals(sysjob.getJobStatus())) {
taskUtil.resumeJob(sysjob, scheduler);
} else if (PigQuartzEnum.JOB_STATUS_NOT_RUNNING.getType().equals(sysjob.getJobStatus())) {
taskUtil.pauseJob(sysjob, scheduler);
} else {
taskUtil.removeJob(sysjob, scheduler);
}
});
}
private final SysJobService sysJobService;

private final TaskUtil taskUtil;

private final Scheduler scheduler;

@Override
public void afterPropertiesSet() throws Exception {
sysJobService.list().forEach(sysjob -> {
if (PigQuartzEnum.JOB_STATUS_RELEASE.getType().equals(sysjob.getJobStatus())) {
taskUtil.removeJob(sysjob, scheduler);
}
else if (PigQuartzEnum.JOB_STATUS_RUNNING.getType().equals(sysjob.getJobStatus())) {
taskUtil.resumeJob(sysjob, scheduler);
}
else if (PigQuartzEnum.JOB_STATUS_NOT_RUNNING.getType().equals(sysjob.getJobStatus())) {
taskUtil.pauseJob(sysjob, scheduler);
}
else {
taskUtil.removeJob(sysjob, scheduler);
}
});
}

}
6 changes: 3 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@
<url>https://www.pig4cloud.com</url>

<properties>
<spring-boot.version>3.2.0</spring-boot.version>
<spring-boot.version>3.2.1</spring-boot.version>
<spring-cloud.version>2023.0.0</spring-cloud.version>
<spring-cloud-alibaba.version>2022.0.0.0</spring-cloud-alibaba.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<spring-boot-admin.version>3.1.8</spring-boot-admin.version>
<spring.authorization.version>1.2.0</spring.authorization.version>
<spring-boot-admin.version>3.2.0</spring-boot-admin.version>
<spring.authorization.version>1.2.1</spring.authorization.version>
<screw.version>0.0.3</screw.version>
<captcha.version>2.2.3</captcha.version>
<aws.version>1.12.261</aws.version>
Expand Down

0 comments on commit f8214e5

Please sign in to comment.