mirror of https://github.com/OpenVidu/openvidu.git
openvidu-server: hide secret properties on log
parent
286891c6fc
commit
8aad8948bf
|
@ -340,6 +340,9 @@ public class OpenViduServer implements JsonRpcConfigurer {
|
|||
|
||||
for (String property : configPropNames) {
|
||||
String value = CONFIG_PROPS.get(property);
|
||||
if (config.getSecretProperties().contains(property)) {
|
||||
value = config.hideSecret(value, "*", 0);
|
||||
}
|
||||
msg += " * " + config.getPropertyName(property) + "=" + (value == null ? "" : value) + "\n";
|
||||
}
|
||||
msg += "\n\n";
|
||||
|
|
|
@ -115,6 +115,8 @@ public class OpenviduConfig {
|
|||
|
||||
private List<String> userConfigProps;
|
||||
|
||||
protected final Set<String> secretProps = new HashSet<>(Arrays.asList("OPENVIDU_SECRET"));
|
||||
|
||||
protected Map<String, ?> propertiesSource;
|
||||
|
||||
public static final String DEFAULT_RECORDING_IMAGE_REPO = "openvidu/openvidu-recording";
|
||||
|
@ -487,6 +489,10 @@ public class OpenviduConfig {
|
|||
public Map<String, String> getConfigProps() {
|
||||
return configProps;
|
||||
}
|
||||
|
||||
public Set<String> getSecretProperties() {
|
||||
return secretProps;
|
||||
}
|
||||
|
||||
public List<String> getUserProperties() {
|
||||
return userConfigProps;
|
||||
|
@ -1255,4 +1261,11 @@ public class OpenviduConfig {
|
|||
return builder;
|
||||
}
|
||||
|
||||
public String hideSecret(final String originalString, String charToReplace, int numberOfVisibleChars) {
|
||||
String hiddenString = originalString.substring(originalString.length() - numberOfVisibleChars,
|
||||
originalString.length());
|
||||
hiddenString = charToReplace.repeat(originalString.length() - numberOfVisibleChars) + hiddenString;
|
||||
return hiddenString;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -152,11 +152,4 @@ public class ConfigRestController {
|
|||
return new ResponseEntity<>(json.toString(), RestUtils.getResponseHeaders(), HttpStatus.OK);
|
||||
}
|
||||
|
||||
protected String hideSecret(final String originalString, String charToReplace, int numberOfVisibleChars) {
|
||||
String hiddenString = originalString.substring(originalString.length() - numberOfVisibleChars,
|
||||
originalString.length());
|
||||
hiddenString = charToReplace.repeat(originalString.length() - numberOfVisibleChars) + hiddenString;
|
||||
return hiddenString;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -742,10 +742,10 @@ public class OpenViduProTestAppE2eTest extends AbstractOpenViduTestappE2eTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("Speech To Text disabled test")
|
||||
void speechToTextDisabledTest() throws Exception {
|
||||
@DisplayName("Service disabled STT test")
|
||||
void serviceDisabledSttTest() throws Exception {
|
||||
|
||||
log.info("Speech To Text disabled test");
|
||||
log.info("Service disabled STT test");
|
||||
|
||||
restartOpenViduServerIfNecessary(false, null, "disabled");
|
||||
|
||||
|
@ -776,10 +776,10 @@ public class OpenViduProTestAppE2eTest extends AbstractOpenViduTestappE2eTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("Speech To Text simple transcription test")
|
||||
void speechToTextSimpleTranscriptionTest() throws Exception {
|
||||
@DisplayName("Simple transcription STT test")
|
||||
void simpleTranscriptionSttTest() throws Exception {
|
||||
|
||||
log.info("Speech To Text simple transcription test");
|
||||
log.info("Simple transcription STT test");
|
||||
|
||||
restartOpenViduServerIfNecessary(false, null, "vosk");
|
||||
|
||||
|
@ -852,10 +852,10 @@ public class OpenViduProTestAppE2eTest extends AbstractOpenViduTestappE2eTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("Speech To Text close session test")
|
||||
void speechToTextCloseSessionTest() throws Exception {
|
||||
@DisplayName("Close session STT test")
|
||||
void closeSessionSttTest() throws Exception {
|
||||
|
||||
log.info("Speech To Text close session");
|
||||
log.info("Close session STT test");
|
||||
|
||||
restartOpenViduServerIfNecessary(false, null, "vosk");
|
||||
|
||||
|
@ -907,10 +907,10 @@ public class OpenViduProTestAppE2eTest extends AbstractOpenViduTestappE2eTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("Speech To Text expected errors test")
|
||||
void speechToTextExpectedErrorsTest() throws Exception {
|
||||
@DisplayName("Expected errors STT test")
|
||||
void expectedErrorsSttTest() throws Exception {
|
||||
|
||||
log.info("Speech To Text expected errors");
|
||||
log.info("Expected errors STT test");
|
||||
|
||||
restartOpenViduServerIfNecessary(false, null, "vosk");
|
||||
|
||||
|
@ -1541,7 +1541,10 @@ public class OpenViduProTestAppE2eTest extends AbstractOpenViduTestappE2eTest {
|
|||
|
||||
protected void restartOpenViduServerIfNecessary(Boolean wantedNetworkQuality, Integer wantedNetworkQualityInterval,
|
||||
String wantedSpeechToText) {
|
||||
try {
|
||||
|
||||
wantedSpeechToText = "azure";
|
||||
|
||||
try {
|
||||
|
||||
CustomHttpClient restClient = new CustomHttpClient(OPENVIDU_URL, "OPENVIDUAPP", OPENVIDU_SECRET);
|
||||
JsonObject config = restClient.rest(HttpMethod.GET, "/openvidu/api/config", 200);
|
||||
|
|
Loading…
Reference in New Issue