Fixed AuthenticateEx issues

This commit is contained in:
Armin Novak 2021-09-06 15:12:12 +02:00 committed by akallabeth
parent 85f1d46eab
commit b336751861
7 changed files with 76 additions and 26 deletions

View File

@ -275,8 +275,7 @@ static BOOL tf_client_new(freerdp* instance, rdpContext* context)
instance->PreConnect = tf_pre_connect;
instance->PostConnect = tf_post_connect;
instance->PostDisconnect = tf_post_disconnect;
instance->Authenticate = client_cli_authenticate;
instance->GatewayAuthenticate = client_cli_gw_authenticate;
instance->AuthenticateEx = client_cli_authenticate_ex;
instance->VerifyCertificateEx = client_cli_verify_certificate_ex;
instance->VerifyChangedCertificateEx = client_cli_verify_changed_certificate_ex;
instance->LogonErrorInfo = tf_logon_error_info;

View File

@ -607,8 +607,7 @@ static BOOL wlf_client_new(freerdp* instance, rdpContext* context)
instance->PreConnect = wl_pre_connect;
instance->PostConnect = wl_post_connect;
instance->PostDisconnect = wl_post_disconnect;
instance->Authenticate = client_cli_authenticate;
instance->GatewayAuthenticate = client_cli_gw_authenticate;
instance->AuthenticateEx = client_cli_authenticate_ex;
instance->VerifyCertificateEx = client_cli_verify_certificate_ex;
instance->VerifyChangedCertificateEx = client_cli_verify_changed_certificate_ex;
instance->PresentGatewayMessage = client_cli_present_gateway_message;

View File

@ -1820,8 +1820,7 @@ static BOOL xfreerdp_client_new(freerdp* instance, rdpContext* context)
instance->PreConnect = xf_pre_connect;
instance->PostConnect = xf_post_connect;
instance->PostDisconnect = xf_post_disconnect;
instance->Authenticate = client_cli_authenticate;
instance->GatewayAuthenticate = client_cli_gw_authenticate;
instance->AuthenticateEx = client_cli_authenticate_ex;
instance->VerifyCertificateEx = client_cli_verify_certificate_ex;
instance->VerifyChangedCertificateEx = client_cli_verify_changed_certificate_ex;
instance->PresentGatewayMessage = client_cli_present_gateway_message;

View File

@ -353,13 +353,29 @@ out:
* @return TRUE if a password was successfully entered. See freerdp_passphrase_read() for more
* details.
*/
static BOOL client_cli_authenticate_raw(freerdp* instance, BOOL gateway, char** username,
static BOOL client_cli_authenticate_raw(freerdp* instance, rdp_auth_reason reason, char** username,
char** password, char** domain)
{
static const size_t password_size = 512;
const char* auth[] = { "Username: ", "Domain: ", "Password: " };
const char* gw[] = { "GatewayUsername: ", "GatewayDomain: ", "GatewayPassword: " };
const char** prompt = (gateway) ? gw : auth;
const char** prompt;
switch (reason)
{
case AUTH_NLA:
case AUTH_TLS:
case AUTH_RDP:
prompt = auth;
break;
case GW_AUTH_HTTP:
case GW_AUTH_RDG:
case GW_AUTH_RPC:
prompt = gw;
break;
default:
return FALSE;
}
if (!username || !password || !domain)
return FALSE;
@ -423,6 +439,44 @@ fail:
return FALSE;
}
BOOL client_cli_authenticate_ex(freerdp* instance, char** username, char** password, char** domain,
rdp_auth_reason reason)
{
WINPR_ASSERT(instance);
WINPR_ASSERT(username);
WINPR_ASSERT(password);
WINPR_ASSERT(domain);
if (instance->settings->SmartcardLogon)
{
WLog_INFO(TAG, "Authentication via smartcard");
return TRUE;
}
switch (reason)
{
case AUTH_NLA:
break;
case AUTH_TLS:
if ((*username) && (*password))
return TRUE;
break;
case AUTH_RDP:
if ((*username) && (*password))
return TRUE;
break;
case GW_AUTH_HTTP:
case GW_AUTH_RDG:
case GW_AUTH_RPC:
break;
default:
return FALSE;
}
return client_cli_authenticate_raw(instance, reason, username, password, domain);
}
#if defined(WITH_FREERDP_DEPRECATED)
BOOL client_cli_authenticate(freerdp* instance, char** username, char** password, char** domain)
{
if (instance->settings->SmartcardLogon)
@ -438,6 +492,7 @@ BOOL client_cli_gw_authenticate(freerdp* instance, char** username, char** passw
{
return client_cli_authenticate_raw(instance, TRUE, username, password, domain);
}
#endif
static DWORD client_cli_accept_certificate(rdpSettings* settings)
{

View File

@ -1518,7 +1518,7 @@ static BOOL parseSizeValue(const char* input, unsigned long* v1, unsigned long*
return TRUE;
}
static BOOL prepare_default_settings(rdpSettings* settings, const COMMAND_LINE_ARGUMENT_A* args,
static BOOL prepare_default_settings(rdpSettings* settings, COMMAND_LINE_ARGUMENT_A* args,
BOOL rdp_file)
{
size_t x;

View File

@ -100,12 +100,19 @@ extern "C"
FREERDP_API int freerdp_client_settings_parse_assistance_file(rdpSettings* settings, int argc,
char* argv[]);
FREERDP_API BOOL client_cli_authenticate(freerdp* instance, char** username, char** password,
char** domain);
FREERDP_API BOOL client_cli_gw_authenticate(freerdp* instance, char** username, char** password,
char** domain);
FREERDP_API BOOL client_cli_authenticate_ex(freerdp* instance, char** username, char** password,
char** domain, rdp_auth_reason reason);
#if defined(WITH_FREERDP_DEPRECATED)
FREERDP_API WINPR_DEPRECATED_VAR("Use client_cli_authenticate_ex",
BOOL client_cli_authenticate(freerdp* instance,
char** username, char** password,
char** domain));
FREERDP_API
WINPR_DEPRECATED_VAR("Use client_cli_authenticate_ex",
BOOL client_cli_gw_authenticate(freerdp* instance, char** username,
char** password, char** domain));
FREERDP_API WINPR_DEPRECATED_VAR(
"Use client_cli_verify_certificate_ex",
DWORD client_cli_verify_certificate(freerdp* instance, const char* common_name,

View File

@ -118,24 +118,15 @@ auth_status utils_authenticate(freerdp* instance, rdp_auth_reason reason, BOOL o
return AUTH_NO_CREDENTIALS;
if (instance->AuthenticateEx)
proceed =
instance->AuthenticateEx(instance, &settings->GatewayUsername,
&settings->GatewayPassword, &settings->GatewayDomain, reason);
proceed = instance->AuthenticateEx(instance, &settings->Username, &settings->Password,
&settings->Domain, reason);
else
proceed = instance->Authenticate(instance, &settings->GatewayUsername,
&settings->GatewayPassword, &settings->GatewayDomain);
proceed = instance->Authenticate(instance, &settings->Username, &settings->Password,
&settings->Domain);
if (!proceed)
return AUTH_NO_CREDENTIALS;
if (!instance->Authenticate(instance, &settings->Username, &settings->Password,
&settings->Domain))
{
freerdp_set_last_error_log(instance->context,
FREERDP_ERROR_CONNECT_NO_OR_MISSING_CREDENTIALS);
return FALSE;
}
if (!utils_sync_credentials(settings, TRUE))
return AUTH_FAILED;
return AUTH_SUCCESS;