Skip to content

Commit

Permalink
Add AWS Authentication parameters to DSN UI (#115)
Browse files Browse the repository at this point in the history
  • Loading branch information
justing-bq authored and yanw-bq committed May 17, 2023
1 parent 08517c8 commit b8a0e09
Show file tree
Hide file tree
Showing 9 changed files with 198 additions and 57 deletions.
7 changes: 7 additions & 0 deletions installer/myodbc-installer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -569,6 +569,13 @@ int list_datasource_details(DataSource *ds)
if (ds->get_server_public_key) printf("\tGET_SERVER_PUBLIC_KEY\n");
if (ds->enable_dns_srv) printf("\tENABLE_DNS_SRV\n");
if (ds->multi_host) printf("\tMULTI_HOST\n");
/* AWS Authentication */
if (ds->auth_mode) printf("\tAUTH_MODE");
if (ds->auth_region) printf("\tAUTH_REGION");
if (ds->auth_host) printf("\tAUTH_HOST");
if (ds->auth_port) printf("\tAUTH_PORT");
if (ds->auth_expiration) printf("\tAUTH_EXPIRATION");
if (ds->auth_secret_id) printf("\tAUTH_SECRET_ID");
/* Failover */
if (ds->enable_cluster_failover) printf("\tENABLE_CLUSTER_FAILOVER\n");
if (ds->allow_reader_connections) printf("\tALLOW_READER_CONNECTIONS\n");
Expand Down
44 changes: 30 additions & 14 deletions setupgui/callbacks.cc
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,15 @@ void syncTabsData(HWND hwnd, DataSource *params)
GET_STRING_TAB(AUTH_TAB, oci_config_file);
GET_STRING_TAB(AUTH_TAB, oci_config_profile);

/* 3 - Failover */
/* 3 - AWS Authentication */
GET_COMBO_TAB(AWS_AUTH_TAB, auth_mode);
GET_STRING_TAB(AWS_AUTH_TAB, auth_region);
GET_STRING_TAB(AWS_AUTH_TAB, auth_host);
GET_UNSIGNED_TAB(AWS_AUTH_TAB, auth_port);
GET_UNSIGNED_TAB(AWS_AUTH_TAB, auth_expiration);
GET_STRING_TAB(AWS_AUTH_TAB, auth_secret_id);

/* 4 - Failover */
GET_BOOL_TAB(FAILOVER_TAB, enable_cluster_failover);
GET_BOOL_TAB(FAILOVER_TAB, allow_reader_connections);
GET_BOOL_TAB(FAILOVER_TAB, gather_perf_metrics);
Expand All @@ -323,7 +331,7 @@ void syncTabsData(HWND hwnd, DataSource *params)
GET_UNSIGNED_TAB(FAILOVER_TAB, connect_timeout);
GET_UNSIGNED_TAB(FAILOVER_TAB, network_timeout);

/* 4 - Monitoring */
/* 5 - Monitoring */
GET_BOOL_TAB(MONITORING_TAB, enable_failure_detection);
if (READ_BOOL_TAB(MONITORING_TAB, enable_failure_detection))
{
Expand All @@ -335,15 +343,15 @@ void syncTabsData(HWND hwnd, DataSource *params)
}


/* 5 - Metadata */
/* 6 - Metadata */
GET_BOOL_TAB(METADATA_TAB, change_bigint_columns_to_int);
GET_BOOL_TAB(METADATA_TAB, handle_binary_as_char);
GET_BOOL_TAB(METADATA_TAB, return_table_names_for_SqlDescribeCol);
GET_BOOL_TAB(METADATA_TAB, no_catalog);
GET_BOOL_TAB(METADATA_TAB, no_schema);
GET_BOOL_TAB(METADATA_TAB, limit_column_size);

/* 6 - Cursors/Results */
/* 7 - Cursors/Results */
GET_BOOL_TAB(CURSORS_TAB, return_matching_rows);
GET_BOOL_TAB(CURSORS_TAB, auto_increment_null_search);
GET_BOOL_TAB(CURSORS_TAB, dynamic_cursor);
Expand All @@ -361,10 +369,10 @@ void syncTabsData(HWND hwnd, DataSource *params)
{
params->cursor_prefetch_number= 0;
}
/* 7 - debug*/
/* 8 - debug*/
GET_BOOL_TAB(DEBUG_TAB,save_queries);

/* 8 - ssl related */
/* 9 - ssl related */
GET_STRING_TAB(SSL_TAB, sslkey);
GET_STRING_TAB(SSL_TAB, sslcert);
GET_STRING_TAB(SSL_TAB, sslca);
Expand All @@ -379,7 +387,7 @@ void syncTabsData(HWND hwnd, DataSource *params)
GET_STRING_TAB(SSL_TAB, ssl_crl);
GET_STRING_TAB(SSL_TAB, ssl_crlpath);

/* 9 - Misc*/
/* 10 - Misc*/
GET_BOOL_TAB(MISC_TAB, safe);
GET_BOOL_TAB(MISC_TAB, dont_use_set_locale);
GET_BOOL_TAB(MISC_TAB, ignore_space_after_function_names);
Expand Down Expand Up @@ -434,7 +442,15 @@ void syncTabs(HWND hwnd, DataSource *params)
SET_STRING_TAB(AUTH_TAB, oci_config_file);
SET_STRING_TAB(AUTH_TAB, oci_config_profile);

/* 3 - Failover */
/* 3 - AWS Authentication */
SET_COMBO_TAB(AWS_AUTH_TAB, auth_mode);
SET_STRING_TAB(AWS_AUTH_TAB, auth_region);
SET_STRING_TAB(AWS_AUTH_TAB, auth_host);
SET_UNSIGNED_TAB(AWS_AUTH_TAB, auth_port);
SET_UNSIGNED_TAB(AWS_AUTH_TAB, auth_expiration);
SET_STRING_TAB(AWS_AUTH_TAB, auth_secret_id);

/* 4 - Failover */
SET_BOOL_TAB(FAILOVER_TAB, enable_cluster_failover);
SET_BOOL_TAB(FAILOVER_TAB, allow_reader_connections);
SET_BOOL_TAB(FAILOVER_TAB, gather_perf_metrics);
Expand Down Expand Up @@ -485,7 +501,7 @@ void syncTabs(HWND hwnd, DataSource *params)
SET_UNSIGNED_TAB(FAILOVER_TAB, network_timeout);
}

/* 4 - Monitoring */
/* 5 - Monitoring */
SET_BOOL_TAB(MONITORING_TAB, enable_failure_detection);
if (READ_BOOL_TAB(MONITORING_TAB, enable_failure_detection)) {
#ifdef _WIN32
Expand All @@ -502,15 +518,15 @@ void syncTabs(HWND hwnd, DataSource *params)
SET_UNSIGNED_TAB(MONITORING_TAB, failure_detection_timeout);
}

/* 5 - Metadata */
/* 6 - Metadata */
SET_BOOL_TAB(METADATA_TAB, change_bigint_columns_to_int);
SET_BOOL_TAB(METADATA_TAB, handle_binary_as_char);
SET_BOOL_TAB(METADATA_TAB, return_table_names_for_SqlDescribeCol);
SET_BOOL_TAB(METADATA_TAB, no_catalog);
SET_BOOL_TAB(METADATA_TAB, no_schema);
SET_BOOL_TAB(METADATA_TAB, limit_column_size);

/* 6 - Cursors/Results */
/* 7 - Cursors/Results */
SET_BOOL_TAB(CURSORS_TAB, return_matching_rows);
SET_BOOL_TAB(CURSORS_TAB, auto_increment_null_search);
SET_BOOL_TAB(CURSORS_TAB, dynamic_cursor);
Expand All @@ -529,10 +545,10 @@ void syncTabs(HWND hwnd, DataSource *params)
SET_UNSIGNED_TAB(CURSORS_TAB, cursor_prefetch_number);
}

/* 7 - debug*/
/* 8 - debug*/
SET_BOOL_TAB(DEBUG_TAB,save_queries);

/* 8 - ssl related */
/* 9 - ssl related */
#ifdef _WIN32
if ( getTabCtrlTabPages(SSL_TAB-1) )
#endif
Expand Down Expand Up @@ -570,7 +586,7 @@ void syncTabs(HWND hwnd, DataSource *params)
SET_STRING_TAB(SSL_TAB, tls_versions);
}

/* 9 - Misc*/
/* 10 - Misc*/
SET_BOOL_TAB(MISC_TAB, safe);
SET_BOOL_TAB(MISC_TAB, dont_use_set_locale);
SET_BOOL_TAB(MISC_TAB, ignore_space_after_function_names);
Expand Down
15 changes: 8 additions & 7 deletions setupgui/setupgui.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,14 @@

#define CONNECTION_TAB 1
#define AUTH_TAB 2
#define FAILOVER_TAB 3
#define MONITORING_TAB 4
#define METADATA_TAB 5
#define CURSORS_TAB 6
#define DEBUG_TAB 7
#define SSL_TAB 8
#define MISC_TAB 9
#define AWS_AUTH_TAB 3
#define FAILOVER_TAB 4
#define MONITORING_TAB 5
#define METADATA_TAB 6
#define CURSORS_TAB 7
#define DEBUG_TAB 8
#define SSL_TAB 9
#define MISC_TAB 10

