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

Allow overriding of guacd-[hostname/port/ssl] within the connection's json properties #795

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
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 @@ -40,6 +40,7 @@
import org.apache.guacamole.net.SSLGuacamoleSocket;
import org.apache.guacamole.net.SimpleGuacamoleTunnel;
import org.apache.guacamole.net.auth.GuacamoleProxyConfiguration;
import org.apache.guacamole.net.auth.GuacamoleProxyConfiguration.EncryptionMethod;
import org.apache.guacamole.protocol.ConfiguredGuacamoleSocket;
import org.apache.guacamole.protocol.GuacamoleClientInformation;
import org.apache.guacamole.protocol.GuacamoleConfiguration;
Expand Down Expand Up @@ -176,6 +177,22 @@ public GuacamoleTunnel connect(UserData.Connection connection,
String hostname = proxyConfig.getHostname();
int port = proxyConfig.getPort();

// handle guacd-[hostname/port/ssl] overrides
Map<String, String> params = connection.getParameters();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The guacd hostname, port, etc. are not connection parameters, which are strictly the protocol-specific key/value pairs for configuring the connection as defined by the protocol plugin that guacd ultimately loads. Additional properties configuring the details for guacd will need to be at a different level of the JSON, perhaps directly within the connection, not within the connection params.

Copy link
Author

@marvin-enthus marvin-enthus Feb 20, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi Mike. I Just pushed an other commit migrating this to connection level.

Currently i'm not sure about the best approach - I've allinged the java class with the current camelCase, so the settings are currently also in camelCase:

{
    "username" : "arbitraryUsername",
    "expires" : TIMESTAMP,
    "connections" : {

        "Connection Name" : {
            "protocol" : "PROTOCOL",
            "guacdHostname" : "my-other-guacd-host",
            "guacdPort" : 4822,
            "guacdSsl" : false,
            "parameters" : {
                "name1" : "value1",
                "name2" : "value2",
                ...
            }
        },
        ...
    }
}

But that's not matching the names in other places. I could set some annotations for the jackson data mapper, but haven't found any json annotation on the code - so i'm not sure about this...

String overrideGuacdHostname = params.get(Environment.GUACD_HOSTNAME.getName());
if (overrideGuacdHostname != null && !overrideGuacdHostname.isEmpty()) {
hostname = overrideGuacdHostname;
}
String overrideGuacdPort = params.get(Environment.GUACD_PORT.getName());
if (overrideGuacdPort != null && !overrideGuacdPort.isEmpty()) {
port = Integer.parseInt(overrideGuacdPort);
}
EncryptionMethod proxyMethod = proxyConfig.getEncryptionMethod();
String overrideGuacdSSL = params.get(Environment.GUACD_SSL.getName());
if (overrideGuacdSSL != null && !overrideGuacdSSL.isEmpty()) {
proxyMethod = Boolean.getBoolean(overrideGuacdSSL) ? EncryptionMethod.SSL : EncryptionMethod.NONE;
}

// Generate and verify connection configuration
GuacamoleConfiguration filteredConfig = getConfiguration(connection);
if (filteredConfig == null) {
Expand All @@ -190,7 +207,7 @@ public GuacamoleTunnel connect(UserData.Connection connection,

// Determine socket type based on required encryption method
final ConfiguredGuacamoleSocket socket;
switch (proxyConfig.getEncryptionMethod()) {
switch (proxyMethod) {

// If guacd requires SSL, use it
case SSL:
Expand Down