More gsasl changes.
This commit is contained in:
@@ -678,7 +678,7 @@ ClientStateStartSession::Enter(boost::shared_ptr<ClientThread> client)
|
|||||||
AuthenticatedLogin_t *authLogin = &netInit->login.choice.authenticatedLogin;
|
AuthenticatedLogin_t *authLogin = &netInit->login.choice.authenticatedLogin;
|
||||||
// TODO
|
// TODO
|
||||||
boost::shared_ptr<SessionData> tmpSession = context.GetSessionData();
|
boost::shared_ptr<SessionData> tmpSession = context.GetSessionData();
|
||||||
tmpSession->CreateAuthSession(client->GetAuthContext(), false, context.GetPlayerName(), context.GetPassword());
|
tmpSession->CreateClientAuthSession(client->GetAuthContext(), context.GetPlayerName(), context.GetPassword());
|
||||||
string outUserData;
|
string outUserData;
|
||||||
tmpSession->AuthStep(1, "", outUserData);
|
tmpSession->AuthStep(1, "", outUserData);
|
||||||
OCTET_STRING_fromBuf(&authLogin->clientUserData,
|
OCTET_STRING_fromBuf(&authLogin->clientUserData,
|
||||||
|
|||||||
@@ -905,7 +905,6 @@ ServerLobbyThread::HandleNetPacketInit(SessionWrapper session, const InitMessage
|
|||||||
}
|
}
|
||||||
|
|
||||||
string playerName;
|
string playerName;
|
||||||
string authData;
|
|
||||||
MD5Buf avatarMD5;
|
MD5Buf avatarMD5;
|
||||||
bool guestUser = false;
|
bool guestUser = false;
|
||||||
if (initMessage.login.present == login_PR_anonymousLogin)
|
if (initMessage.login.present == login_PR_anonymousLogin)
|
||||||
@@ -915,12 +914,15 @@ ServerLobbyThread::HandleNetPacketInit(SessionWrapper session, const InitMessage
|
|||||||
}
|
}
|
||||||
else if (initMessage.login.present == login_PR_authenticatedLogin)
|
else if (initMessage.login.present == login_PR_authenticatedLogin)
|
||||||
{
|
{
|
||||||
|
string inAuthData;
|
||||||
|
string outRequestData;
|
||||||
const AuthenticatedLogin_t *authLogin = &initMessage.login.choice.authenticatedLogin;
|
const AuthenticatedLogin_t *authLogin = &initMessage.login.choice.authenticatedLogin;
|
||||||
authData = string((const char *)authLogin->clientUserData.buf, authLogin->clientUserData.size);
|
inAuthData = string((const char *)authLogin->clientUserData.buf, authLogin->clientUserData.size);
|
||||||
if (authLogin->avatar)
|
if (authLogin->avatar)
|
||||||
memcpy(avatarMD5.data, authLogin->avatar->buf, MD5_DATA_SIZE);
|
memcpy(avatarMD5.data, authLogin->avatar->buf, MD5_DATA_SIZE);
|
||||||
// TODO
|
session.sessionData->CreateServerAuthSession(m_authContext);
|
||||||
playerName = "testuser";
|
session.sessionData->AuthStep(1, inAuthData, outRequestData);
|
||||||
|
playerName = session.sessionData->AuthGetUser();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
SessionError(session, ERR_NET_INVALID_PASSWORD);
|
SessionError(session, ERR_NET_INVALID_PASSWORD);
|
||||||
|
|||||||
@@ -76,16 +76,23 @@ SessionData::GetAsioSocket()
|
|||||||
return m_socket;
|
return m_socket;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool CreateServerAuthSession(Gsasl *context)
|
||||||
SessionData::CreateAuthSession(Gsasl *context, bool server, const string &userName, const string &password)
|
|
||||||
{
|
{
|
||||||
bool retVal = false;
|
bool retVal = false;
|
||||||
boost::mutex::scoped_lock lock(m_dataMutex);
|
boost::mutex::scoped_lock lock(m_dataMutex);
|
||||||
InternalClearAuthSession();
|
InternalClearAuthSession();
|
||||||
int errorCode;
|
int errorCode;
|
||||||
if (server)
|
|
||||||
errorCode = gsasl_server_start(context, "SCRAM-SHA-1", &m_authSession);
|
errorCode = gsasl_server_start(context, "SCRAM-SHA-1", &m_authSession);
|
||||||
else
|
return errorCode == GSASL_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
SessionData::CreateClientAuthSession(Gsasl *context, const string &userName, const string &password)
|
||||||
|
{
|
||||||
|
bool retVal = false;
|
||||||
|
boost::mutex::scoped_lock lock(m_dataMutex);
|
||||||
|
InternalClearAuthSession();
|
||||||
|
int errorCode;
|
||||||
errorCode = gsasl_client_start(context, "SCRAM-SHA-1", &m_authSession);
|
errorCode = gsasl_client_start(context, "SCRAM-SHA-1", &m_authSession);
|
||||||
if (errorCode == GSASL_OK)
|
if (errorCode == GSASL_OK)
|
||||||
{
|
{
|
||||||
@@ -123,6 +130,16 @@ SessionData::AuthStep(int stepNum, const std::string &inData, std::string &outDa
|
|||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
string
|
||||||
|
SessionData::AuthGetUser()
|
||||||
|
{
|
||||||
|
string retStr;
|
||||||
|
if (m_authSession)
|
||||||
|
{
|
||||||
|
retStr = gsasl_property_fast(m_authSession, GSASL_AUTHID);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
SessionData::InternalClearAuthSession()
|
SessionData::InternalClearAuthSession()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -57,8 +57,10 @@ public:
|
|||||||
|
|
||||||
boost::shared_ptr<boost::asio::ip::tcp::socket> GetAsioSocket();
|
boost::shared_ptr<boost::asio::ip::tcp::socket> GetAsioSocket();
|
||||||
|
|
||||||
bool CreateAuthSession(Gsasl *context, bool server, const std::string &userName, const std::string &password);
|
bool CreateServerAuthSession(Gsasl *context);
|
||||||
|
bool CreateClientAuthSession(Gsasl *context, const std::string &userName, const std::string &password);
|
||||||
bool AuthStep(int stepNum, const std::string &inData, std::string &outData);
|
bool AuthStep(int stepNum, const std::string &inData, std::string &outData);
|
||||||
|
string AuthGetUser();
|
||||||
|
|
||||||
void SetReadyFlag();
|
void SetReadyFlag();
|
||||||
void ResetReadyFlag();
|
void ResetReadyFlag();
|
||||||
|
|||||||
Reference in New Issue
Block a user