Skip to content

Commit 91241ca

Browse files
author
jianggang
committed
feat: add permanent toggle flag
1 parent 2089670 commit 91241ca

File tree

17 files changed

+120
-78
lines changed

17 files changed

+120
-78
lines changed

src/main/java/com/featureprobe/api/auth/SecurityConfig.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package com.featureprobe.api.auth;
22

3-
import com.featureprobe.api.base.config.AppConfig;
3+
import com.featureprobe.api.base.config.JWTConfig;
44
import com.featureprobe.api.base.enums.OrganizationRoleEnum;
55
import com.featureprobe.api.dto.BaseResponse;
66
import com.featureprobe.api.mapper.JsonMapper;
@@ -36,7 +36,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
3636

3737
private LoginSuccessHandler loginSuccessHandler;
3838

39-
private AppConfig appConfig;
39+
private JWTConfig JWTConfig;
4040

4141
private UserPasswordAuthenticationProvider userPasswordAuthenticationProvider;
4242

@@ -98,7 +98,7 @@ protected void configure(HttpSecurity http) throws Exception {
9898
.authenticationEntryPoint(authenticationEntryPoint());
9999
http.addFilterBefore(userPasswordAuthenticationProcessingFilter(authenticationManager()),
100100
UsernamePasswordAuthenticationFilter.class);
101-
if (!appConfig.isGuestDisabled()) {
101+
if (!JWTConfig.isGuestDisabled()) {
102102
http.addFilterBefore(guestAuthenticationProcessingFilter(authenticationManager()),
103103
UserPasswordAuthenticationProcessingFilter.class);
104104
}

src/main/java/com/featureprobe/api/auth/tenant/TenantFilter.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package com.featureprobe.api.auth.tenant;
22

33
import com.featureprobe.api.auth.TokenHelper;
4-
import com.featureprobe.api.base.config.AppConfig;
4+
import com.featureprobe.api.base.config.JWTConfig;
55
import com.featureprobe.api.dto.BaseResponse;
66
import com.featureprobe.api.dto.OrganizationMember;
77
import com.featureprobe.api.mapper.JsonMapper;
@@ -32,15 +32,15 @@ public class TenantFilter implements Filter {
3232

3333
private OrganizationService organizationService;
3434

35-
private AppConfig appConfig;
35+
private JWTConfig JWTConfig;
3636

3737
@Override
3838
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain)
3939
throws IOException, ServletException {
4040
HttpServletResponse response = (HttpServletResponse) servletResponse;
4141
HttpServletRequest request = (HttpServletRequest) servletRequest;
4242
String requestURI = request.getRequestURI();
43-
if (!appConfig.getExcludeTenantUri().contains(requestURI)) {
43+
if (!JWTConfig.getExcludeTenantUri().contains(requestURI)) {
4444
String tenantHeader = request.getHeader(TENANT_HEADER);
4545
try {
4646
if (StringUtils.isNotBlank(tenantHeader)) {
Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,17 @@
11
package com.featureprobe.api.base.config;
22

3+
import lombok.AllArgsConstructor;
34
import lombok.Data;
5+
import lombok.NoArgsConstructor;
46
import org.springframework.boot.context.properties.ConfigurationProperties;
57
import org.springframework.stereotype.Component;
6-
import java.util.List;
78

89
@Data
910
@Component
10-
@ConfigurationProperties(prefix = "app.security.jwt")
11+
@ConfigurationProperties(prefix = "app")
12+
@AllArgsConstructor
13+
@NoArgsConstructor
1114
public class AppConfig {
1215

13-
private String keystoreLocation;
14-
15-
private String keystorePassword;
16-
17-
private String keyAlias;
18-
19-
private String privateKeyPassphrase;
20-
21-
private List<String> excludeTenantUri;
22-
23-
private boolean guestDisabled = true;
24-
25-
private String guestDefaultPassword;
26-
16+
private Long toggleDeadline;
2717
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package com.featureprobe.api.base.config;
2+
3+
import lombok.Data;
4+
import org.springframework.boot.context.properties.ConfigurationProperties;
5+
import org.springframework.stereotype.Component;
6+
import java.util.List;
7+
8+
@Data
9+
@Component
10+
@ConfigurationProperties(prefix = "app.security.jwt")
11+
public class JWTConfig {
12+
13+
private String keystoreLocation;
14+
15+
private String keystorePassword;
16+
17+
private String keyAlias;
18+
19+
private String privateKeyPassphrase;
20+
21+
private List<String> excludeTenantUri;
22+
23+
private boolean guestDisabled = true;
24+
25+
private String guestDefaultPassword;
26+
27+
}

src/main/java/com/featureprobe/api/dto/ToggleCreateRequest.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,6 @@ public class ToggleCreateRequest {
3333

3434
@NotNull
3535
private Integer disabledServe;
36+
37+
private boolean permanent;
3638
}

src/main/java/com/featureprobe/api/dto/ToggleItemResponse.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ public class ToggleItemResponse {
1212

1313
private String key;
1414

15+
private Boolean permanent;
16+
17+
private Long useDays;
18+
1519
private String returnType;
1620

1721
private String desc;

src/main/java/com/featureprobe/api/dto/ToggleResponse.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ public class ToggleResponse {
1313

1414
private String key;
1515

16+
private Boolean permanent;
17+
18+
private Long useDays;
19+
1620
private String returnType;
1721

1822
private Integer disabledServe;

src/main/java/com/featureprobe/api/dto/ToggleSearchRequest.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,6 @@ public class ToggleSearchRequest extends PaginationRequest {
2222

2323
private List<ToggleReleaseStatusEnum> releaseStatusList;
2424

25+
private Boolean permanent;
26+
2527
}

src/main/java/com/featureprobe/api/dto/ToggleUpdateRequest.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,6 @@ public class ToggleUpdateRequest {
2222
private Integer disabledServe;
2323

2424
private Boolean archived;
25+
26+
private boolean permanent;
2527
}

src/main/java/com/featureprobe/api/entity/Toggle.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,9 @@
22

33
import com.featureprobe.api.base.config.TenantEntityListener;
44
import com.featureprobe.api.base.entity.AbstractAuditEntity;
5-
import lombok.AllArgsConstructor;
6-
import lombok.EqualsAndHashCode;
75
import lombok.Getter;
8-
import lombok.NoArgsConstructor;
96
import lombok.Setter;
10-
import lombok.ToString;
117
import org.hibernate.annotations.DynamicInsert;
12-
import org.hibernate.annotations.Fetch;
13-
import org.hibernate.annotations.FetchMode;
148
import org.hibernate.annotations.Filter;
159
import org.hibernate.annotations.FilterDef;
1610
import org.hibernate.annotations.ParamDef;
@@ -45,6 +39,9 @@ public class Toggle extends AbstractAuditEntity implements TenantSupport {
4539
@Column(name = "[key]")
4640
private String key;
4741

42+
@Column(columnDefinition = "TINYINT")
43+
private boolean permanent;
44+
4845
@Column(name = "description" , columnDefinition = "TEXT")
4946
private String desc;
5047

0 commit comments

Comments
 (0)