credentials: Move user impersonation to peer::get_identity()
To retrieve user credentials, EapHost provides us the interactive user's token we can use to impersonate. By doing the impersonation early in peer::get_identity(), we don't need to pass the token down the lower methods. This is rather a simplification than a performance optimization. Signed-off-by: Simon Rozman <simon@rozman.si>
This commit is contained in:
@@ -297,7 +297,6 @@ LPCTSTR eap::credentials_identity::target_suffix() const
|
||||
|
||||
eap::credentials::source_t eap::credentials_identity::combine(
|
||||
_In_ DWORD dwFlags,
|
||||
_In_opt_ HANDLE hTokenImpersonateUser,
|
||||
_In_opt_ const credentials *cred_cached,
|
||||
_In_ const config_method &cfg,
|
||||
_In_opt_z_ LPCTSTR pszTargetName)
|
||||
@@ -320,9 +319,6 @@ eap::credentials::source_t eap::credentials_identity::combine(
|
||||
}
|
||||
|
||||
if (pszTargetName) {
|
||||
// Switch user context.
|
||||
user_impersonator impersonating(hTokenImpersonateUser);
|
||||
|
||||
try {
|
||||
credentials_identity cred_loaded(m_module);
|
||||
cred_loaded.retrieve(pszTargetName, cfg.m_level);
|
||||
@@ -603,7 +599,6 @@ LPCTSTR eap::credentials_pass::target_suffix() const
|
||||
|
||||
eap::credentials::source_t eap::credentials_pass::combine(
|
||||
_In_ DWORD dwFlags,
|
||||
_In_opt_ HANDLE hTokenImpersonateUser,
|
||||
_In_opt_ const credentials *cred_cached,
|
||||
_In_ const config_method &cfg,
|
||||
_In_opt_z_ LPCTSTR pszTargetName)
|
||||
@@ -626,9 +621,6 @@ eap::credentials::source_t eap::credentials_pass::combine(
|
||||
}
|
||||
|
||||
if (pszTargetName) {
|
||||
// Switch user context.
|
||||
user_impersonator impersonating(hTokenImpersonateUser);
|
||||
|
||||
try {
|
||||
credentials_pass cred_loaded(m_module);
|
||||
cred_loaded.retrieve(pszTargetName, cfg.m_level);
|
||||
|
@@ -367,9 +367,12 @@ void eap::peer::get_identity(
|
||||
config_connection cfg(*this);
|
||||
unpack(cfg, pConnectionData, dwConnectionDataSize);
|
||||
|
||||
// Switch user context.
|
||||
user_impersonator impersonating(hTokenImpersonateUser);
|
||||
|
||||
// Combine credentials.
|
||||
credentials_connection cred_out(*this, cfg);
|
||||
auto cfg_method = combine_credentials(dwFlags, cfg, pUserData, dwUserDataSize, cred_out, hTokenImpersonateUser);
|
||||
auto cfg_method = combine_credentials(dwFlags, cfg, pUserData, dwUserDataSize, cred_out);
|
||||
|
||||
if (cfg_method) {
|
||||
// No UI will be necessary.
|
||||
|
Reference in New Issue
Block a user