Credentials are no longer stored using method name (TLS/PAP/MSCHAPv2) but with level/type identifier
This commit is contained in:
@@ -80,14 +80,12 @@
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" />
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\include\Config.h" />
|
||||
<ClInclude Include="..\include\Credentials.h" />
|
||||
<ClInclude Include="..\include\Method.h" />
|
||||
<ClInclude Include="..\include\MSCHAPv2.h" />
|
||||
<ClInclude Include="..\src\StdAfx.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\src\Config.cpp" />
|
||||
<ClCompile Include="..\src\Credentials.cpp" />
|
||||
<ClCompile Include="..\src\Method.cpp" />
|
||||
<ClCompile Include="..\src\MSCHAPv2.cpp" />
|
||||
<ClCompile Include="..\src\StdAfx.cpp">
|
||||
|
@@ -17,9 +17,6 @@
|
||||
<ClInclude Include="..\include\Config.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\include\Credentials.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\include\Method.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
@@ -34,9 +31,6 @@
|
||||
<ClCompile Include="..\src\Config.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\src\Credentials.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\src\Method.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
|
@@ -30,7 +30,6 @@ namespace eap
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Credentials.h"
|
||||
#include "../../EAPBase/include/Config.h"
|
||||
|
||||
#include <Windows.h>
|
||||
@@ -46,9 +45,10 @@ namespace eap
|
||||
///
|
||||
/// Constructs configuration
|
||||
///
|
||||
/// \param[in] mod EAP module to use for global services
|
||||
/// \param[in] mod EAP module to use for global services
|
||||
/// \param[in] level Config level (0=outer, 1=inner, 2=inner-inner...)
|
||||
///
|
||||
config_method_mschapv2(_In_ module &mod);
|
||||
config_method_mschapv2(_In_ module &mod, _In_ unsigned int level);
|
||||
|
||||
///
|
||||
/// Copies configuration
|
||||
|
@@ -1,122 +0,0 @@
|
||||
/*
|
||||
Copyright 2015-2016 Amebis
|
||||
Copyright 2016 GÉANT
|
||||
|
||||
This file is part of GÉANTLink.
|
||||
|
||||
GÉANTLink is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
GÉANTLink is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GÉANTLink. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
namespace eap
|
||||
{
|
||||
///
|
||||
/// MSCHAPv2 credentials
|
||||
///
|
||||
class credentials_mschapv2;
|
||||
}
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Config.h"
|
||||
|
||||
#include "../../EAPBase/include/Credentials.h"
|
||||
|
||||
#include <Windows.h>
|
||||
#include <sal.h>
|
||||
#include <tchar.h>
|
||||
|
||||
|
||||
namespace eap
|
||||
{
|
||||
class credentials_mschapv2 : public credentials_pass
|
||||
{
|
||||
public:
|
||||
///
|
||||
/// Constructs credentials
|
||||
///
|
||||
/// \param[in] mod EAP module to use for global services
|
||||
///
|
||||
credentials_mschapv2(_In_ module &mod);
|
||||
|
||||
///
|
||||
/// Copies credentials
|
||||
///
|
||||
/// \param[in] other Credentials to copy from
|
||||
///
|
||||
credentials_mschapv2(_In_ const credentials_mschapv2 &other);
|
||||
|
||||
///
|
||||
/// Moves credentials
|
||||
///
|
||||
/// \param[in] other Credentials to move from
|
||||
///
|
||||
credentials_mschapv2(_Inout_ credentials_mschapv2 &&other);
|
||||
|
||||
///
|
||||
/// Copies credentials
|
||||
///
|
||||
/// \param[in] other Credentials to copy from
|
||||
///
|
||||
/// \returns Reference to this object
|
||||
///
|
||||
credentials_mschapv2& operator=(_In_ const credentials_mschapv2 &other);
|
||||
|
||||
///
|
||||
/// Moves credentials
|
||||
///
|
||||
/// \param[in] other Credentials to move from
|
||||
///
|
||||
/// \returns Reference to this object
|
||||
///
|
||||
credentials_mschapv2& operator=(_Inout_ credentials_mschapv2 &&other);
|
||||
|
||||
///
|
||||
/// Clones credentials
|
||||
///
|
||||
/// \returns Pointer to cloned credentials
|
||||
///
|
||||
virtual config* clone() const;
|
||||
|
||||
/// \name Storage
|
||||
/// @{
|
||||
|
||||
///
|
||||
/// Return target suffix for Windows Credential Manager credential name
|
||||
///
|
||||
virtual LPCTSTR target_suffix() const;
|
||||
|
||||
/// @}
|
||||
|
||||
///
|
||||
/// Combine credentials in the following order:
|
||||
///
|
||||
/// 1. Cached credentials
|
||||
/// 2. Pre-configured credentials
|
||||
/// 3. Stored credentials
|
||||
///
|
||||
/// \param[in] cred_cached Cached credentials (optional, can be \c NULL, must be credentials_mschapv2* type)
|
||||
/// \param[in] cfg Method configuration (must be config_method_mschapv2 type)
|
||||
/// \param[in] pszTargetName The name in Windows Credential Manager to retrieve credentials from (optional, can be \c NULL)
|
||||
///
|
||||
/// \returns
|
||||
/// - \c source_cache Credentials were obtained from EapHost cache
|
||||
/// - \c source_preshared Credentials were set by method configuration
|
||||
/// - \c source_storage Credentials were loaded from Windows Credential Manager
|
||||
///
|
||||
virtual source_t combine(
|
||||
_In_ const credentials *cred_cached,
|
||||
_In_ const config_method_with_cred &cfg,
|
||||
_In_opt_z_ LPCTSTR pszTargetName);
|
||||
};
|
||||
}
|
@@ -29,7 +29,6 @@ namespace eap
|
||||
#pragma once
|
||||
|
||||
#include "Config.h"
|
||||
#include "Credentials.h"
|
||||
#include "MSCHAPv2.h"
|
||||
|
||||
#include "../../EAPBase/include/Method.h"
|
||||
@@ -49,7 +48,7 @@ namespace eap
|
||||
/// \param[in] cfg Method configuration
|
||||
/// \param[in] cred User credentials
|
||||
///
|
||||
method_mschapv2(_In_ module &module, _In_ config_method_mschapv2 &cfg, _In_ credentials_mschapv2 &cred);
|
||||
method_mschapv2(_In_ module &module, _In_ config_method_mschapv2 &cfg, _In_ credentials_pass &cred);
|
||||
|
||||
///
|
||||
/// Moves an EAP method
|
||||
@@ -133,7 +132,7 @@ namespace eap
|
||||
static std::list<std::string> parse_response(_In_count_(count) const char *resp, _In_ size_t count);
|
||||
|
||||
protected:
|
||||
credentials_mschapv2 &m_cred; ///< EAP-TLS user credentials
|
||||
credentials_pass &m_cred; ///< EAP-TLS user credentials
|
||||
winstd::crypt_prov m_cp; ///< Cryptography provider for general services
|
||||
|
||||
challenge_mschapv2 m_challenge_server; ///< MSCHAP server challenge
|
||||
|
@@ -28,9 +28,9 @@ using namespace winstd;
|
||||
// eap::config_method_mschapv2
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
eap::config_method_mschapv2::config_method_mschapv2(_In_ module &mod) : config_method_with_cred(mod)
|
||||
eap::config_method_mschapv2::config_method_mschapv2(_In_ module &mod, _In_ unsigned int level) : config_method_with_cred(mod, level)
|
||||
{
|
||||
m_preshared.reset(new credentials_mschapv2(mod));
|
||||
m_preshared.reset(new credentials_pass(mod));
|
||||
}
|
||||
|
||||
|
||||
@@ -84,5 +84,5 @@ const wchar_t* eap::config_method_mschapv2::get_method_str() const
|
||||
|
||||
eap::credentials* eap::config_method_mschapv2::make_credentials() const
|
||||
{
|
||||
return new credentials_mschapv2(m_module);
|
||||
return new credentials_pass(m_module);
|
||||
}
|
||||
|
@@ -1,112 +0,0 @@
|
||||
/*
|
||||
Copyright 2015-2016 Amebis
|
||||
Copyright 2016 GÉANT
|
||||
|
||||
This file is part of GÉANTLink.
|
||||
|
||||
GÉANTLink is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
GÉANTLink is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GÉANTLink. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace winstd;
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// eap::credentials_mschapv2
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
eap::credentials_mschapv2::credentials_mschapv2(_In_ module &mod) : credentials_pass(mod)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
eap::credentials_mschapv2::credentials_mschapv2(_In_ const credentials_mschapv2 &other) :
|
||||
credentials_pass(other)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
eap::credentials_mschapv2::credentials_mschapv2(_Inout_ credentials_mschapv2 &&other) :
|
||||
credentials_pass(std::move(other))
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
eap::credentials_mschapv2& eap::credentials_mschapv2::operator=(_In_ const credentials_mschapv2 &other)
|
||||
{
|
||||
if (this != &other)
|
||||
(credentials_pass&)*this = other;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
eap::credentials_mschapv2& eap::credentials_mschapv2::operator=(_Inout_ credentials_mschapv2 &&other)
|
||||
{
|
||||
if (this != &other)
|
||||
(credentials_pass&&)*this = std::move(other);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
eap::config* eap::credentials_mschapv2::clone() const
|
||||
{
|
||||
return new credentials_mschapv2(*this);
|
||||
}
|
||||
|
||||
|
||||
LPCTSTR eap::credentials_mschapv2::target_suffix() const
|
||||
{
|
||||
return _T("MSCHAPv2");
|
||||
}
|
||||
|
||||
|
||||
eap::credentials::source_t eap::credentials_mschapv2::combine(
|
||||
_In_ const credentials *cred_cached,
|
||||
_In_ const config_method_with_cred &cfg,
|
||||
_In_opt_z_ LPCTSTR pszTargetName)
|
||||
{
|
||||
if (cred_cached) {
|
||||
// Using EAP service cached credentials.
|
||||
*this = *(credentials_mschapv2*)cred_cached;
|
||||
m_module.log_event(&EAPMETHOD_TRACE_EVT_CRED_CACHED1, event_data((unsigned int)eap_type_legacy_mschapv2), event_data(credentials_mschapv2::get_name()), event_data::blank);
|
||||
return source_cache;
|
||||
}
|
||||
|
||||
if (cfg.m_use_preshared) {
|
||||
// Using preshared credentials.
|
||||
*this = *(credentials_mschapv2*)cfg.m_preshared.get();
|
||||
m_module.log_event(&EAPMETHOD_TRACE_EVT_CRED_PRESHARED1, event_data((unsigned int)eap_type_legacy_mschapv2), event_data(credentials_mschapv2::get_name()), event_data::blank);
|
||||
return source_preshared;
|
||||
}
|
||||
|
||||
if (pszTargetName) {
|
||||
try {
|
||||
credentials_mschapv2 cred_loaded(m_module);
|
||||
cred_loaded.retrieve(pszTargetName);
|
||||
|
||||
// Using stored credentials.
|
||||
*this = std::move(cred_loaded);
|
||||
m_module.log_event(&EAPMETHOD_TRACE_EVT_CRED_STORED1, event_data((unsigned int)eap_type_legacy_mschapv2), event_data(credentials_mschapv2::get_name()), event_data::blank);
|
||||
return source_storage;
|
||||
} catch (...) {
|
||||
// Not actually an error.
|
||||
}
|
||||
}
|
||||
|
||||
return source_unknown;
|
||||
}
|
@@ -28,7 +28,7 @@ using namespace winstd;
|
||||
// eap::method_mschapv2
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
eap::method_mschapv2::method_mschapv2(_In_ module &module, _In_ config_method_mschapv2 &cfg, _In_ credentials_mschapv2 &cred) :
|
||||
eap::method_mschapv2::method_mschapv2(_In_ module &module, _In_ config_method_mschapv2 &cfg, _In_ credentials_pass &cred) :
|
||||
m_cred(cred),
|
||||
m_ident(0),
|
||||
m_success(false),
|
||||
|
@@ -21,7 +21,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "../include/Config.h"
|
||||
#include "../include/Credentials.h"
|
||||
#include "../include/Method.h"
|
||||
#include "../include/MSCHAPv2.h"
|
||||
|
||||
|
Reference in New Issue
Block a user