GUACAMOLE-514: Merge support for VNC authentication involving usernames.

This commit is contained in:
Mike Jumper 2019-08-12 18:02:24 -07:00 committed by GitHub
commit 51463209a8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 57 additions and 2 deletions

View File

@ -31,3 +31,22 @@ char* guac_vnc_get_password(rfbClient* client) {
return ((guac_vnc_client*) gc->data)->settings->password; return ((guac_vnc_client*) gc->data)->settings->password;
} }
rfbCredential* guac_vnc_get_credentials(rfbClient* client, int credentialType) {
guac_client* gc = rfbClientGetClientData(client, GUAC_VNC_CLIENT_KEY);
guac_vnc_settings* settings = ((guac_vnc_client*) gc->data)->settings;
if (credentialType == rfbCredentialTypeUser) {
rfbCredential *creds = malloc(sizeof(rfbCredential));
creds->userCredential.username = settings->username;
creds->userCredential.password = settings->password;
return creds;
}
guac_client_abort(gc, GUAC_PROTOCOL_STATUS_SERVER_ERROR,
"Unsupported credential type requested.");
guac_client_log(gc, GUAC_LOG_DEBUG,
"Unable to provide requested type of credential: %d.",
credentialType);
return NULL;
}

View File

@ -27,7 +27,7 @@
/** /**
* Callback which is invoked by libVNCServer when it needs to read the user's * Callback which is invoked by libVNCServer when it needs to read the user's
* VNC password. As ths user's password, if any, will be stored in the * VNC password. As this user's password, if any, will be stored in the
* connection settings, this function does nothing more than return that value. * connection settings, this function does nothing more than return that value.
* *
* @param client * @param client
@ -38,5 +38,23 @@
*/ */
char* guac_vnc_get_password(rfbClient* client); char* guac_vnc_get_password(rfbClient* client);
/**
* Callback which is invoked by libVNCServer when it needs to read the user's
* VNC credentials. The credentials are stored in the connection settings,
* so they will be retrieved from that.
*
* @param client
* The rfbClient associated with the VNC connection requiring the
* authentication.
*
* @param credentialType
* The credential type being requested, as defined by the libVNCclient
* code in the rfbclient.h header.
*
* @return
* The rfbCredential object that contains the required credentials.
*/
rfbCredential* guac_vnc_get_credentials(rfbClient* client, int credentialType);
#endif #endif

View File

@ -35,6 +35,7 @@ const char* GUAC_VNC_CLIENT_ARGS[] = {
"port", "port",
"read-only", "read-only",
"encodings", "encodings",
"username",
"password", "password",
"swap-red-blue", "swap-red-blue",
"color-depth", "color-depth",
@ -108,6 +109,11 @@ enum VNC_ARGS_IDX {
*/ */
IDX_ENCODINGS, IDX_ENCODINGS,
/**
* The username to send to the VNC server if authentication is requested.
*/
IDX_USERNAME,
/** /**
* The password to send to the VNC server if authentication is requested. * The password to send to the VNC server if authentication is requested.
*/ */
@ -337,6 +343,10 @@ guac_vnc_settings* guac_vnc_parse_args(guac_user* user,
guac_user_parse_args_int(user, GUAC_VNC_CLIENT_ARGS, argv, guac_user_parse_args_int(user, GUAC_VNC_CLIENT_ARGS, argv,
IDX_PORT, 0); IDX_PORT, 0);
settings->username =
guac_user_parse_args_string(user, GUAC_VNC_CLIENT_ARGS, argv,
IDX_USERNAME, ""); /* NOTE: freed by libvncclient */
settings->password = settings->password =
guac_user_parse_args_string(user, GUAC_VNC_CLIENT_ARGS, argv, guac_user_parse_args_string(user, GUAC_VNC_CLIENT_ARGS, argv,
IDX_PASSWORD, ""); /* NOTE: freed by libvncclient */ IDX_PASSWORD, ""); /* NOTE: freed by libvncclient */

View File

@ -45,6 +45,11 @@ typedef struct guac_vnc_settings {
*/ */
int port; int port;
/**
* The username given in the arguments.
*/
char* username;
/** /**
* The password given in the arguments. * The password given in the arguments.
*/ */

View File

@ -153,6 +153,9 @@ rfbClient* guac_vnc_get_client(guac_client* client) {
} }
/* Authentication */
rfb_client->GetCredential = guac_vnc_get_credentials;
/* Password */ /* Password */
rfb_client->GetPassword = guac_vnc_get_password; rfb_client->GetPassword = guac_vnc_get_password;