This is a basic authentication filter capable of being used with the Spark UI. It is adapted from:
With the only changes being updating from Java Extension (javax) to Jakarta for use with Java 17+.
Package above filter class as a JAR, put it in $SPARK_HOME/jars/ add SPARK_MASTER_OPTS and SPARK_WORKER_OPTS as:
-Dspark.ui.filters=com.fortytools.servlet.BasicAuthFilter
-Dspark.com.fortytools.servlet.BasicAuthFilter.param.user=<user>
-Dspark.com.fortytools.servlet.BasicAuthFilter.param.password=<password>
-Dspark.com.fortytools.servlet.BasicAuthFilter.param.realm=<realmname>
Realm is unused so can be anything.
Although this is functional for preventing unwanted access it is not intended for use on the open internet.