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

pull/2/head
YunaiV 2022-06-11 23:54:30 +08:00
parent 309ba2d3f1
commit b1aa9f484f
5 changed files with 9 additions and 17 deletions

View File

@ -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";
}

View File

@ -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 {

View File

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

View File

@ -192,9 +192,7 @@ yudao:
captcha:
enable: false # 本地环境,暂时关闭图片验证码,方便登录等接口的测试
security:
token-header: Authorization
mock-enable: true
mock-secret: test
xss:
enable: false
exclude-urls: # 如下两个 url仅仅是为了演示去掉配置也没关系

View File

@ -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: