From 4ef64eb4d5f03fc8c781cae49fed603de1e946d4 Mon Sep 17 00:00:00 2001 From: Alexey Sokolov Date: Thu, 13 Feb 2025 21:36:07 +0000 Subject: [PATCH] rename next sasl module hook --- include/znc/Modules.h | 34 +++++++++++++++++++--------------- modules/modpython/functions.in | 2 +- modules/modpython/module.h | 7 +++---- modules/modpython/znc.py | 2 +- src/Client.cpp | 5 +++-- src/Modules.cpp | 8 ++++---- 6 files changed, 31 insertions(+), 27 deletions(-) diff --git a/include/znc/Modules.h b/include/znc/Modules.h index d773cda9..d5bb9e67 100644 --- a/include/znc/Modules.h +++ b/include/znc/Modules.h @@ -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, 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); diff --git a/modules/modpython/functions.in b/modules/modpython/functions.in index 8615f4bf..1001f708 100644 --- a/modules/modpython/functions.in +++ b/modules/modpython/functions.in @@ -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) diff --git a/modules/modpython/module.h b/modules/modpython/module.h index 54244b53..64d5d728 100644 --- a/modules/modpython/module.h +++ b/modules/modpython/module.h @@ -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, diff --git a/modules/modpython/znc.py b/modules/modpython/znc.py index ca8f3617..ae7b0a43 100644 --- a/modules/modpython/znc.py +++ b/modules/modpython/znc.py @@ -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): diff --git a/src/Client.cpp b/src/Client.cpp index f2c1fd5e..02644f3e 100644 --- a/src/Client.cpp +++ b/src/Client.cpp @@ -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 { diff --git a/src/Modules.cpp b/src/Modules.cpp index 8a9b0f2f..294a8983 100644 --- a/src/Modules.cpp +++ b/src/Modules.cpp @@ -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) {