mirror of https://github.com/apache/nifi.git
NIFI-4632: Add the local hostname to the list of validated host headers
This closes #2288. Signed-off-by: Andy LoPresto <alopresto.apache@gmail.com>
This commit is contained in:
parent
6169061456
commit
cec2764140
|
@ -18,6 +18,7 @@ package org.apache.nifi.web.server;
|
|||
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.net.InetAddress;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
@ -60,6 +61,12 @@ public class HostHeaderHandler extends ScopedHandler {
|
|||
validHosts.add("localhost:" + serverPort);
|
||||
// Different from customizer -- empty is ok here
|
||||
validHosts.add("");
|
||||
try {
|
||||
validHosts.add(InetAddress.getLocalHost().getHostName());
|
||||
validHosts.add(InetAddress.getLocalHost().getHostName() + ":" + serverPort);
|
||||
} catch (final Exception e) {
|
||||
logger.warn("Failed to determine local hostname.", e);
|
||||
}
|
||||
|
||||
logger.info("Created " + this.toString());
|
||||
}
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
*/
|
||||
package org.apache.nifi.web.server;
|
||||
|
||||
import java.net.InetAddress;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
@ -53,6 +54,12 @@ public class HostHeaderSanitizationCustomizer implements HttpConfiguration.Custo
|
|||
// Sometimes the hostname is left empty but the port is always populated
|
||||
validHosts.add("localhost");
|
||||
validHosts.add("localhost:" + serverPort);
|
||||
try {
|
||||
validHosts.add(InetAddress.getLocalHost().getHostName());
|
||||
validHosts.add(InetAddress.getLocalHost().getHostName() + ":" + serverPort);
|
||||
} catch (final Exception e) {
|
||||
logger.warn("Failed to determine local hostname.", e);
|
||||
}
|
||||
|
||||
logger.info("Created " + this.toString());
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue