Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update java client for proper PSK #6

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ public class PskAuthenticationHandler implements AuthenticationRequestHandler {
String pskFromConfig = Configuration.getInstance().getStringWithDefault("authentication.psk", null);
// If this feature is enabled by not value give, generate a 64bit number and encode as
// base-36 (lower case and numbers).
PSK = Objects.requireNonNullElseGet(pskFromConfig, () -> Long.toString(Math.abs(new Random().nextLong()), 36));
PSK = Optional.ofNullable(pskFromConfig).map(String::trim).filter(s -> !s.isEmpty())
.orElseGet(() -> Long.toString(Math.abs(new Random().nextLong()), 36));

// limit to ascii for better log and url support
if (!StandardCharsets.US_ASCII.newEncoder().canEncode(PSK)) {
Expand Down Expand Up @@ -69,7 +70,7 @@ public void initialize(String targetUrl) {
logger.warn().append("================================================================================").endl();
logger.warn().append("Superuser access through pre-shared key is enabled - use ").append(PSK)
.append(" to connect").endl();
logger.warn().append("Connect automatically to Web UI with ").append(targetUrl).append("/jsapi?psk=")
logger.warn().append("Connect automatically to Web UI with ").append(targetUrl).append("/?psk=")
.append(PSK)
.endl();
logger.warn().append("================================================================================").endl();
Expand Down
2 changes: 1 addition & 1 deletion docker-compose-common.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ services:
# with max memory.
#
# To turn on debug logging, add: -Dlogback.configurationFile=logback-debug.xml
- START_OPTS=-Xmx4g -Ddeephaven.console.type=${DEEPHAVEN_CONSOLE_TYPE} -Ddeephaven.application.dir=${DEEPHAVEN_APPLICATION_DIR}
- START_OPTS=-Xmx4g -Ddeephaven.console.type=${DEEPHAVEN_CONSOLE_TYPE} -Ddeephaven.application.dir=${DEEPHAVEN_APPLICATION_DIR} -Dauthentication.psk=${PSK}
#
# For remote debugging switch the line above for the one below (and also change the ports below)
# - START_OPTS=-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:5005 -Xmx4g -Ddeephaven.console.type=${DEEPHAVEN_CONSOLE_TYPE} -Ddeephaven.application.dir=${DEEPHAVEN_APPLICATION_DIR}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public String toAuthenticationTypeAndValue() {
return "io.deephaven.authentication.mtls.MTlsAuthenticationHandler";
}
if (psk != null) {
return "psk " + psk;
return "io.deephaven.authentication.psk.PskAuthenticationHandler " + psk;
}
if (explicit != null) {
return explicit;
Expand Down
2 changes: 1 addition & 1 deletion props/configs/src/main/resources/dh-defaults.prop
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ deephaven.console.type=python
http.session.durationMs=300000

# Default to allowing anonymous access, but don't yet warn users that it is unsafe by default
AuthHandlers=io.deephaven.auth.AnonymousAuthenticationHandler
AuthHandlers=io.deephaven.authentication.psk.PskAuthenticationHandler
authentication.anonymous.warn=true

# List of configuration properties to provide to unauthenticated clients, so that they can decide how best to prove their
Expand Down
2 changes: 1 addition & 1 deletion server/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ dependencies {

Classpaths.inheritImmutables(project, true)


runtimeOnly dependencies.project(path: ':authentication:example-providers:psk', configuration:'shadow')
}

TestTools.addEngineOutOfBandTest(project)
Expand Down
1 change: 0 additions & 1 deletion server/jetty-app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ if (hasProperty('quiet')) {

if (hasProperty('psk')) {
authHandlers += ['io.deephaven.authentication.psk.PskAuthenticationHandler']
dependencies.implementation(dependencies.project(path: ':authentication:example-providers:psk', configuration:'shadow'))
if (project.getProperty('psk')) {
// if there is a non-empty value assigned, use that for the key
extraJvmArgs += ["-Dauthentication.psk=${getProperty('psk')}"]
Expand Down