Quellcode durchsuchen

增加 SecurityProperties 和 WebProperties 默认值,简化配置

YunaiV vor 2 Jahren
Ursprung
Commit
b1aa9f484f

+ 3 - 3
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";
 
 }

+ 6 - 2
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 {
 

+ 0 - 4
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,仅仅是为了演示,去掉配置也没关系

+ 0 - 2
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,仅仅是为了演示,去掉配置也没关系

+ 0 - 6
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: