Skip to content

Commit 08026b5

Browse files
committed
GUACAMOLE-2057: Add configuration parameters for supporting Kerberos authentication for RDP.
1 parent 2f09f6d commit 08026b5

File tree

2 files changed

+141
-0
lines changed

2 files changed

+141
-0
lines changed

src/protocols/rdp/settings.c

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,9 @@ const char* GUAC_RDP_CLIENT_ARGS[] = {
7878
"console-audio",
7979
"server-layout",
8080
"security",
81+
"auth-pkg",
82+
"kdc-url",
83+
"kerberos-cache",
8184
"ignore-cert",
8285
"cert-tofu",
8386
"cert-fingerprints",
@@ -296,6 +299,28 @@ enum RDP_ARGS_IDX {
296299
*/
297300
IDX_SECURITY,
298301

302+
/**
303+
* The authentication package to use based on the underlying FreeRDP support
304+
* for alternatives to NTML. Currently FreeRDP2 only supports NTLM, while
305+
* FreeRDP3 introduces support for Kerberos and continues to support NTLM.
306+
* The default is to negotiate between guacd and the remote server.
307+
*/
308+
IDX_AUTH_PKG,
309+
310+
/**
311+
* When kerberos authentication is in use, the URL of the KDC server to use
312+
* for ticket validation. If not specified, guacd will use the underlying
313+
* system's kerberos configuration.
314+
*/
315+
IDX_KDC_URL,
316+
317+
/**
318+
* When kerberos authentication is in use, the path to the kerberos ticket
319+
* cache, relative to GUACAMOLE_HOME. If not specified, the default system
320+
* cache of the underlying system on which guacd is running will be used.
321+
*/
322+
IDX_KERBEROS_CACHE,
323+
299324
/**
300325
* "true" if validity of the RDP server's certificate should be ignored,
301326
* "false" or blank if invalid certificates should result in a failure to
@@ -832,6 +857,30 @@ guac_rdp_settings* guac_rdp_parse_args(guac_user* user,
832857
settings->security_mode = GUAC_SECURITY_ANY;
833858
}
834859

860+
/* Use kerberos authentication */
861+
if (strcmp(argv[IDX_AUTH_PKG], "kerberos") == 0) {
862+
guac_user_log(user, GUAC_LOG_INFO, "Authentication package: Kerberos");
863+
settings->auth_pkg = GUAC_AUTH_PKG_KERBEROS;
864+
}
865+
866+
else if (strcmp(argv[IDX_AUTH_PKG], "ntlm") == 0) {
867+
guac_user_log(user, GUAC_LOG_INFO, "Authentication package: NTLM");
868+
settings->auth_pkg = GUAC_AUTH_PKG_NTLM;
869+
}
870+
871+
else {
872+
guac_user_log(user, GUAC_LOG_INFO, "No authentication package requested, defaulting to negotiate.");
873+
settings->auth_pkg = GUAC_AUTH_PKG_ANY;
874+
}
875+
876+
/* Set KDC URL */
877+
settings->kdc_url = guac_user_parse_args_string(user, GUAC_RDP_CLIENT_ARGS,
878+
argv, IDX_KDC_URL, NULL);
879+
880+
/* Set Kerberos cache */
881+
settings->kerberos_cache = guac_user_parse_args_string(user,
882+
GUAC_RDP_CLIENT_ARGS, argv, IDX_KERBEROS_CACHE, NULL);
883+
835884
/* Set hostname */
836885
settings->hostname =
837886
guac_user_parse_args_string(user, GUAC_RDP_CLIENT_ARGS, argv,
@@ -1410,6 +1459,8 @@ void guac_rdp_settings_free(guac_rdp_settings* settings) {
14101459
guac_mem_free(settings->timezone);
14111460
guac_mem_free(settings->username);
14121461
guac_mem_free(settings->printer_name);
1462+
guac_mem_free(settings->kdc_url);
1463+
guac_mem_free(settings->kerberos_cache);
14131464

14141465
/* Free channel name array */
14151466
if (settings->svc_names != NULL) {
@@ -1692,6 +1743,29 @@ void guac_rdp_push_settings(guac_client* client,
16921743

16931744
}
16941745

1746+
/* Set the authentication package to use. */
1747+
switch(guac_settings->auth_pkg) {
1748+
1749+
case GUAC_AUTH_PKG_NTLM:
1750+
freerdp_settings_set_string(rdp_settings, FreeRDP_AuthenticationPackageList, "ntlm,!kerberos");
1751+
break;
1752+
1753+
case GUAC_AUTH_PKG_KERBEROS:
1754+
freerdp_settings_set_string(rdp_settings, FreeRDP_AuthenticationPackageList, "!ntlm,kerberos");
1755+
break;
1756+
1757+
case GUAC_AUTH_PKG_ANY:
1758+
freerdp_settings_set_string(rdp_settings, FreeRDP_AuthenticationPackageList, "ntlm,kerberos");
1759+
break;
1760+
1761+
}
1762+
1763+
if (guac_settings->kdc_url != NULL)
1764+
freerdp_settings_set_string(rdp_settings, FreeRDP_KerberosKdcUrl, guac_strdup(guac_settings->kdc_url));
1765+
1766+
if (guac_settings->kerberos_cache != NULL)
1767+
freerdp_settings_set_string(rdp_settings, FreeRDP_KerberosCache, guac_strdup(guac_settings->kerberos_cache));
1768+
16951769
/* Security */
16961770
freerdp_settings_set_bool(rdp_settings, FreeRDP_Authentication, !guac_settings->disable_authentication);
16971771
freerdp_settings_set_bool(rdp_settings, FreeRDP_IgnoreCertificate, guac_settings->ignore_certificate);
@@ -1941,6 +2015,29 @@ void guac_rdp_push_settings(guac_client* client,
19412015

19422016
}
19432017

2018+
/* Set the authentication package preferences */
2019+
switch(guac_settings->auth_pkg) {
2020+
2021+
case GUAC_AUTH_PKG_NTLM:
2022+
rdp_settings->AuthenticationPackageList = "ntlm,!kerberos";
2023+
break;
2024+
2025+
case GUAC_AUTH_PKG_KERBEROS:
2026+
rdp_settings->AuthenticationPackageList = "!ntlm,kerberos";
2027+
break;
2028+
2029+
case GUAC_AUTH_PKG_ANY:
2030+
rdp_settings->AuthenticationPackageList = "ntlm,kerberos";
2031+
break;
2032+
2033+
}
2034+
2035+
/* Kerberos KDC URL */
2036+
rdp_settings->KerberosKdcUrl = guac_strdup(guac_settings->kdc_url);
2037+
2038+
/* Kerberos ticket cache */
2039+
rdp_settings->KerberosCache = guac_strdup(guac_settings->kerberos_cache);
2040+
19442041
/* Security */
19452042
rdp_settings->Authentication = !guac_settings->disable_authentication;
19462043
rdp_settings->IgnoreCertificate = guac_settings->ignore_certificate;

src/protocols/rdp/settings.h

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,32 @@ typedef enum guac_rdp_security {
125125

126126
} guac_rdp_security;
127127

128+
/**
129+
* The authentication packages supported by freerdp and thus guacd.
130+
*/
131+
typedef enum guac_rdp_auth_package {
132+
133+
/**
134+
* NTLM-based authentication, which is still the default for Windows, but
135+
* is being phased out in favor of Kerberos due to security concerns.
136+
*/
137+
GUAC_AUTH_PKG_NTLM,
138+
139+
/**
140+
* Kerberos-based authentication, which is supported by FreeRDP3 and is
141+
* the new standard for RDP connections due to its superior security as
142+
* compared with NTLM.
143+
*/
144+
GUAC_AUTH_PKG_KERBEROS,
145+
146+
/**
147+
* Allow guacd and the server to negotiatoin without preferring one or the
148+
* other.
149+
*/
150+
GUAC_AUTH_PKG_ANY
151+
152+
} guac_rdp_auth_package;
153+
128154
/**
129155
* All supported combinations screen resize methods.
130156
*/
@@ -296,6 +322,24 @@ typedef struct guac_rdp_settings {
296322
*/
297323
guac_rdp_security security_mode;
298324

325+
/**
326+
* The authentication package to use.
327+
*/
328+
guac_rdp_auth_package auth_pkg;
329+
330+
/**
331+
* When using kerberos-based authentication, the URL of the KDC, if something
332+
* other than the system-level kerberos configuration should be used.
333+
*/
334+
char* kdc_url;
335+
336+
/**
337+
* When using kerberos-based authentication, the location of the kerberos
338+
* ticket cache to use, relative to GUACAMOLE_HOME, if the system-level
339+
* cache file should not be used.
340+
*/
341+
char* kerberos_cache;
342+
299343
/**
300344
* Whether bad server certificates should be ignored.
301345
*/

0 commit comments

Comments
 (0)