Skip to content

Commit

Permalink
Add AWS Authentication parameters to DSN UI
Browse files Browse the repository at this point in the history
  • Loading branch information
justing-bq committed Feb 23, 2023
1 parent 59e30f5 commit 0778b9d
Show file tree
Hide file tree
Showing 8 changed files with 212 additions and 70 deletions.
7 changes: 7 additions & 0 deletions installer/myodbc-installer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -565,6 +565,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 @@ -300,7 +300,15 @@ void syncTabsData(HWND hwnd, DataSource *params)
GET_STRING_TAB(MFA_TAB, pwd3);
#endif

/* 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 @@ -319,7 +327,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 @@ -331,15 +339,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 @@ -357,10 +365,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 @@ -375,7 +383,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 @@ -426,7 +434,15 @@ void syncTabs(HWND hwnd, DataSource *params)
SET_STRING_TAB(MFA_TAB, pwd3);
#endif

/* 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 @@ -477,7 +493,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 @@ -494,15 +510,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 @@ -521,10 +537,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 @@ -562,7 +578,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
18 changes: 10 additions & 8 deletions setupgui/setupgui.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,21 +39,23 @@

#if MFA_ENABLED
#define MFA_TAB 2
#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
#define AWS_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
#else
#define FAILOVER_TAB 2
#define MONITORING_TAB 3
#define METADATA_TAB 4
#define CURSORS_TAB 5
#define DEBUG_TAB 6
#define SSL_TAB 7
#define MISC_TAB 8
#endif

#else
Expand Down
55 changes: 46 additions & 9 deletions setupgui/windows/odbcdialogparams.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,7 @@ void btnDetails_Click (HWND hwnd)
#if MFA_ENABLED
L"MFA",
#endif
L"AWS Authentication",
L"Cluster Failover",
L"Monitoring",
L"Metadata",
Expand All @@ -397,8 +398,9 @@ void btnDetails_Click (HWND hwnd)
MAKEINTRESOURCE(IDD_TAB6),
MAKEINTRESOURCE(IDD_TAB7),
MAKEINTRESOURCE(IDD_TAB8),
#if MFA_ENABLED
MAKEINTRESOURCE(IDD_TAB9),
#if MFA_ENABLED
MAKEINTRESOURCE(IDD_TAB10),
#endif
0};

Expand All @@ -412,17 +414,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 @@ -671,6 +682,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
Loading

0 comments on commit 0778b9d

Please sign in to comment.