Skip to content

Commit 8de2639

Browse files
committed
feat(TFA): increase expiration time for TFA initialization and streamline configuration parameter handling
1 parent e57a094 commit 8de2639

2 files changed

Lines changed: 10 additions & 11 deletions

File tree

backend/src/main/java/com/park/utmstack/service/UtmConfigurationParameterService.java

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
import java.util.Optional;
2727
import java.util.stream.Collectors;
2828

29-
import static com.park.utmstack.config.Constants.DATE_FORMAT_SETTING_ID;
29+
import static com.park.utmstack.config.Constants.*;
3030

3131
/**
3232
* Service Implementation for managing UtmConfigurationParameter.
@@ -85,22 +85,21 @@ public void saveAll(List<UtmConfigurationParameter> params) throws UtmMailExcept
8585
final String ctx = CLASSNAME + ".saveAll";
8686
try {
8787

88-
UtmConfigurationParameter tfaEnabledParam = params.stream()
88+
Boolean tfaEnabledParam = params.stream()
8989
.filter(p -> p.getConfParamShort().equals(Constants.PROP_TFA_ENABLE))
9090
.findFirst()
91-
.orElse(null);
91+
.map(p -> Boolean.parseBoolean(p.getConfParamValue()))
92+
.orElse(Boolean.valueOf(CFG.get(PROP_TFA_ENABLE)));
9293

93-
UtmConfigurationParameter tfaMethodParam = params.stream()
94+
TfaMethod tfaMethodParam = params.stream()
9495
.filter(p -> p.getConfParamShort().equals(Constants.PROP_TFA_METHOD))
9596
.findFirst()
97+
.map(p -> TfaMethod.valueOf(p.getConfParamValue()))
9698
.orElse(null);
9799

98-
if (tfaEnabledParam != null && tfaMethodParam != null && tfaMethodParam.getConfParamValue() != null && Boolean.parseBoolean(tfaEnabledParam.getConfParamValue())) {
99-
String tfaMethod = tfaMethodParam.getConfParamValue();
100-
101-
tfaService.persistConfiguration(TfaMethod.valueOf(tfaMethod));
102-
103-
log.info("TFA enabled with method: {}", tfaMethod);
100+
if (tfaEnabledParam && tfaMethodParam != null) {
101+
tfaService.persistConfiguration(tfaMethodParam);
102+
log.info("TFA enabled with method: {}", tfaMethodParam);
104103
}
105104

106105

backend/src/main/java/com/park/utmstack/service/tfa/TotpTfaService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public TfaInitResponse initiateSetup(User user) {
5454
String qrBase64 = generateQrBase64(uri);
5555
Delivery delivery = new Delivery(TfaMethod.TOTP, qrBase64);
5656

57-
return new TfaInitResponse("pending", delivery, Constants.EXPIRES_IN_SECONDS);
57+
return new TfaInitResponse("pending", delivery, Constants.EXPIRES_IN_SECONDS * 10);
5858
}
5959

6060
@Override

0 commit comments

Comments
 (0)