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;
}
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
* 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.
*
* @param client
@ -38,5 +38,23 @@
*/
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

View File

@ -35,6 +35,7 @@ const char* GUAC_VNC_CLIENT_ARGS[] = {
"port",
"read-only",
"encodings",
"username",
"password",
"swap-red-blue",
"color-depth",
@ -108,6 +109,11 @@ enum VNC_ARGS_IDX {
*/
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.
*/
@ -337,10 +343,14 @@ guac_vnc_settings* guac_vnc_parse_args(guac_user* user,
guac_user_parse_args_int(user, GUAC_VNC_CLIENT_ARGS, argv,
IDX_PORT, 0);
settings->username =
guac_user_parse_args_string(user, GUAC_VNC_CLIENT_ARGS, argv,
IDX_USERNAME, ""); /* NOTE: freed by libvncclient */
settings->password =
guac_user_parse_args_string(user, GUAC_VNC_CLIENT_ARGS, argv,
IDX_PASSWORD, ""); /* NOTE: freed by libvncclient */
/* Remote cursor */
if (strcmp(argv[IDX_CURSOR], "remote") == 0) {
guac_user_log(user, GUAC_LOG_INFO, "Cursor rendering: remote");

View File

@ -45,6 +45,11 @@ typedef struct guac_vnc_settings {
*/
int port;
/**
* The username given in the arguments.
*/
char* username;
/**
* 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 */
rfb_client->GetPassword = guac_vnc_get_password;