mirror of https://github.com/OpenVidu/openvidu.git
openvidu-server: limit OPENVIDU_SECRET format to [a-zA-Z0-9_-]
parent
4a7a2808b6
commit
99cd6d2f9c
|
@ -483,7 +483,8 @@ public class OpenviduConfig {
|
|||
|
||||
coturnRedisConnectTimeout = getValue("COTURN_REDIS_CONNECT_TIMEOUT");
|
||||
|
||||
openviduSecret = asNonEmptyString("OPENVIDU_SECRET");
|
||||
openviduSecret = asNonEmptyAlphanumericString("OPENVIDU_SECRET",
|
||||
"Cannot be empty and must contain only alphanumeric characters [a-zA-Z0-9], hypens (\"-\") and underscores (\"_\")");
|
||||
|
||||
openviduCdr = asBoolean("OPENVIDU_CDR");
|
||||
openviduCdrPath = openviduCdr ? asWritableFileSystemPath("OPENVIDU_CDR_PATH")
|
||||
|
@ -741,6 +742,17 @@ public class OpenviduConfig {
|
|||
}
|
||||
}
|
||||
|
||||
protected String asNonEmptyAlphanumericString(String property, String errorMessage) {
|
||||
final String REGEX = "^[a-zA-Z0-9_-]+$";
|
||||
String stringValue = getValue(property);
|
||||
if (stringValue != null && !stringValue.isEmpty() && stringValue.matches(REGEX)) {
|
||||
return stringValue;
|
||||
} else {
|
||||
addError(property, errorMessage);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
protected String asOptionalString(String property) {
|
||||
return getValue(property);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue