Skip to content

Commit 9b0b282

Browse files
committed
Replace web::credentials::password with web::credentials::_decrypt.
1 parent a8bd7ea commit 9b0b282

File tree

2 files changed

+3
-23
lines changed

2 files changed

+3
-23
lines changed

Release/include/cpprest/details/web_utilities.h

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -102,34 +102,13 @@ class credentials
102102
/// <returns>A string containing the user name.</returns>
103103
const utility::string_t &username() const { return m_username; }
104104

105-
/// <summary>
106-
/// The password for the user name associated with the credentials.
107-
/// </summary>
108-
/// <returns>A string containing the password.</returns>
109-
CASABLANCA_DEPRECATED("This API is deprecated for security reasons to avoid unnecessary password copies stored in plaintext.")
110-
utility::string_t password() const
111-
{
112-
#if defined(_WIN32) && !defined(CPPREST_TARGET_XP)
113-
return utility::string_t(*m_password.decrypt());
114-
#else
115-
return m_password;
116-
#endif
117-
}
118-
119105
/// <summary>
120106
/// Checks if credentials have been set
121107
/// </summary>
122108
/// <returns><c>true</c> if user name and password is set, <c>false</c> otherwise.</returns>
123109
bool is_set() const { return !m_username.empty(); }
124110

125-
private:
126-
friend class http::client::details::winhttp_client;
127-
friend class http::client::details::winrt_client;
128-
friend class http::client::details::asio_context;
129-
friend class websockets::client::details::winrt_callback_client;
130-
friend class websockets::client::details::wspp_callback_client;
131-
132-
details::plaintext_string decrypt() const
111+
details::plaintext_string _decrypt() const
133112
{
134113
// Encryption APIs not supported on XP
135114
#if defined(_WIN32) && !defined(CPPREST_TARGET_XP)
@@ -139,6 +118,7 @@ class credentials
139118
#endif
140119
}
141120

121+
private:
142122
::utility::string_t m_username;
143123

144124
#if defined(_WIN32) && !defined(CPPREST_TARGET_XP)

Release/src/http/client/http_client_winhttp.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -968,7 +968,7 @@ class winhttp_client : public _http_client_communicator
968968

969969
// New scope to ensure plaintext password is cleared as soon as possible.
970970
{
971-
auto password = cred.decrypt();
971+
auto password = cred._decrypt();
972972
if (!WinHttpSetCredentials(
973973
hRequestHandle,
974974
dwAuthTarget,

0 commit comments

Comments
 (0)