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