org.springframework.boot
spring-boot-configuration-processor
diff --git a/zlt-commons/zlt-swagger2-spring-boot-starter/pom.xml b/zlt-commons/zlt-swagger2-spring-boot-starter/pom.xml
deleted file mode 100644
index 0a992c22..00000000
--- a/zlt-commons/zlt-swagger2-spring-boot-starter/pom.xml
+++ /dev/null
@@ -1,29 +0,0 @@
-
-
-
- com.zlt
- zlt-commons
- 5.6.0
-
- 4.0.0
- jar
- zlt-swagger2-spring-boot-starter
- swagger通用组件
-
-
- org.springframework.boot
- spring-boot-starter
-
-
- com.github.xiaoymin
- knife4j-micro-spring-boot-starter
-
-
- org.springframework.boot
- spring-boot-configuration-processor
- true
-
-
-
diff --git a/zlt-commons/zlt-swagger2-spring-boot-starter/src/main/java/com/central/common/swagger2/SwaggerAutoConfiguration.java b/zlt-commons/zlt-swagger2-spring-boot-starter/src/main/java/com/central/common/swagger2/SwaggerAutoConfiguration.java
deleted file mode 100644
index e52f12cb..00000000
--- a/zlt-commons/zlt-swagger2-spring-boot-starter/src/main/java/com/central/common/swagger2/SwaggerAutoConfiguration.java
+++ /dev/null
@@ -1,271 +0,0 @@
-package com.central.common.swagger2;
-
-import com.github.xiaoymin.knife4j.spring.annotations.EnableKnife4j;
-import com.google.common.base.Predicate;
-import com.google.common.base.Predicates;
-import com.google.common.collect.Lists;
-import org.springframework.beans.factory.BeanFactory;
-import org.springframework.beans.factory.BeanFactoryAware;
-import org.springframework.beans.factory.config.ConfigurableBeanFactory;
-import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
-import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.context.annotation.Import;
-import springfox.bean.validators.configuration.BeanValidatorPluginsConfiguration;
-import springfox.documentation.builders.ApiInfoBuilder;
-import springfox.documentation.builders.ParameterBuilder;
-import springfox.documentation.builders.PathSelectors;
-import springfox.documentation.builders.RequestHandlerSelectors;
-import springfox.documentation.schema.ModelRef;
-import springfox.documentation.service.ApiInfo;
-import springfox.documentation.service.ApiKey;
-import springfox.documentation.service.AuthorizationScope;
-import springfox.documentation.service.Contact;
-import springfox.documentation.service.Parameter;
-import springfox.documentation.service.SecurityReference;
-import springfox.documentation.spi.DocumentationType;
-import springfox.documentation.spi.service.contexts.SecurityContext;
-import springfox.documentation.spring.web.plugins.Docket;
-import springfox.documentation.swagger2.annotations.EnableSwagger2;
-
-import java.util.ArrayList;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Objects;
-import java.util.Set;
-import java.util.stream.Collectors;
-
-/**
- * @author zlt
- * @date 2018/11/18 9:22
- *
- * Blog: http://zlt2000.gitee.io
- * Github: https://github.com/zlt2000
- */
-@Configuration
-@EnableSwagger2
-@EnableKnife4j
-@Import(BeanValidatorPluginsConfiguration.class)
-public class SwaggerAutoConfiguration implements BeanFactoryAware {
- private static final String AUTH_KEY = "Authorization";
-
- private BeanFactory beanFactory;
-
- @Bean
- @ConditionalOnMissingBean
- public SwaggerProperties swaggerProperties() {
- return new SwaggerProperties();
- }
-
- /*@Bean
- @ConditionalOnMissingBean
- @ConditionalOnProperty(name = "zlt.swagger.enabled", matchIfMissing = true)
- public List createRestApi(SwaggerProperties swaggerProperties) {
- ConfigurableBeanFactory configurableBeanFactory = (ConfigurableBeanFactory) beanFactory;
- List docketList = new LinkedList<>();
-
- // 没有分组
- if (swaggerProperties.getDocket().size() == 0) {
- final Docket docket = createDocket(swaggerProperties);
- configurableBeanFactory.registerSingleton("defaultDocket", docket);
- docketList.add(docket);
- return docketList;
- }
-
- // 分组创建
- for (String groupName : swaggerProperties.getDocket().keySet()) {
- SwaggerProperties.DocketInfo docketInfo = swaggerProperties.getDocket().get(groupName);
-
- ApiInfo apiInfo = new ApiInfoBuilder()
- .title(docketInfo.getTitle().isEmpty() ? swaggerProperties.getTitle() : docketInfo.getTitle())
- .description(docketInfo.getDescription().isEmpty() ? swaggerProperties.getDescription() : docketInfo.getDescription())
- .version(docketInfo.getVersion().isEmpty() ? swaggerProperties.getVersion() : docketInfo.getVersion())
- .license(docketInfo.getLicense().isEmpty() ? swaggerProperties.getLicense() : docketInfo.getLicense())
- .licenseUrl(docketInfo.getLicenseUrl().isEmpty() ? swaggerProperties.getLicenseUrl() : docketInfo.getLicenseUrl())
- .contact(
- new Contact(
- docketInfo.getContact().getName().isEmpty() ? swaggerProperties.getContact().getName() : docketInfo.getContact().getName(),
- docketInfo.getContact().getUrl().isEmpty() ? swaggerProperties.getContact().getUrl() : docketInfo.getContact().getUrl(),
- docketInfo.getContact().getEmail().isEmpty() ? swaggerProperties.getContact().getEmail() : docketInfo.getContact().getEmail()
- )
- )
- .termsOfServiceUrl(docketInfo.getTermsOfServiceUrl().isEmpty() ? swaggerProperties.getTermsOfServiceUrl() : docketInfo.getTermsOfServiceUrl())
- .build();
-
- // base-path处理
- // 当没有配置任何path的时候,解析/**
- if (docketInfo.getBasePath().isEmpty()) {
- docketInfo.getBasePath().add("/**");
- }
- List> basePath = new ArrayList<>(docketInfo.getBasePath().size());
- for (String path : docketInfo.getBasePath()) {
- basePath.add(PathSelectors.ant(path));
- }
-
- // exclude-path处理
- List> excludePath = new ArrayList<>(docketInfo.getExcludePath().size());
- for (String path : docketInfo.getExcludePath()) {
- excludePath.add(PathSelectors.ant(path));
- }
-
- Docket docket = new Docket(DocumentationType.SWAGGER_2)
- .host(swaggerProperties.getHost())
- .apiInfo(apiInfo)
- .globalOperationParameters(assemblyGlobalOperationParameters(swaggerProperties.getGlobalOperationParameters(),
- docketInfo.getGlobalOperationParameters()))
- .groupName(groupName)
- .select()
- .apis(RequestHandlerSelectors.basePackage(docketInfo.getBasePackage()))
- .paths(
- Predicates.and(
- Predicates.not(Predicates.or(excludePath)),
- Predicates.or(basePath)
- )
- )
- .build()
- .securitySchemes(securitySchemes())
- .securityContexts(securityContexts());
-
- configurableBeanFactory.registerSingleton(groupName, docket);
- docketList.add(docket);
- }
- return docketList;
- }*/
-
- /**
- * 创建 Docket对象
- *
- * @param swaggerProperties swagger配置
- * @return Docket
- */
- /*private Docket createDocket(final SwaggerProperties swaggerProperties) {
- ApiInfo apiInfo = new ApiInfoBuilder()
- .title(swaggerProperties.getTitle())
- .description(swaggerProperties.getDescription())
- .version(swaggerProperties.getVersion())
- .license(swaggerProperties.getLicense())
- .licenseUrl(swaggerProperties.getLicenseUrl())
- .contact(new Contact(swaggerProperties.getContact().getName(),
- swaggerProperties.getContact().getUrl(),
- swaggerProperties.getContact().getEmail()))
- .termsOfServiceUrl(swaggerProperties.getTermsOfServiceUrl())
- .build();
-
- // base-path处理
- // 当没有配置任何path的时候,解析/**
- if (swaggerProperties.getBasePath().isEmpty()) {
- swaggerProperties.getBasePath().add("/**");
- }
- List> basePath = new ArrayList<>();
- for (String path : swaggerProperties.getBasePath()) {
- basePath.add(PathSelectors.ant(path));
- }
-
- // exclude-path处理
- List> excludePath = new ArrayList<>();
- for (String path : swaggerProperties.getExcludePath()) {
- excludePath.add(PathSelectors.ant(path));
- }
-
- return new Docket(DocumentationType.SWAGGER_2)
- .host(swaggerProperties.getHost())
- .apiInfo(apiInfo)
- .globalOperationParameters(buildGlobalOperationParametersFromSwaggerProperties(
- swaggerProperties.getGlobalOperationParameters()))
- .select()
- .apis(RequestHandlerSelectors.basePackage(swaggerProperties.getBasePackage()))
- .paths(
- Predicates.and(
- Predicates.not(Predicates.or(excludePath)),
- Predicates.or(basePath)
- )
- )
- .build()
- .securitySchemes(securitySchemes())
- .securityContexts(securityContexts());
- }*/
-
- @Override
- public void setBeanFactory(BeanFactory beanFactory) {
- this.beanFactory = beanFactory;
- }
-
- private List securityContexts() {
- List contexts = new ArrayList<>(1);
- SecurityContext securityContext = SecurityContext.builder()
- .securityReferences(defaultAuth())
- //.forPaths(PathSelectors.regex("^(?!auth).*$"))
- .build();
- contexts.add(securityContext);
- return contexts;
- }
-
- private List defaultAuth() {
- AuthorizationScope authorizationScope = new AuthorizationScope("global", "accessEverything");
- AuthorizationScope[] authorizationScopes = new AuthorizationScope[1];
- authorizationScopes[0] = authorizationScope;
- List references = new ArrayList<>(1);
- references.add(new SecurityReference(AUTH_KEY, authorizationScopes));
- return references;
- }
-
- private List securitySchemes() {
- List apiKeys = new ArrayList<>(1);
- ApiKey apiKey = new ApiKey(AUTH_KEY, AUTH_KEY, "header");
- apiKeys.add(apiKey);
- return apiKeys;
- }
-
- private List buildGlobalOperationParametersFromSwaggerProperties(
- List globalOperationParameters) {
- List parameters = Lists.newArrayList();
-
- if (Objects.isNull(globalOperationParameters)) {
- return parameters;
- }
- for (SwaggerProperties.GlobalOperationParameter globalOperationParameter : globalOperationParameters) {
- parameters.add(new ParameterBuilder()
- .name(globalOperationParameter.getName())
- .description(globalOperationParameter.getDescription())
- .modelRef(new ModelRef(globalOperationParameter.getModelRef()))
- .parameterType(globalOperationParameter.getParameterType())
- .required(Boolean.parseBoolean(globalOperationParameter.getRequired()))
- .build());
- }
- return parameters;
- }
-
- /**
- * 局部参数按照name覆盖局部参数
- *
- * @param globalOperationParameters
- * @param docketOperationParameters
- * @return
- */
- private List assemblyGlobalOperationParameters(
- List globalOperationParameters,
- List docketOperationParameters) {
-
- if (Objects.isNull(docketOperationParameters) || docketOperationParameters.isEmpty()) {
- return buildGlobalOperationParametersFromSwaggerProperties(globalOperationParameters);
- }
-
- Set docketNames = docketOperationParameters.stream()
- .map(SwaggerProperties.GlobalOperationParameter::getName)
- .collect(Collectors.toSet());
-
- List resultOperationParameters = Lists.newArrayList();
-
- if (Objects.nonNull(globalOperationParameters)) {
- for (SwaggerProperties.GlobalOperationParameter parameter : globalOperationParameters) {
- if (!docketNames.contains(parameter.getName())) {
- resultOperationParameters.add(parameter);
- }
- }
- }
-
- resultOperationParameters.addAll(docketOperationParameters);
- return buildGlobalOperationParametersFromSwaggerProperties(resultOperationParameters);
- }
-}
diff --git a/zlt-commons/zlt-swagger2-spring-boot-starter/src/main/java/com/central/common/swagger2/SwaggerProperties.java b/zlt-commons/zlt-swagger2-spring-boot-starter/src/main/java/com/central/common/swagger2/SwaggerProperties.java
deleted file mode 100644
index 9bba37dc..00000000
--- a/zlt-commons/zlt-swagger2-spring-boot-starter/src/main/java/com/central/common/swagger2/SwaggerProperties.java
+++ /dev/null
@@ -1,114 +0,0 @@
-package com.central.common.swagger2;
-
-import lombok.Data;
-import lombok.Getter;
-import lombok.Setter;
-import org.springframework.boot.context.properties.ConfigurationProperties;
-import org.springframework.stereotype.Component;
-
-import java.util.ArrayList;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-
-/**
- * swagger2 属性配置
- *
- * @author zlt
- * @date 2018/11/18 9:17
- */
-@Data
-@ConfigurationProperties("zlt.swagger")
-@Component
-public class SwaggerProperties {
- /**是否开启swagger**/
- private Boolean enabled;
- /**标题**/
- private String title = "";
- /**描述**/
- private String description = "";
- /**版本**/
- private String version = "";
- /**许可证**/
- private String license = "";
- /**许可证URL**/
- private String licenseUrl = "";
- /**服务条款URL**/
- private String termsOfServiceUrl = "";
- /**联系人**/
- private Contact contact = new Contact();
-
- /**swagger会解析的包路径**/
- private String basePackage = "";
-
- /**swagger会解析的url规则**/
- private List basePath = new ArrayList<>();
- /**在basePath基础上需要排除的url规则**/
- private List excludePath = new ArrayList<>();
-
- /**分组文档**/
- private Map docket = new LinkedHashMap<>();
-
- /**host信息**/
- private String host = "";
-
- /**全局参数配置**/
- private List globalOperationParameters;
-
- @Setter
- @Getter
- public static class GlobalOperationParameter{
- /**参数名**/
- private String name;
-
- /**描述信息**/
- private String description;
-
- /**指定参数类型**/
- private String modelRef;
-
- /**参数放在哪个地方:header,query,path,body.form**/
- private String parameterType;
-
- /**参数是否必须传**/
- private String required;
- }
-
- @Data
- public static class DocketInfo {
- /**标题**/
- private String title = "";
- /**描述**/
- private String description = "";
- /**版本**/
- private String version = "";
- /**许可证**/
- private String license = "";
- /**许可证URL**/
- private String licenseUrl = "";
- /**服务条款URL**/
- private String termsOfServiceUrl = "";
-
- private Contact contact = new Contact();
-
- /**swagger会解析的包路径**/
- private String basePackage = "";
-
- /**swagger会解析的url规则**/
- private List basePath = new ArrayList<>();
- /**在basePath基础上需要排除的url规则**/
- private List excludePath = new ArrayList<>();
-
- private List globalOperationParameters;
- }
-
- @Data
- public static class Contact {
- /**联系人**/
- private String name = "";
- /**联系人url**/
- private String url = "";
- /**联系人email**/
- private String email = "";
- }
-}
diff --git a/zlt-commons/zlt-swagger2-spring-boot-starter/src/main/resources/META-INF/spring.factories b/zlt-commons/zlt-swagger2-spring-boot-starter/src/main/resources/META-INF/spring.factories
deleted file mode 100644
index ae9b3414..00000000
--- a/zlt-commons/zlt-swagger2-spring-boot-starter/src/main/resources/META-INF/spring.factories
+++ /dev/null
@@ -1,2 +0,0 @@
-org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
-com.central.common.swagger2.SwaggerAutoConfiguration
\ No newline at end of file
diff --git a/zlt-demo/resources-server-demo/src/main/java/org/zlt/config/MyResourceConfig.java b/zlt-demo/resources-server-demo/src/main/java/org/zlt/config/MyResourceConfig.java
index 1d1af95d..482aef1e 100644
--- a/zlt-demo/resources-server-demo/src/main/java/org/zlt/config/MyResourceConfig.java
+++ b/zlt-demo/resources-server-demo/src/main/java/org/zlt/config/MyResourceConfig.java
@@ -1,8 +1,7 @@
package org.zlt.config;
-import com.central.oauth2.common.config.DefaultResourceServerConf;
import org.springframework.context.annotation.Configuration;
-import org.springframework.security.oauth2.config.annotation.web.configuration.EnableResourceServer;
+//import org.springframework.security.oauth2.config.annotation.web.configuration.EnableResourceServer;
/**
* security资源服务器配置
@@ -14,7 +13,7 @@ import org.springframework.security.oauth2.config.annotation.web.configuration.E
* Blog: http://zlt2000.gitee.io
* Github: https://github.com/zlt2000
*/
-@Configuration
+/*@Configuration
@EnableResourceServer
public class MyResourceConfig extends DefaultResourceServerConf {
-}
+}*/
diff --git a/zlt-demo/sso-demo/ss-sso/src/main/java/com/sso/demo/config/SecurityConfig.java b/zlt-demo/sso-demo/ss-sso/src/main/java/com/sso/demo/config/SecurityConfig.java
index 99d1bd45..838e54b7 100644
--- a/zlt-demo/sso-demo/ss-sso/src/main/java/com/sso/demo/config/SecurityConfig.java
+++ b/zlt-demo/sso-demo/ss-sso/src/main/java/com/sso/demo/config/SecurityConfig.java
@@ -31,14 +31,14 @@ public class SecurityConfig {
@Bean
public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
- http.authorizeHttpRequests().anyRequest().authenticated()
+ /*http.authorizeHttpRequests().anyRequest().authenticated()
.and()
.csrf().disable()
.logout()
.logoutSuccessHandler(ssoLogoutSuccessHandler);
if (StrUtil.isNotEmpty(loginPath)) {
http.formLogin().loginProcessingUrl(loginPath);
- }
+ }*/
return http.build();
}
}
\ No newline at end of file
diff --git a/zlt-demo/websocket-demo/src/main/java/org/zlt/config/MyResourceConfig.java b/zlt-demo/websocket-demo/src/main/java/org/zlt/config/MyResourceConfig.java
index 8c00d035..6a4ac97a 100644
--- a/zlt-demo/websocket-demo/src/main/java/org/zlt/config/MyResourceConfig.java
+++ b/zlt-demo/websocket-demo/src/main/java/org/zlt/config/MyResourceConfig.java
@@ -1,8 +1,6 @@
package org.zlt.config;
-import com.central.oauth2.common.config.DefaultResourceServerConf;
import org.springframework.context.annotation.Configuration;
-import org.springframework.security.oauth2.config.annotation.web.configuration.EnableResourceServer;
/**
* security资源服务器配置
@@ -14,7 +12,9 @@ import org.springframework.security.oauth2.config.annotation.web.configuration.E
* Blog: http://zlt2000.gitee.io
* Github: https://github.com/zlt2000
*/
+/*
@Configuration
@EnableResourceServer
public class MyResourceConfig extends DefaultResourceServerConf {
}
+*/
diff --git a/zlt-doc/sql/oauth-center.sql b/zlt-doc/sql/oauth-center.sql
index 627de1d8..8211ce8f 100644
--- a/zlt-doc/sql/oauth-center.sql
+++ b/zlt-doc/sql/oauth-center.sql
@@ -22,8 +22,7 @@ CREATE TABLE `oauth_client_details` (
`create_time` datetime(0) NULL DEFAULT NULL,
`update_time` datetime(0) NULL DEFAULT NULL,
`client_name` varchar(128) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT '' COMMENT '应用名称',
- `support_id_token` tinyint(1) DEFAULT 1 COMMENT '是否支持id_token',
- `id_token_validity` int(11) DEFAULT 60 COMMENT 'id_token有效期',
+ `token_format` varchar(10) not null DEFAULT 'reference' COMMENT 'token格式: reference 引用令牌(不透明), self-contained 自包含令牌(jwt))',
`creator_id` int(11) COMMENT '创建人id',
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 11 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
@@ -31,6 +30,6 @@ CREATE TABLE `oauth_client_details` (
-- ----------------------------
-- Records of oauth_client_details
-- ----------------------------
-INSERT INTO `oauth_client_details` VALUES (1, 'webApp', NULL, '$2a$10$06msMGYRH8nrm4iVnKFNKOoddB8wOwymVhbUzw/d3ZixD7Nq8ot72', 'webApp', 'app', 'authorization_code,password,refresh_token,client_credentials,implicit,password_code,openId,mobile_password', 'http://127.0.0.1:8082/callback.html', NULL, 3600, NULL, '{"LOGOUT_NOTIFY_URL_LIST":"http://127.0.0.1:8082/logoutNotify"}', 'true', NULL, NULL, 'pc端', 1, 60, 1);
-INSERT INTO `oauth_client_details` VALUES (2, 'app', NULL, '$2a$10$i3F515wEDiB4Gvj9ym9Prui0dasRttEUQ9ink4Wpgb4zEDCAlV8zO', 'app', 'app', 'authorization_code,password,refresh_token', 'http://127.0.0.1:8081/callback.html', NULL, 3600, NULL, '{"LOGOUT_NOTIFY_URL_LIST":"http://127.0.0.1:8081/logoutNotify"}', 'true', NULL, NULL, '移动端', 1, 60, 1);
-INSERT INTO `oauth_client_details` VALUES (3, 'zlt', NULL, '$2a$10$/o.wuORzVcXaezmYVzwYMuoY7qeWXBALwQmkskXD/7C6rqfCyPrna', 'zlt', 'all', 'authorization_code,password,refresh_token,client_credentials', 'http://127.0.0.1:8080/singleLogin', NULL, 3600, 28800, '{}', 'true', '2018-12-27 00:50:30', '2018-12-27 00:50:30', '第三方应用', 1, 60, 1);
\ No newline at end of file
+INSERT INTO `oauth_client_details` VALUES (1, 'webApp', NULL, '$2a$10$06msMGYRH8nrm4iVnKFNKOoddB8wOwymVhbUzw/d3ZixD7Nq8ot72', 'webApp', 'app', 'authorization_code,password,refresh_token,client_credentials,implicit,password_code,openId,mobile_password', 'http://127.0.0.1:8082/callback.html', NULL, 3600, NULL, '{"LOGOUT_NOTIFY_URL_LIST":"http://127.0.0.1:8082/logoutNotify"}', 'true', NULL, NULL, 'pc端', 'reference', 1);
+INSERT INTO `oauth_client_details` VALUES (2, 'app', NULL, '$2a$10$i3F515wEDiB4Gvj9ym9Prui0dasRttEUQ9ink4Wpgb4zEDCAlV8zO', 'app', 'app', 'authorization_code,password,refresh_token', 'http://127.0.0.1:8081/callback.html', NULL, 3600, NULL, '{"LOGOUT_NOTIFY_URL_LIST":"http://127.0.0.1:8081/logoutNotify"}', 'true', NULL, NULL, '移动端', 'reference', 1);
+INSERT INTO `oauth_client_details` VALUES (3, 'zlt', NULL, '$2a$10$/o.wuORzVcXaezmYVzwYMuoY7qeWXBALwQmkskXD/7C6rqfCyPrna', 'zlt', 'all', 'authorization_code,password,refresh_token,client_credentials', 'http://127.0.0.1:8080/singleLogin', NULL, 3600, 28800, '{}', 'true', '2018-12-27 00:50:30', '2018-12-27 00:50:30', '第三方应用', 'reference', 1);
\ No newline at end of file
diff --git a/zlt-doc/版本升级_sql/旧版本升级v6.0.0.sql b/zlt-doc/版本升级_sql/旧版本升级v6.0.0.sql
new file mode 100644
index 00000000..4085eef7
--- /dev/null
+++ b/zlt-doc/版本升级_sql/旧版本升级v6.0.0.sql
@@ -0,0 +1,5 @@
+------------更新语句
+Use `oauth-center`;
+alter table oauth_client_details add token_format varchar(10) not null DEFAULT 'reference' COMMENT 'token格式: reference 引用令牌(不透明), self-contained 自包含令牌(jwt))';
+alter table oauth_client_details drop column support_id_token;
+alter table oauth_client_details drop column id_token_validity;
\ No newline at end of file
diff --git a/zlt-gateway/sc-gateway/pom.xml b/zlt-gateway/sc-gateway/pom.xml
index 88c12ce5..a1300774 100644
--- a/zlt-gateway/sc-gateway/pom.xml
+++ b/zlt-gateway/sc-gateway/pom.xml
@@ -76,7 +76,6 @@
com.github.xiaoymin
knife4j-gateway-spring-boot-starter
- 4.2.0
diff --git a/zlt-gateway/sc-gateway/src/main/java/com/central/gateway/auth/CustomAuthenticationManager.java b/zlt-gateway/sc-gateway/src/main/java/com/central/gateway/auth/CustomAuthenticationManager.java
deleted file mode 100644
index d4263708..00000000
--- a/zlt-gateway/sc-gateway/src/main/java/com/central/gateway/auth/CustomAuthenticationManager.java
+++ /dev/null
@@ -1,49 +0,0 @@
-package com.central.gateway.auth;
-
-import org.springframework.security.authentication.ReactiveAuthenticationManager;
-import org.springframework.security.core.Authentication;
-import org.springframework.security.oauth2.common.OAuth2AccessToken;
-import org.springframework.security.oauth2.common.exceptions.InvalidTokenException;
-import org.springframework.security.oauth2.provider.OAuth2Authentication;
-import org.springframework.security.oauth2.provider.token.TokenStore;
-import org.springframework.security.oauth2.server.resource.BearerTokenAuthenticationToken;
-import reactor.core.publisher.Mono;
-
-/**
- * @author zlt
- * @date 2019/10/6
- *
- * Blog: http://zlt2000.gitee.io
- * Github: https://github.com/zlt2000
- */
-public class CustomAuthenticationManager implements ReactiveAuthenticationManager {
- private TokenStore tokenStore;
-
- public CustomAuthenticationManager(TokenStore tokenStore) {
- this.tokenStore = tokenStore;
- }
-
- @Override
- public Mono authenticate(Authentication authentication) {
- return Mono.justOrEmpty(authentication)
- .filter(a -> a instanceof BearerTokenAuthenticationToken)
- .cast(BearerTokenAuthenticationToken.class)
- .map(BearerTokenAuthenticationToken::getToken)
- .flatMap((accessTokenValue -> {
- OAuth2AccessToken accessToken = tokenStore.readAccessToken(accessTokenValue);
- if (accessToken == null) {
- return Mono.error(new InvalidTokenException("Invalid access token: " + accessTokenValue));
- } else if (accessToken.isExpired()) {
- tokenStore.removeAccessToken(accessToken);
- return Mono.error(new InvalidTokenException("Access token expired: " + accessTokenValue));
- }
-
- OAuth2Authentication result = tokenStore.readAuthentication(accessToken);
- if (result == null) {
- return Mono.error(new InvalidTokenException("Invalid access token: " + accessTokenValue));
- }
- return Mono.just(result);
- }))
- .cast(Authentication.class);
- }
-}
diff --git a/zlt-gateway/sc-gateway/src/main/java/com/central/gateway/auth/CustomServerWebExchangeMatchers.java b/zlt-gateway/sc-gateway/src/main/java/com/central/gateway/auth/CustomServerWebExchangeMatchers.java
deleted file mode 100644
index a74201d8..00000000
--- a/zlt-gateway/sc-gateway/src/main/java/com/central/gateway/auth/CustomServerWebExchangeMatchers.java
+++ /dev/null
@@ -1,38 +0,0 @@
-package com.central.gateway.auth;
-
-import com.central.oauth2.common.properties.SecurityProperties;
-import org.springframework.security.web.server.util.matcher.ServerWebExchangeMatcher;
-import org.springframework.util.AntPathMatcher;
-import org.springframework.web.server.ServerWebExchange;
-import reactor.core.publisher.Mono;
-
-/**
- * 自定义 ServerWebExchangeMatcher
- * 解决只要请求携带access_token,排除鉴权的url依然会被拦截
- *
- * @author zlt
- * @version 1.0
- * @date 2022/6/10
- *
- * Blog: http://zlt2000.gitee.io
- * Github: https://github.com/zlt2000
- */
-public class CustomServerWebExchangeMatchers implements ServerWebExchangeMatcher {
- private final SecurityProperties securityProperties;
-
- private final AntPathMatcher antPathMatcher = new AntPathMatcher();
-
- public CustomServerWebExchangeMatchers(SecurityProperties securityProperties) {
- this.securityProperties = securityProperties;
- }
-
- @Override
- public Mono matches(ServerWebExchange exchange) {
- for (String url : securityProperties.getIgnore().getUrls()) {
- if (antPathMatcher.match(url, exchange.getRequest().getURI().getPath())) {
- return MatchResult.notMatch();
- }
- }
- return MatchResult.match();
- }
-}
diff --git a/zlt-gateway/sc-gateway/src/main/java/com/central/gateway/auth/JsonAccessDeniedHandler.java b/zlt-gateway/sc-gateway/src/main/java/com/central/gateway/auth/JsonAccessDeniedHandler.java
deleted file mode 100644
index 9223ede2..00000000
--- a/zlt-gateway/sc-gateway/src/main/java/com/central/gateway/auth/JsonAccessDeniedHandler.java
+++ /dev/null
@@ -1,26 +0,0 @@
-package com.central.gateway.auth;
-
-import com.central.common.utils.WebfluxResponseUtil;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.http.HttpStatus;
-import org.springframework.security.access.AccessDeniedException;
-import org.springframework.security.web.server.authorization.ServerAccessDeniedHandler;
-import org.springframework.web.server.ServerWebExchange;
-import reactor.core.publisher.Mono;
-
-/**
- * 403拒绝访问异常处理,转换为JSON
- *
- * @author zlt
- * @date 2019/10/7
- *
- * Blog: http://zlt2000.gitee.io
- * Github: https://github.com/zlt2000
- */
-@Slf4j
-public class JsonAccessDeniedHandler implements ServerAccessDeniedHandler {
- @Override
- public Mono handle(ServerWebExchange exchange, AccessDeniedException e) {
- return WebfluxResponseUtil.responseFailed(exchange, HttpStatus.FORBIDDEN.value(), e.getMessage());
- }
-}
diff --git a/zlt-gateway/sc-gateway/src/main/java/com/central/gateway/auth/JsonAuthenticationEntryPoint.java b/zlt-gateway/sc-gateway/src/main/java/com/central/gateway/auth/JsonAuthenticationEntryPoint.java
deleted file mode 100644
index 45627bad..00000000
--- a/zlt-gateway/sc-gateway/src/main/java/com/central/gateway/auth/JsonAuthenticationEntryPoint.java
+++ /dev/null
@@ -1,26 +0,0 @@
-package com.central.gateway.auth;
-
-import com.central.common.utils.WebfluxResponseUtil;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.http.HttpStatus;
-import org.springframework.security.core.AuthenticationException;
-import org.springframework.security.web.server.ServerAuthenticationEntryPoint;
-import org.springframework.web.server.ServerWebExchange;
-import reactor.core.publisher.Mono;
-
-/**
- * 401未授权异常处理,转换为JSON
- *
- * @author zlt
- * @date 2019/10/7
- *
- * Blog: http://zlt2000.gitee.io
- * Github: https://github.com/zlt2000
- */
-@Slf4j
-public class JsonAuthenticationEntryPoint implements ServerAuthenticationEntryPoint {
- @Override
- public Mono commence(ServerWebExchange exchange, AuthenticationException e) {
- return WebfluxResponseUtil.responseFailed(exchange, HttpStatus.UNAUTHORIZED.value(), e.getMessage());
- }
-}
diff --git a/zlt-gateway/sc-gateway/src/main/java/com/central/gateway/auth/Oauth2AuthSuccessHandler.java b/zlt-gateway/sc-gateway/src/main/java/com/central/gateway/auth/Oauth2AuthSuccessHandler.java
deleted file mode 100644
index 88576fac..00000000
--- a/zlt-gateway/sc-gateway/src/main/java/com/central/gateway/auth/Oauth2AuthSuccessHandler.java
+++ /dev/null
@@ -1,54 +0,0 @@
-package com.central.gateway.auth;
-
-import cn.hutool.core.collection.CollectionUtil;
-import cn.hutool.core.util.StrUtil;
-import com.central.common.constant.SecurityConstants;
-import com.central.common.model.SysUser;
-import com.central.oauth2.common.util.AuthUtils;
-import org.springframework.http.server.reactive.ServerHttpRequest;
-import org.springframework.security.core.Authentication;
-import org.springframework.security.oauth2.provider.OAuth2Authentication;
-import org.springframework.security.web.server.WebFilterExchange;
-import org.springframework.security.web.server.authentication.ServerAuthenticationSuccessHandler;
-import org.springframework.util.LinkedMultiValueMap;
-import org.springframework.util.MultiValueMap;
-import org.springframework.web.server.ServerWebExchange;
-import reactor.core.publisher.Mono;
-
-/**
- * 认证成功处理类
- *
- * @author zlt
- * @date 2019/10/7
- *
- * Blog: http://zlt2000.gitee.io
- * Github: https://github.com/zlt2000
- */
-public class Oauth2AuthSuccessHandler implements ServerAuthenticationSuccessHandler {
- @Override
- public Mono onAuthenticationSuccess(WebFilterExchange webFilterExchange, Authentication authentication) {
- MultiValueMap headerValues = new LinkedMultiValueMap<>(4);
- Object principal = authentication.getPrincipal();
- //客户端模式只返回一个clientId
- if (principal instanceof SysUser) {
- SysUser user = (SysUser)authentication.getPrincipal();
- headerValues.add(SecurityConstants.USER_ID_HEADER, String.valueOf(user.getId()));
- headerValues.add(SecurityConstants.USER_HEADER, user.getUsername());
- }
- OAuth2Authentication oauth2Authentication = (OAuth2Authentication)authentication;
- String clientId = oauth2Authentication.getOAuth2Request().getClientId();
- headerValues.add(SecurityConstants.TENANT_HEADER, clientId);
- headerValues.add(SecurityConstants.ROLE_HEADER, CollectionUtil.join(authentication.getAuthorities(), ","));
- String accountType = AuthUtils.getAccountType(oauth2Authentication.getUserAuthentication());
- if (StrUtil.isNotEmpty(accountType)) {
- headerValues.add(SecurityConstants.ACCOUNT_TYPE_HEADER, accountType);
- }
- ServerWebExchange exchange = webFilterExchange.getExchange();
- ServerHttpRequest serverHttpRequest = exchange.getRequest().mutate()
- .headers(h -> h.addAll(headerValues))
- .build();
-
- ServerWebExchange build = exchange.mutate().request(serverHttpRequest).build();
- return webFilterExchange.getChain().filter(build);
- }
-}
diff --git a/zlt-gateway/sc-gateway/src/main/java/com/central/gateway/auth/PermissionAuthManager.java b/zlt-gateway/sc-gateway/src/main/java/com/central/gateway/auth/PermissionAuthManager.java
deleted file mode 100644
index 0bd0af65..00000000
--- a/zlt-gateway/sc-gateway/src/main/java/com/central/gateway/auth/PermissionAuthManager.java
+++ /dev/null
@@ -1,56 +0,0 @@
-package com.central.gateway.auth;
-
-import com.central.common.model.SysMenu;
-import com.central.gateway.feign.AsynMenuService;
-import com.central.oauth2.common.service.impl.DefaultPermissionServiceImpl;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.http.server.reactive.ServerHttpRequest;
-import org.springframework.security.authorization.AuthorizationDecision;
-import org.springframework.security.authorization.ReactiveAuthorizationManager;
-import org.springframework.security.core.Authentication;
-import org.springframework.security.web.server.authorization.AuthorizationContext;
-import org.springframework.stereotype.Component;
-import org.springframework.web.server.ServerWebExchange;
-import reactor.core.publisher.Mono;
-
-import javax.annotation.Resource;
-import java.util.Collections;
-import java.util.List;
-import java.util.concurrent.Future;
-
-/**
- * url权限认证
- *
- * @author zlt
- * @date 2019/10/6
- *
- * Blog: http://zlt2000.gitee.io
- * Github: https://github.com/zlt2000
- */
-@Slf4j
-@Component
-public class PermissionAuthManager extends DefaultPermissionServiceImpl implements ReactiveAuthorizationManager {
- @Resource
- private AsynMenuService asynMenuService;
-
- @Override
- public Mono check(Mono authentication, AuthorizationContext authorizationContext) {
- return authentication.map(auth -> {
- ServerWebExchange exchange = authorizationContext.getExchange();
- ServerHttpRequest request = exchange.getRequest();
- boolean isPermission = super.hasPermission(auth, request.getMethodValue(), request.getURI().getPath());
- return new AuthorizationDecision(isPermission);
- }).defaultIfEmpty(new AuthorizationDecision(false));
- }
-
- @Override
- public List findMenuByRoleCodes(String roleCodes) {
- Future> futureResult = asynMenuService.findByRoleCodes(roleCodes);
- try {
- return futureResult.get();
- } catch (Exception e) {
- log.error("asynMenuService.findMenuByRoleCodes-error", e);
- }
- return Collections.emptyList();
- }
-}
\ No newline at end of file
diff --git a/zlt-gateway/sc-gateway/src/main/java/com/central/gateway/config/ResourceServerConfiguration.java b/zlt-gateway/sc-gateway/src/main/java/com/central/gateway/config/ResourceServerConfiguration.java
deleted file mode 100644
index 34305a81..00000000
--- a/zlt-gateway/sc-gateway/src/main/java/com/central/gateway/config/ResourceServerConfiguration.java
+++ /dev/null
@@ -1,71 +0,0 @@
-package com.central.gateway.config;
-
-import com.central.gateway.auth.*;
-import com.central.oauth2.common.properties.SecurityProperties;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.http.HttpMethod;
-import org.springframework.security.authentication.ReactiveAuthenticationManager;
-import org.springframework.security.config.annotation.web.reactive.EnableWebFluxSecurity;
-import org.springframework.security.config.web.server.SecurityWebFiltersOrder;
-import org.springframework.security.config.web.server.ServerHttpSecurity;
-import org.springframework.security.oauth2.provider.token.TokenStore;
-import org.springframework.security.oauth2.server.resource.web.server.authentication.ServerBearerTokenAuthenticationConverter;
-import org.springframework.security.web.server.SecurityWebFilterChain;
-import org.springframework.security.web.server.authentication.AuthenticationWebFilter;
-import org.springframework.security.web.server.authentication.ServerAuthenticationEntryPointFailureHandler;
-
-/**
- * 资源服务器配置
- *
- * @author zlt
- * @date 2019/10/5
- *
- * Blog: http://zlt2000.gitee.io
- * Github: https://github.com/zlt2000
- */
-@Configuration
-@EnableWebFluxSecurity
-public class ResourceServerConfiguration {
- @Bean
- public SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http
- , SecurityProperties securityProperties, TokenStore tokenStore, PermissionAuthManager permissionAuthManager) {
- //认证处理器
- ReactiveAuthenticationManager customAuthenticationManager = new CustomAuthenticationManager(tokenStore);
- JsonAuthenticationEntryPoint entryPoint = new JsonAuthenticationEntryPoint();
- //token转换器
- ServerBearerTokenAuthenticationConverter tokenAuthenticationConverter = new ServerBearerTokenAuthenticationConverter();
- tokenAuthenticationConverter.setAllowUriQueryParameter(true);
- //oauth2认证过滤器
- AuthenticationWebFilter oauth2Filter = new AuthenticationWebFilter(customAuthenticationManager);
- oauth2Filter.setServerAuthenticationConverter(tokenAuthenticationConverter);
- oauth2Filter.setAuthenticationFailureHandler(new ServerAuthenticationEntryPointFailureHandler(entryPoint));
- oauth2Filter.setAuthenticationSuccessHandler(new Oauth2AuthSuccessHandler());
- oauth2Filter.setRequiresAuthenticationMatcher(new CustomServerWebExchangeMatchers(securityProperties));
- http.addFilterAt(oauth2Filter, SecurityWebFiltersOrder.AUTHENTICATION);
-
- ServerHttpSecurity.AuthorizeExchangeSpec authorizeExchange = http.authorizeExchange();
- if (securityProperties.getAuth().getHttpUrls().length > 0) {
- authorizeExchange.pathMatchers(securityProperties.getAuth().getHttpUrls()).authenticated();
- }
- if (securityProperties.getIgnore().getUrls().length > 0) {
- authorizeExchange.pathMatchers(securityProperties.getIgnore().getUrls()).permitAll();
- }
- authorizeExchange
- .pathMatchers(HttpMethod.OPTIONS).permitAll()
- .anyExchange()
- .access(permissionAuthManager)
- .and()
- .exceptionHandling()
- .accessDeniedHandler(new JsonAccessDeniedHandler())
- .authenticationEntryPoint(entryPoint)
- .and()
- .headers()
- .frameOptions()
- .disable()
- .and()
- .httpBasic().disable()
- .csrf().disable();
- return http.build();
- }
-}
diff --git a/zlt-gateway/sc-gateway/src/main/resources/application.yml b/zlt-gateway/sc-gateway/src/main/resources/application.yml
index f7f69bf3..dbdfba45 100644
--- a/zlt-gateway/sc-gateway/src/main/resources/application.yml
+++ b/zlt-gateway/sc-gateway/src/main/resources/application.yml
@@ -82,6 +82,12 @@ spring:
# filter:
# enabled: true
+knife4j:
+ gateway:
+ enabled: true
+ discover:
+ excluded-services: ${spring.application.name}
+
zlt:
swagger-agg:
generate-routes: user,file
diff --git a/zlt-monitor/log-center/pom.xml b/zlt-monitor/log-center/pom.xml
index eb2d27bf..45909e61 100644
--- a/zlt-monitor/log-center/pom.xml
+++ b/zlt-monitor/log-center/pom.xml
@@ -23,8 +23,8 @@
- com.zlt
- zlt-swagger2-spring-boot-starter
+ com.github.xiaoymin
+ knife4j-openapi3-jakarta-spring-boot-starter
com.zlt
diff --git a/zlt-monitor/log-center/src/main/java/com/central/log/controller/AggregationController.java b/zlt-monitor/log-center/src/main/java/com/central/log/controller/AggregationController.java
index 8dc77caa..203f544e 100644
--- a/zlt-monitor/log-center/src/main/java/com/central/log/controller/AggregationController.java
+++ b/zlt-monitor/log-center/src/main/java/com/central/log/controller/AggregationController.java
@@ -1,7 +1,8 @@
package com.central.log.controller;
import com.central.search.client.service.IQueryService;
-import io.swagger.annotations.ApiOperation;
+import io.swagger.v3.oas.annotations.Operation;
+import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
@@ -14,12 +15,13 @@ import java.util.Map;
* @author zlt
* @date 2019/5/8
*/
+@Tag(name = "访问统计")
@RestController
public class AggregationController {
@Autowired
private IQueryService queryService;
- @ApiOperation(value = "访问统计")
+ @Operation(summary = "访问统计")
@GetMapping(value = "/requestStat")
public Map requestStatAgg() {
return queryService.requestStatAgg("point-log-*","request-statistics");
diff --git a/zlt-monitor/log-center/src/main/java/com/central/log/controller/AuditLogController.java b/zlt-monitor/log-center/src/main/java/com/central/log/controller/AuditLogController.java
index 5631aa13..4d3bce74 100644
--- a/zlt-monitor/log-center/src/main/java/com/central/log/controller/AuditLogController.java
+++ b/zlt-monitor/log-center/src/main/java/com/central/log/controller/AuditLogController.java
@@ -4,9 +4,8 @@ import com.central.common.model.PageResult;
import com.central.search.client.service.IQueryService;
import com.central.search.model.SearchDto;
import com.fasterxml.jackson.databind.JsonNode;
-import io.swagger.annotations.ApiImplicitParam;
-import io.swagger.annotations.ApiImplicitParams;
-import io.swagger.annotations.ApiOperation;
+import io.swagger.v3.oas.annotations.Operation;
+import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
@@ -19,6 +18,7 @@ import org.springframework.web.bind.annotation.RestController;
* Blog: http://zlt2000.gitee.io
* Github: https://github.com/zlt2000
*/
+@Tag(name = "审计日志")
@RestController
public class AuditLogController {
private final IQueryService queryService;
@@ -27,12 +27,7 @@ public class AuditLogController {
this.queryService = queryService;
}
- @ApiOperation(value = "审计日志全文搜索列表")
- @ApiImplicitParams({
- @ApiImplicitParam(name = "page", value = "分页起始位置", required = true, dataType = "Integer"),
- @ApiImplicitParam(name = "limit", value = "分页结束位置", required = true, dataType = "Integer"),
- @ApiImplicitParam(name = "queryStr", value = "搜索关键字", dataType = "String")
- })
+ @Operation(summary = "审计日志全文搜索列表")
@GetMapping(value = "/auditLog")
public PageResult getPage(SearchDto searchDto) {
searchDto.setIsHighlighter(true);
diff --git a/zlt-monitor/log-center/src/main/java/com/central/log/controller/SlowQueryLogController.java b/zlt-monitor/log-center/src/main/java/com/central/log/controller/SlowQueryLogController.java
index 99d5a3f6..6ba0fae7 100644
--- a/zlt-monitor/log-center/src/main/java/com/central/log/controller/SlowQueryLogController.java
+++ b/zlt-monitor/log-center/src/main/java/com/central/log/controller/SlowQueryLogController.java
@@ -4,9 +4,8 @@ import com.central.common.model.PageResult;
import com.central.search.client.service.IQueryService;
import com.central.search.model.SearchDto;
import com.fasterxml.jackson.databind.JsonNode;
-import io.swagger.annotations.ApiImplicitParam;
-import io.swagger.annotations.ApiImplicitParams;
-import io.swagger.annotations.ApiOperation;
+import io.swagger.v3.oas.annotations.Operation;
+import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
@@ -16,17 +15,13 @@ import org.springframework.web.bind.annotation.RestController;
*
* @author zlt
*/
+@Tag(name = "慢查询日志")
@RestController
public class SlowQueryLogController {
@Autowired
private IQueryService queryService;
- @ApiOperation(value = "慢sql日志全文搜索列表")
- @ApiImplicitParams({
- @ApiImplicitParam(name = "page", value = "分页起始位置", required = true, dataType = "Integer"),
- @ApiImplicitParam(name = "limit", value = "分页结束位置", required = true, dataType = "Integer"),
- @ApiImplicitParam(name = "queryStr", value = "搜索关键字", dataType = "String")
- })
+ @Operation(summary = "慢sql日志全文搜索列表")
@GetMapping(value = "/slowQueryLog")
public PageResult getPage(SearchDto searchDto) {
searchDto.setIsHighlighter(true);
diff --git a/zlt-monitor/log-center/src/main/java/com/central/log/controller/SysLogController.java b/zlt-monitor/log-center/src/main/java/com/central/log/controller/SysLogController.java
index 1a483ee2..6869e882 100644
--- a/zlt-monitor/log-center/src/main/java/com/central/log/controller/SysLogController.java
+++ b/zlt-monitor/log-center/src/main/java/com/central/log/controller/SysLogController.java
@@ -6,9 +6,8 @@ import com.central.log.service.TraceLogService;
import com.central.search.client.service.IQueryService;
import com.central.search.model.SearchDto;
import com.fasterxml.jackson.databind.JsonNode;
-import io.swagger.annotations.ApiImplicitParam;
-import io.swagger.annotations.ApiImplicitParams;
-import io.swagger.annotations.ApiOperation;
+import io.swagger.v3.oas.annotations.Operation;
+import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
@@ -20,6 +19,7 @@ import java.util.*;
*
* @author zlt
*/
+@Tag(name = "系统日志")
@RestController
public class SysLogController {
/**
@@ -33,27 +33,13 @@ public class SysLogController {
@Resource
private TraceLogService traceLogService;
- @ApiOperation(value = "系统日志全文搜索列表")
- @ApiImplicitParams({
- @ApiImplicitParam(name = "page", value = "分页起始位置", required = true, dataType = "Integer"),
- @ApiImplicitParam(name = "limit", value = "分页结束位置", required = true, dataType = "Integer"),
- @ApiImplicitParam(name = "queryStr", value = "搜索关键字", dataType = "String"),
- @ApiImplicitParam(name = "sortCol", value = "排序字段", dataType = "String"),
- @ApiImplicitParam(name = "sortOrder", value = "排序顺序", dataType = "String"),
- @ApiImplicitParam(name = "isHighlighter", value = "是否显示高亮", dataType = "String")
- })
+ @Operation(summary = "系统日志全文搜索列表")
@GetMapping(value = "/sysLog")
public PageResult sysLog(SearchDto searchDto) {
return queryService.strQuery(SYS_LOG_INDEXNAME, searchDto);
}
- @ApiOperation(value = "系统日志链路列表")
- @ApiImplicitParams({
- @ApiImplicitParam(name = "queryStr", value = "搜索关键字", dataType = "String"),
- @ApiImplicitParam(name = "sortCol", value = "排序字段", dataType = "String"),
- @ApiImplicitParam(name = "sortOrder", value = "排序顺序", dataType = "String"),
- @ApiImplicitParam(name = "isHighlighter", value = "是否显示高亮", dataType = "String")
- })
+ @Operation(summary = "系统日志链路列表")
@GetMapping(value = "/traceLog")
public PageResult traceLog(SearchDto searchDto) {
PageResult pageResult = queryService.strQuery(SYS_LOG_INDEXNAME, searchDto);
diff --git a/zlt-uaa/pom.xml b/zlt-uaa/pom.xml
index b21c593f..5efd2379 100644
--- a/zlt-uaa/pom.xml
+++ b/zlt-uaa/pom.xml
@@ -33,14 +33,9 @@
com.zlt
zlt-loadbalancer-spring-boot-starter
-
com.github.xiaoymin
knife4j-openapi3-jakarta-spring-boot-starter
- 4.2.0
com.zlt
@@ -67,11 +62,6 @@
commons-io
commons-io
-
-
- com.github.whvcse
- easy-captcha
-
org.springframework.boot
@@ -111,10 +101,6 @@
org.apache.tomcat.embed
tomcat-embed-core
-
- javax.servlet
- javax.servlet-api
-
diff --git a/zlt-uaa/src/main/java/com/central/oauth/controller/ValidateCodeController.java b/zlt-uaa/src/main/java/com/central/oauth/controller/ValidateCodeController.java
index dd7170ce..a387b76d 100644
--- a/zlt-uaa/src/main/java/com/central/oauth/controller/ValidateCodeController.java
+++ b/zlt-uaa/src/main/java/com/central/oauth/controller/ValidateCodeController.java
@@ -1,11 +1,11 @@
package com.central.oauth.controller;
+import cn.hutool.captcha.CaptchaUtil;
+import cn.hutool.captcha.LineCaptcha;
import com.central.common.constant.SecurityConstants;
import com.central.common.model.Result;
import com.central.oauth.service.IValidateCodeService;
-import com.wf.captcha.base.Captcha;
-import com.wf.captcha.GifCaptcha;
-import com.wf.captcha.utils.CaptchaUtil;
+import jakarta.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.util.Assert;
@@ -13,7 +13,6 @@ import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.ResponseBody;
-import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
/**
@@ -33,17 +32,19 @@ public class ValidateCodeController {
*/
@GetMapping(SecurityConstants.DEFAULT_VALIDATE_CODE_URL_PREFIX + "/{deviceId}")
public void createCode(@PathVariable String deviceId, HttpServletResponse response) throws IOException {
+ Assert.notNull(deviceId, "机器码不能为空");
Assert.notNull(deviceId, "机器码不能为空");
// 设置请求头为输出图片类型
- CaptchaUtil.setHeader(response);
- // 三个参数分别为宽、高、位数
- GifCaptcha gifCaptcha = new GifCaptcha(100, 35, 4);
- // 设置类型:字母数字混合
- gifCaptcha.setCharType(Captcha.TYPE_DEFAULT);
+ response.setContentType("image/jpeg");
+ response.setHeader("Pragma", "no-cache");
+ response.setHeader("Cache-Control", "no-cache");
+ response.setDateHeader("Expires", 0);
+ // 三个参数分别为宽、高、验证码字符数、干扰线宽度
+ LineCaptcha captcha = CaptchaUtil.createLineCaptcha(100, 35, 4, 10);
// 保存验证码
- validateCodeService.saveImageCode(deviceId, gifCaptcha.text().toLowerCase());
+ validateCodeService.saveImageCode(deviceId, captcha.getCode().toLowerCase());
// 输出图片流
- gifCaptcha.out(response.getOutputStream());
+ captcha.write(response.getOutputStream());
}
/**
diff --git a/zlt-uaa/src/main/java/com/central/oauth/service/IValidateCodeService.java b/zlt-uaa/src/main/java/com/central/oauth/service/IValidateCodeService.java
index 8003650f..3f69a98b 100644
--- a/zlt-uaa/src/main/java/com/central/oauth/service/IValidateCodeService.java
+++ b/zlt-uaa/src/main/java/com/central/oauth/service/IValidateCodeService.java
@@ -17,7 +17,7 @@ public interface IValidateCodeService {
*/
void saveImageCode(String deviceId, String imageCode);
- Result sendSmsCode(String mobile);
+ Result sendSmsCode(String mobile);
/**
* 获取验证码
diff --git a/zlt-uaa/src/main/java/com/central/oauth/service/impl/ValidateCodeServiceImpl.java b/zlt-uaa/src/main/java/com/central/oauth/service/impl/ValidateCodeServiceImpl.java
index 08927bb2..04cce984 100644
--- a/zlt-uaa/src/main/java/com/central/oauth/service/impl/ValidateCodeServiceImpl.java
+++ b/zlt-uaa/src/main/java/com/central/oauth/service/impl/ValidateCodeServiceImpl.java
@@ -54,7 +54,7 @@ public class ValidateCodeServiceImpl implements IValidateCodeService {
* @return true、false
*/
@Override
- public Result sendSmsCode(String mobile) {
+ public Result sendSmsCode(String mobile) {
Object tempCode = redisRepository.get(buildKey(mobile));
if (tempCode != null) {
log.error("用户:{}验证码未失效{}", mobile, tempCode);
diff --git a/zlt-uaa/src/main/resources/application.yml b/zlt-uaa/src/main/resources/application.yml
index c4910e53..0952ae43 100644
--- a/zlt-uaa/src/main/resources/application.yml
+++ b/zlt-uaa/src/main/resources/application.yml
@@ -13,17 +13,30 @@ mybatis-plus:
db-config:
id-type: auto
+springdoc:
+ swagger-ui:
+ path: /swagger-ui.html
+ tags-sorter: alpha
+ operations-sorter: alpha
+ api-docs:
+ path: /v3/api-docs
+ group-configs:
+ - group: 'uaa'
+ paths-to-match: '/**'
+ packages-to-scan: com.central.oauth.controller
+ default-flat-param-object: true
+
+knife4j:
+ enable: true
+ setting:
+ language: zh_cn
+ swagger-model-name: 认证中心接口文档
+
zlt:
oauth2:
token:
store:
type: redis
- swagger:
- enabled: true
- title: 认证中心
- description: 认证中心接口文档
- version: 1.0
- base-package: com.central.oauth.controller
security:
code:
# 忽略验证码的应用编号
@@ -43,21 +56,4 @@ zlt:
enabled: false
includeSqls:
# 应用列表
- - com.central.oauth.mapper.ClientMapper.findList
-
-springdoc:
- swagger-ui:
- path: /doc.html
- api-docs:
- path: /v3/api-docs
- group-configs:
- - group: 'uaa'
- paths-to-match: '/**'
- packages-to-scan: com.central.oauth.controller
- default-flat-param-object: true
-
-knife4j:
- enable: true
- setting:
- language: zh_cn
- swagger-model-name: 认证中心接口文档
\ No newline at end of file
+ - com.central.oauth.mapper.ClientMapper.findList
\ No newline at end of file