#else
# include <gtk/gtk.h>
Expand Down
Binary file modified setupgui/windows/aws_connector_odbc_header.bmp
Binary file not shown.
53 changes: 45 additions & 8 deletions setupgui/windows/odbcdialogparams.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,7 @@ void btnDetails_Click (HWND hwnd)
static PWSTR tabnames[] = {
L"Connection",
L"Authentication",
L"AWS Authentication",
L"Cluster Failover",
L"Monitoring",
L"Metadata",
Expand All @@ -396,6 +397,7 @@ void btnDetails_Click (HWND hwnd)
MAKEINTRESOURCE(IDD_TAB7),
MAKEINTRESOURCE(IDD_TAB8),
MAKEINTRESOURCE(IDD_TAB9),
MAKEINTRESOURCE(IDD_TAB10),
0};

New_TabControl( &TabCtrl_1, // address of TabControl struct
Expand All @@ -408,17 +410,26 @@ void btnDetails_Click (HWND hwnd)
flag = true;


HWND auth_tab = TabCtrl_1.hTabPages[AWS_AUTH_TAB - 1];
HWND auth_mode_dlg = GetDlgItem(auth_tab, IDC_EDIT_auth_mode);

ComboBox_ResetContent(auth_mode_dlg);

ComboBox_AddString(auth_mode_dlg, L"");
ComboBox_AddString(auth_mode_dlg, LSTR(AUTH_MODE_IAM));
ComboBox_AddString(auth_mode_dlg, LSTR(AUTH_MODE_SECRETS_MANAGER));

HWND ssl_tab = TabCtrl_1.hTabPages[SSL_TAB-1];
HWND combo = GetDlgItem(ssl_tab, IDC_EDIT_sslmode);
HWND sslmode_dlg = GetDlgItem(ssl_tab, IDC_EDIT_sslmode);

ComboBox_ResetContent(combo);
ComboBox_ResetContent(sslmode_dlg);

ComboBox_AddString(combo, L"");
ComboBox_AddString(combo, LSTR(ODBC_SSL_MODE_DISABLED));
ComboBox_AddString(combo, LSTR(ODBC_SSL_MODE_PREFERRED));
ComboBox_AddString(combo, LSTR(ODBC_SSL_MODE_REQUIRED));
ComboBox_AddString(combo, LSTR(ODBC_SSL_MODE_VERIFY_CA));
ComboBox_AddString(combo, LSTR(ODBC_SSL_MODE_VERIFY_IDENTITY));
ComboBox_AddString(sslmode_dlg, L"");
ComboBox_AddString(sslmode_dlg, LSTR(ODBC_SSL_MODE_DISABLED));
ComboBox_AddString(sslmode_dlg, LSTR(ODBC_SSL_MODE_PREFERRED));
ComboBox_AddString(sslmode_dlg, LSTR(ODBC_SSL_MODE_REQUIRED));
ComboBox_AddString(sslmode_dlg, LSTR(ODBC_SSL_MODE_VERIFY_CA));
ComboBox_AddString(sslmode_dlg, LSTR(ODBC_SSL_MODE_VERIFY_IDENTITY));

syncTabs(hwnd, pParams);
}
Expand Down Expand Up @@ -667,6 +678,32 @@ void FormMain_OnCommand(HWND hwnd, int id, HWND hwndCtl, UINT codeNotify)
case IDC_RADIO_pipe:
SwitchTcpOrPipe(hwnd, !!Button_GetCheck(GetDlgItem(hwnd, IDC_RADIO_pipe)));
break;
case IDC_EDIT_auth_mode:
{
HWND authTab = TabCtrl_1.hTabPages[AWS_AUTH_TAB - 1];
assert(authTab);

HWND host = GetDlgItem(authTab, IDC_EDIT_auth_host);
HWND port = GetDlgItem(authTab, IDC_EDIT_auth_port);
HWND expiration = GetDlgItem(authTab, IDC_EDIT_auth_expiration);
HWND secret_id = GetDlgItem(authTab, IDC_EDIT_auth_secret_id);
assert(port);
assert(host);
assert(expiration);
assert(secret_id);

wchar_t authMode[20];
ComboBox_GetText(GetDlgItem(authTab, IDC_EDIT_auth_mode), authMode, sizeof(authMode));

BOOL usingIAM = wcscmp(authMode, L"IAM") == 0;
EnableWindow(port, usingIAM);
EnableWindow(host, usingIAM);
EnableWindow(expiration, usingIAM);

BOOL usingSecretsManager = wcscmp(authMode, L"SECRETS MANAGER") == 0;
EnableWindow(secret_id, usingSecretsManager);
}
break;
case IDC_CHECK_gather_perf_metrics:
{
HWND failoverTab = TabCtrl_1.hTabPages[FAILOVER_TAB-1];
Expand Down
67 changes: 43 additions & 24 deletions setupgui/windows/odbcdialogparams.rc
Original file line number Diff line number Diff line change
Expand Up @@ -95,38 +95,38 @@ END
// Dialog
//

IDD_DIALOG1 DIALOGEX 0, 0, 379, 450
IDD_DIALOG1 DIALOGEX 0, 0, 430, 450
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
CAPTION "Dialog"
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
GROUPBOX "Connection Parameters",IDC_STATIC,18,53,348,148
GROUPBOX "Connection Parameters",IDC_STATIC,18,53,396,148
RTEXT "Data Source &Name:",IDC_STATIC,23,68,67,8
EDITTEXT IDC_EDIT_name,98,64,243,14,ES_AUTOHSCROLL
EDITTEXT IDC_EDIT_name,98,64,289,14,ES_AUTOHSCROLL
RTEXT "D&escription:",IDC_STATIC,23,87,67,8
EDITTEXT IDC_EDIT_description,98,83,243,14,ES_AUTOHSCROLL
EDITTEXT IDC_EDIT_description,98,83,289,14,ES_AUTOHSCROLL
GROUPBOX "",IDC_STATIC,31,105,59,26,NOT WS_VISIBLE
CONTROL "TCP/IP &Server:",IDC_RADIO_tcp,"Button",BS_AUTORADIOBUTTON | BS_RIGHT,32,105,60,13
CONTROL "Named &Pipe:",IDC_RADIO_pipe,"Button",BS_AUTORADIOBUTTON | BS_RIGHT,32,122,60,13
RTEXT "Server",IDC_STATIC,97,104,0,0 // Invisible, needed for accessibility
EDITTEXT IDC_EDIT_server,98,104,185,14,ES_AUTOHSCROLL
RTEXT "&Port:",IDC_STATIC,289,107,19,8
EDITTEXT IDC_EDIT_port,312,104,29,14,ES_AUTOHSCROLL | ES_NUMBER
EDITTEXT IDC_EDIT_server,98,104,231,14,ES_AUTOHSCROLL
RTEXT "&Port:",IDC_STATIC,335,107,19,8
EDITTEXT IDC_EDIT_port,358,104,29,14,ES_AUTOHSCROLL | ES_NUMBER
RTEXT "Named Pipe",IDC_STATIC,97,104,0,0 // Invisible, needed for accessibility
EDITTEXT IDC_EDIT_socket,98,123,185,14,WS_DISABLED,ES_AUTOHSCROLL
EDITTEXT IDC_EDIT_socket,98,123,289,14,WS_DISABLED,ES_AUTOHSCROLL
RTEXT "&User:",IDC_STATIC,23,143,67,8
EDITTEXT IDC_EDIT_uid,98,142,185,14,ES_AUTOHSCROLL
EDITTEXT IDC_EDIT_uid,98,142,289,14,ES_AUTOHSCROLL
RTEXT "Pass&word:",IDC_STATIC,23,164,67,8
EDITTEXT IDC_EDIT_pwd,98,161,185,14,ES_PASSWORD | ES_AUTOHSCROLL
EDITTEXT IDC_EDIT_pwd,98,161,289,14,ES_PASSWORD | ES_AUTOHSCROLL
RTEXT "Data&base:",IDC_STATIC,23,182,67,8
COMBOBOX IDC_EDIT_database,98,180,185,42,CBS_DROPDOWN | CBS_AUTOHSCROLL | CBS_SORT | WS_VSCROLL | WS_TABSTOP
PUSHBUTTON "&Test",IDC_BUTTON_TEST,299,179,41,14
CONTROL "",IDC_TAB1,"SysTabControl32",WS_TABSTOP,17,214,349,234 // Change the size of this to fit more controls
COMBOBOX IDC_EDIT_database,98,180,231,42,CBS_DROPDOWN | CBS_AUTOHSCROLL | CBS_SORT | WS_VSCROLL | WS_TABSTOP
PUSHBUTTON "&Test",IDC_BUTTON_TEST,345,179,41,14
CONTROL "",IDC_TAB1,"SysTabControl32",WS_TABSTOP,17,214,399,234 // Change the size of this to fit more controls
PUSHBUTTON "&Details >>",IDC_BUTTON_DETAILS,17,405,50,15
DEFPUSHBUTTON "OK",IDOK,211,405,50,15
PUSHBUTTON "&Cancel",IDCANCEL,265,405,50,15
PUSHBUTTON "&Help",IDC_BUTTON_HELP,317,405,49,15
CONTROL IDB_LOGO,IDC_STATIC,"Static",SS_BITMAP,0,0,379,39
DEFPUSHBUTTON "OK",IDOK,257,405,50,15
PUSHBUTTON "&Cancel",IDCANCEL,311,405,50,15
PUSHBUTTON "&Help",IDC_BUTTON_HELP,365,405,49,15
CONTROL IDB_LOGO,IDC_STATIC,"Static",SS_BITMAP,0,0,650,63
END

IDD_TAB1 DIALOGEX 0, 0, 224, 231
Expand Down Expand Up @@ -188,7 +188,26 @@ BEGIN
#endif
END

IDD_TAB3 DIALOGEX 0, 0, 209, 281
IDD_TAB3 DIALOGEX 0, 0, 209, 181
STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
RTEXT "Authentication Mode:", IDC_STATIC, 0, 10, 80, 10
COMBOBOX IDC_EDIT_auth_mode, 85, 10, 85, 10,
CBS_DROPDOWN | CBS_AUTOHSCROLL | CBS_SORT | WS_VSCROLL | WS_TABSTOP
RTEXT "Auth Region:", IDC_STATIC, 0, 25, 80, 10
EDITTEXT IDC_EDIT_auth_region, 85, 25, 85, 10, ES_AUTOHSCROLL
RTEXT "IAM Host:", IDC_STATIC, 0, 40, 80, 10
EDITTEXT IDC_EDIT_auth_host, 85, 40, 85, 10, ES_AUTOHSCROLL
RTEXT "IAM Port:", IDC_STATIC, 0, 55, 80, 10
EDITTEXT IDC_EDIT_auth_port, 85, 55, 85, 10, ES_AUTOHSCROLL | ES_NUMBER
RTEXT "IAM Expire Time:", IDC_STATIC, 0, 70, 80, 10
EDITTEXT IDC_EDIT_auth_expiration, 85, 70, 85, 10, ES_AUTOHSCROLL | ES_NUMBER
RTEXT "Secret ID:", IDC_STATIC, 0, 85, 80, 10
EDITTEXT IDC_EDIT_auth_secret_id, 85, 85, 85, 10, ES_AUTOHSCROLL
END

IDD_TAB4 DIALOGEX 0, 0, 209, 281
STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
Expand Down Expand Up @@ -220,7 +239,7 @@ BEGIN
EDITTEXT IDC_EDIT_network_timeout,132,193,64,12,ES_AUTOHSCROLL | ES_NUMBER
END

IDD_TAB4 DIALOGEX 0, 0, 209, 181
IDD_TAB5 DIALOGEX 0, 0, 209, 181
STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
Expand All @@ -238,7 +257,7 @@ BEGIN
EDITTEXT IDC_EDIT_monitor_disposal_time,132,85,64,12,ES_AUTOHSCROLL | ES_NUMBER| WS_DISABLED
END

IDD_TAB5 DIALOGEX 0, 0, 209, 181
IDD_TAB6 DIALOGEX 0, 0, 209, 181
STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
Expand All @@ -257,7 +276,7 @@ BEGIN

END

IDD_TAB6 DIALOGEX 0, 0, 209, 181
IDD_TAB7 DIALOGEX 0, 0, 209, 181
STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
Expand All @@ -284,15 +303,15 @@ BEGIN
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,125,138,10
END

IDD_TAB7 DIALOGEX 0, 0, 209, 181
IDD_TAB8 DIALOGEX 0, 0, 209, 181
STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
CONTROL "&Log driver activity to %TEMP%\\myodbc.log",IDC_CHECK_save_queries,
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,12,160,10
END

IDD_TAB8 DIALOGEX 0, 0, 509, 181
IDD_TAB9 DIALOGEX 0, 0, 509, 181
STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
Expand Down Expand Up @@ -329,7 +348,7 @@ BEGIN
END


IDD_TAB9 DIALOGEX 0, 0, 209, 181
IDD_TAB10 DIALOGEX 0, 0, 209, 181
STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
Expand Down
Loading

0 comments on commit b8a0e09

Please sign in to comment.