Commit b1aa9f484fcb0a28966fec5b5cfc04953440632f

Authored by YunaiV
1 parent 309ba2d3

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

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 {
16 16 * HTTP 请求时,访问令牌的请求 Header
17 17 */
18 18 @NotEmpty(message = "Token Header 不能为空")
19   - private String tokenHeader;
  19 + private String tokenHeader = "Authorization";
20 20  
21 21 /**
22 22 * mock 模式的开关
23 23 */
24 24 @NotNull(message = "mock 模式的开关不能为空")
25   - private Boolean mockEnable;
  25 + private Boolean mockEnable = false;
26 26 /**
27 27 * mock 模式的密钥
28 28 * 一定要配置密钥,保证安全性
29 29 */
30 30 @NotEmpty(message = "mock 模式的密钥不能为空") // 这里设置了一个默认值,因为实际上只有 mockEnable 为 true 时才需要配置。
31   - private String mockSecret = "yudaoyuanma";
  31 + private String mockSecret = "test";
32 32  
33 33 }
... ...
yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/web/config/WebProperties.java
1 1 package cn.iocoder.yudao.framework.web.config;
2 2  
  3 +import lombok.AllArgsConstructor;
3 4 import lombok.Data;
  5 +import lombok.NoArgsConstructor;
4 6 import org.springframework.boot.context.properties.ConfigurationProperties;
5 7 import org.springframework.validation.annotation.Validated;
6 8 import org.springframework.web.servlet.config.annotation.PathMatchConfigurer;
... ... @@ -15,14 +17,16 @@ import javax.validation.constraints.NotNull;
15 17 public class WebProperties {
16 18  
17 19 @NotNull(message = "APP API 不能为空")
18   - private Api appApi;
  20 + private Api appApi = new Api("/app-api", "**.controller.app.**");
19 21 @NotNull(message = "Admin API 不能为空")
20   - private Api adminApi;
  22 + private Api adminApi = new Api("/admin-api", "**.controller.admin.**");
21 23  
22 24 @NotNull(message = "Admin UI 不能为空")
23 25 private Ui adminUi;
24 26  
25 27 @Data
  28 + @AllArgsConstructor
  29 + @NoArgsConstructor
26 30 @Valid
27 31 public static class Api {
28 32  
... ...
yudao-server/src/main/resources/application-dev.yaml
... ... @@ -171,10 +171,6 @@ wx: # 参见 https://github.com/Wechat-Group/WxJava/blob/develop/spring-boot-sta
171 171  
172 172 # 芋道配置项,设置当前项目所有自定义的配置
173 173 yudao:
174   - security:
175   - token-header: Authorization
176   - mock-enable: true
177   - mock-secret: test
178 174 xss:
179 175 enable: false
180 176 exclude-urls: # 如下两个 url,仅仅是为了演示,去掉配置也没关系
... ...
yudao-server/src/main/resources/application-local.yaml
... ... @@ -192,9 +192,7 @@ yudao:
192 192 captcha:
193 193 enable: false # 本地环境,暂时关闭图片验证码,方便登录等接口的测试
194 194 security:
195   - token-header: Authorization
196 195 mock-enable: true
197   - mock-secret: test
198 196 xss:
199 197 enable: false
200 198 exclude-urls: # 如下两个 url,仅仅是为了演示,去掉配置也没关系
... ...
yudao-server/src/main/resources/application.yaml
... ... @@ -75,12 +75,6 @@ yudao:
75 75 version: 1.0.0
76 76 base-package: cn.iocoder.yudao
77 77 web:
78   - admin-api:
79   - prefix: /admin-api
80   - controller: '**.controller.admin.**'
81   - app-api:
82   - prefix: /app-api
83   - controller: '**.controller.app.**'
84 78 admin-ui:
85 79 url: http://dashboard.yudao.iocoder.cn # Admin 管理后台 UI 的地址
86 80 swagger:
... ...