rename next sasl module hook

This commit is contained in:
Alexey Sokolov
2025-02-13 21:36:07 +00:00
parent c8266aafda
commit 4ef64eb4d5
6 changed files with 31 additions and 27 deletions
+19 -15
View File
@@ -1363,9 +1363,9 @@ class CModule {
*/
virtual void OnClientCapRequest(CClient* pClient, const CString& sCap,
bool bState);
/** Called when a client requests SASL authentication. Use ssMechanisms.insert("mechanism")
/** Called when a client requests SASL authentication. Use ssMechanisms.insert("MECHANISM")
* for announcing SASL mechanisms which your module supports.
* @param ssMechanisms The set of supported SASL mechanisms to append to.
* @param ssMechanisms The set of supported SASL mechanisms to append to.
*/
virtual void OnClientGetSASLMechanisms(SCString& ssMechanisms);
/** Called when a client has selected a SASL mechanism for SASL authentication.
@@ -1374,18 +1374,23 @@ class CModule {
* @param sMechanism The SASL mechanism selected by the client.
* @param sResponse The optional value of an initial SASL challenge message to send to the client.
*/
virtual EModRet OnSASLServerChallenge(const CString& sMechanism,
CString& sResponse);
virtual EModRet OnClientSASLServerInitialChallenge(
const CString& sMechanism, CString& sResponse);
/** Called when a client is sending us a SASL message after the mechanism was selected.
* If implementing a SASL authentication mechanism, check the passed credentials,
* then either request more data by sending a challenge in sMechanismResponse,
* reject authentication by setting bAuthenticationSuccess to false,
* or accept authentication by setting bAuthenticationSuccess to true and setting sUser to the authenticated user name.
* If implementing a SASL authentication mechanism, check the passed
* credentials, then either request more data by sending a challenge in
* sMechanismResponse, reject authentication by setting
* bAuthenticationSuccess to false, or accept authentication by setting
* bAuthenticationSuccess to true and setting sUser to the authenticated
* user name.
* @param sMechanism The SASL mechanism selected by the client.
* @param sBuffer The SASL opaque value/credentials sent by the client.
* @param sUser The optional name of the authenticated user to log in the user as, if authentication is accepted.
* @param sMechanismResponse The optional value of a SASL challenge message to reply to the client to ask for more data.
* @param bAuthenticationSuccess If sMechanismResponse is not set, whether to accept or reject the authentication request.
* @param sUser The optional name of the authenticated user to log in the
* user as, if authentication is accepted.
* @param sMechanismResponse The optional value of a SASL challenge message
* to reply to the client to ask for more data.
* @param bAuthenticationSuccess If sMechanismResponse is not set, whether
* to accept or reject the authentication request.
*/
virtual EModRet OnClientSASLAuthenticate(const CString& sMechanism,
const CString& sBuffer,
@@ -1695,11 +1700,10 @@ class CModules : public std::vector<CModule*>, private CCoreTranslationMixin {
bool bState);
bool OnClientCapRequest(CClient* pClient, const CString& sCap, bool bState);
bool OnClientGetSASLMechanisms(SCString& ssMechanisms);
bool OnSASLServerChallenge(const CString& sMechanism,
CString& sResponse);
bool OnClientSASLServerInitialChallenge(const CString& sMechanism,
CString& sResponse);
bool OnClientSASLAuthenticate(const CString& sMechanism,
const CString& sBuffer,
CString& sUser,
const CString& sBuffer, CString& sUser,
CString& sResponse,
bool& bAuthenticationSuccess);
+1 -1
View File
@@ -113,7 +113,7 @@ EModRet OnUnknownUserRawMessage(CMessage& Message)
bool IsClientCapSupported(CClient* pClient, const CString& sCap, bool bState)
void OnClientCapRequest(CClient* pClient, const CString& sCap, bool bState)
void OnClientGetSASLMechanisms(SCString& ssMechanisms)
EModRet OnSASLServerChallenge(const CString& sMechanism, CString& sResponse)
EModRet OnClientSASLServerInitialChallenge(const CString& sMechanism, CString& sResponse)
EModRet OnClientSASLAuthenticate(const CString& sMechanism, const CString& sBuffer, CString& sUser, CString& sMechanismResponse, bool& bAuthenticationSuccess)
EModRet OnModuleLoading(const CString& sModName, const CString& sArgs, CModInfo::EModuleType eType, bool& bSuccess, CString& sRetMsg)
EModRet OnModuleUnloading(CModule* pModule, bool& bSuccess, CString& sRetMsg)
+3 -4
View File
@@ -195,11 +195,10 @@ class ZNC_EXPORT_LIB_EXPORT CPyModule : public CModule {
void OnClientCapRequest(CClient* pClient, const CString& sCap,
bool bState) override;
void OnClientGetSASLMechanisms(SCString& ssMechanisms) override;
EModRet OnSASLServerChallenge(const CString& sMechanism,
CString& sResponse) override;
EModRet OnClientSASLServerInitialChallenge(const CString& sMechanism,
CString& sResponse) override;
EModRet OnClientSASLAuthenticate(const CString& sMechanism,
const CString& sBuffer,
CString& sUser,
const CString& sBuffer, CString& sUser,
CString& sMechanismResponse,
bool& bAuthenticationSuccess) override;
virtual EModRet OnModuleLoading(const CString& sModName,
+1 -1
View File
@@ -481,7 +481,7 @@ class Module:
def OnClientGetSASLMechanisms(self, ssMechanisms):
pass
def OnSASLServerChallenge(self, sMechanism, sResponse):
def OnClientSASLServerInitialChallenge(self, sMechanism, sResponse):
pass
def OnClientSASLAuthenticate(self, sMechanism, sBuffer, sUser, sResponse, bAuthenticationSuccess):
+3 -2
View File
@@ -1146,8 +1146,9 @@ void CClient::OnAuthenticateMessage(CAuthenticateMessage& Message) {
auto bResult = false;
CString sChallenge;
GLOBALMODULECALL(OnSASLServerChallenge(m_sSASLMechanism, sChallenge),
&bResult);
GLOBALMODULECALL(
OnClientSASLServerInitialChallenge(m_sSASLMechanism, sChallenge),
&bResult);
if (bResult) {
SASLChallenge(sChallenge);
} else {
+4 -4
View File
@@ -1208,8 +1208,8 @@ CModule::EModRet CModule::OnClientSASLAuthenticate(
return CONTINUE;
}
CModule::EModRet CModule::OnSASLServerChallenge(const CString& sMechanism,
CString& sResponse) {
CModule::EModRet CModule::OnClientSASLServerInitialChallenge(
const CString& sMechanism, CString& sResponse) {
return CONTINUE;
}
@@ -1769,9 +1769,9 @@ bool CModules::OnClientSASLAuthenticate(const CString& sMechanism,
sResponse, bAuthenticationSuccess));
}
bool CModules::OnSASLServerChallenge(const CString& sMechanism,
bool CModules::OnClientSASLServerInitialChallenge(const CString& sMechanism,
CString& sResponse) {
MODHALTCHK(OnSASLServerChallenge(sMechanism, sResponse));
MODHALTCHK(OnClientSASLServerInitialChallenge(sMechanism, sResponse));
}
bool CModules::OnClientGetSASLMechanisms(SCString& ssMechanisms) {