From b1aa9f484fcb0a28966fec5b5cfc04953440632f Mon Sep 17 00:00:00 2001 From: YunaiV Date: Sat, 11 Jun 2022 23:54:30 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=20SecurityProperties=20?= =?UTF-8?q?=E5=92=8C=20WebProperties=20=E9=BB=98=E8=AE=A4=E5=80=BC?= =?UTF-8?q?=EF=BC=8C=E7=AE=80=E5=8C=96=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../framework/security/config/SecurityProperties.java | 6 +++--- .../iocoder/yudao/framework/web/config/WebProperties.java | 8 ++++++-- yudao-server/src/main/resources/application-dev.yaml | 4 ---- yudao-server/src/main/resources/application-local.yaml | 2 -- yudao-server/src/main/resources/application.yaml | 6 ------ 5 files changed, 9 insertions(+), 17 deletions(-) diff --git a/yudao-framework/yudao-spring-boot-starter-security/src/main/java/cn/iocoder/yudao/framework/security/config/SecurityProperties.java b/yudao-framework/yudao-spring-boot-starter-security/src/main/java/cn/iocoder/yudao/framework/security/config/SecurityProperties.java index a9373cd9c..9d5f64597 100644 --- a/yudao-framework/yudao-spring-boot-starter-security/src/main/java/cn/iocoder/yudao/framework/security/config/SecurityProperties.java +++ b/yudao-framework/yudao-spring-boot-starter-security/src/main/java/cn/iocoder/yudao/framework/security/config/SecurityProperties.java @@ -16,18 +16,18 @@ public class SecurityProperties { * HTTP 请求时,访问令牌的请求 Header */ @NotEmpty(message = "Token Header 不能为空") - private String tokenHeader; + private String tokenHeader = "Authorization"; /** * mock 模式的开关 */ @NotNull(message = "mock 模式的开关不能为空") - private Boolean mockEnable; + private Boolean mockEnable = false; /** * mock 模式的密钥 * 一定要配置密钥,保证安全性 */ @NotEmpty(message = "mock 模式的密钥不能为空") // 这里设置了一个默认值,因为实际上只有 mockEnable 为 true 时才需要配置。 - private String mockSecret = "yudaoyuanma"; + private String mockSecret = "test"; } diff --git a/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/web/config/WebProperties.java b/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/web/config/WebProperties.java index 173a67042..03f4d70b6 100644 --- a/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/web/config/WebProperties.java +++ b/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/web/config/WebProperties.java @@ -1,6 +1,8 @@ package cn.iocoder.yudao.framework.web.config; +import lombok.AllArgsConstructor; import lombok.Data; +import lombok.NoArgsConstructor; import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.validation.annotation.Validated; import org.springframework.web.servlet.config.annotation.PathMatchConfigurer; @@ -15,14 +17,16 @@ import javax.validation.constraints.NotNull; public class WebProperties { @NotNull(message = "APP API 不能为空") - private Api appApi; + private Api appApi = new Api("/app-api", "**.controller.app.**"); @NotNull(message = "Admin API 不能为空") - private Api adminApi; + private Api adminApi = new Api("/admin-api", "**.controller.admin.**"); @NotNull(message = "Admin UI 不能为空") private Ui adminUi; @Data + @AllArgsConstructor + @NoArgsConstructor @Valid public static class Api { diff --git a/yudao-server/src/main/resources/application-dev.yaml b/yudao-server/src/main/resources/application-dev.yaml index 4989a6146..e54bec4fc 100644 --- a/yudao-server/src/main/resources/application-dev.yaml +++ b/yudao-server/src/main/resources/application-dev.yaml @@ -171,10 +171,6 @@ wx: # 参见 https://github.com/Wechat-Group/WxJava/blob/develop/spring-boot-sta # 芋道配置项,设置当前项目所有自定义的配置 yudao: - security: - token-header: Authorization - mock-enable: true - mock-secret: test xss: enable: false exclude-urls: # 如下两个 url,仅仅是为了演示,去掉配置也没关系 diff --git a/yudao-server/src/main/resources/application-local.yaml b/yudao-server/src/main/resources/application-local.yaml index beed068e5..bf32b2fb0 100644 --- a/yudao-server/src/main/resources/application-local.yaml +++ b/yudao-server/src/main/resources/application-local.yaml @@ -192,9 +192,7 @@ yudao: captcha: enable: false # 本地环境,暂时关闭图片验证码,方便登录等接口的测试 security: - token-header: Authorization mock-enable: true - mock-secret: test xss: enable: false exclude-urls: # 如下两个 url,仅仅是为了演示,去掉配置也没关系 diff --git a/yudao-server/src/main/resources/application.yaml b/yudao-server/src/main/resources/application.yaml index b6e0555a8..9db79c817 100644 --- a/yudao-server/src/main/resources/application.yaml +++ b/yudao-server/src/main/resources/application.yaml @@ -75,12 +75,6 @@ yudao: version: 1.0.0 base-package: cn.iocoder.yudao web: - admin-api: - prefix: /admin-api - controller: '**.controller.admin.**' - app-api: - prefix: /app-api - controller: '**.controller.app.**' admin-ui: url: http://dashboard.yudao.iocoder.cn # Admin 管理后台 UI 的地址 swagger: