Reabse and address PR comments

This commit is contained in:
delthas
2023-08-31 11:24:53 +02:00
parent d27e2cce5c
commit 1dd995ef77
9 changed files with 166 additions and 99 deletions
+17 -14
View File
@@ -116,10 +116,8 @@ class CClient : public CIRCSocket {
m_bBatch(false),
m_bEchoMessage(false),
m_bSelfMessage(false),
m_bSasl(false),
m_bSaslAuthenticating(false),
m_bSaslAuthenticated(false),
m_bSaslMultipart(false),
m_bSASL(false),
m_bSASLAuthenticating(false),
m_bPlaybackActive(false),
m_pUser(nullptr),
m_pNetwork(nullptr),
@@ -128,8 +126,9 @@ class CClient : public CIRCSocket {
m_sUser(""),
m_sNetwork(""),
m_sIdentifier(""),
m_sSaslBuffer(""),
m_sSaslMechanism(""),
m_sSASLBuffer(""),
m_sSASLMechanism(""),
m_sSASLUser(""),
m_spAuth(),
m_ssAcceptedCaps(),
m_ssSupportedTags(),
@@ -162,7 +161,7 @@ class CClient : public CIRCSocket {
}}},
{"extended-join",
{true, [this](bool bVal) { m_bExtendedJoin = bVal; }}},
{"sasl", {false, [this](bool bVal) { m_bSasl = bVal; m_bSaslAuthenticating = bVal; }}},
{"sasl", {false, [this](bool bVal) { m_bSASL = bVal; m_bSASLAuthenticating = bVal; }}},
}) {
EnableReadLine();
// RFC says a line can have 512 chars max, but we are
@@ -342,7 +341,12 @@ class CClient : public CIRCSocket {
bool OnActionMessage(CActionMessage& Message);
void OnAuthenticateMessage(CAuthenticateMessage& Message);
CString EnumerateSaslMechanisms(SCString& ssMechanisms);
/**
* Fills all available SASL mechanisms in the passed set, and returns a comma-joined string of those mechanisms.
* @param ssMechanisms Set of supported mechanisms, filled by this method.
* @return A comma-joined string of supported mechanisms.
*/
CString EnumerateSASLMechanisms(SCString& ssMechanisms);
bool OnCTCPMessage(CCTCPMessage& Message);
bool OnJoinMessage(CJoinMessage& Message);
@@ -373,10 +377,8 @@ class CClient : public CIRCSocket {
bool m_bBatch;
bool m_bEchoMessage;
bool m_bSelfMessage;
bool m_bSasl;
bool m_bSaslAuthenticating;
bool m_bSaslAuthenticated;
bool m_bSaslMultipart;
bool m_bSASL;
bool m_bSASLAuthenticating;
bool m_bPlaybackActive;
CUser* m_pUser;
CIRCNetwork* m_pNetwork;
@@ -385,8 +387,9 @@ class CClient : public CIRCSocket {
CString m_sUser;
CString m_sNetwork;
CString m_sIdentifier;
CString m_sSaslBuffer;
CString m_sSaslMechanism;
CString m_sSASLBuffer;
CString m_sSASLMechanism;
CString m_sSASLUser;
std::shared_ptr<CAuthBase> m_spAuth;
SCString m_ssAcceptedCaps;
SCString m_ssSupportedTags;
+27 -6
View File
@@ -1308,14 +1308,35 @@ class CModule {
*/
virtual void OnClientCapRequest(CClient* pClient, const CString& sCap,
bool bState);
virtual EModRet OnSaslServerChallenge(const CString& sMechanism,
/** 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.
*/
virtual void OnGetSASLMechanisms(SCString& ssMechanisms);
/** Called when a client has selected a SASL mechanism for SASL authentication.
* If implementing a SASL authentication mechanism, set sResponse to specify an initial challenge
* message to send to the client. Otherwise, an empty response will be sent.
* @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 OnClientSaslAuthenticate(const CString& sMechanism,
/** 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.
* @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.
*/
virtual EModRet OnClientSASLAuthenticate(const CString& sMechanism,
const CString& sBuffer,
CString& sUser,
CString& sMechanismResponse,
bool& bAuthenticationSuccess);
virtual void OnGetSaslMechanisms(SCString& ssMechanisms);
/** Called when a module is going to be loaded.
* @param sModName name of the module.
@@ -1595,14 +1616,14 @@ class CModules : public std::vector<CModule*>, private CCoreTranslationMixin {
bool IsClientCapSupported(CClient* pClient, const CString& sCap,
bool bState);
bool OnClientCapRequest(CClient* pClient, const CString& sCap, bool bState);
bool OnSaslServerChallenge(const CString& sMechanism,
bool OnGetSASLMechanisms(SCString& ssMechanisms);
bool OnSASLServerChallenge(const CString& sMechanism,
CString& sResponse);
bool OnClientSaslAuthenticate(const CString& sMechanism,
bool OnClientSASLAuthenticate(const CString& sMechanism,
const CString& sBuffer,
CString& sUser,
CString& sResponse,
bool& bAuthenticationSuccess);
bool OnGetSaslMechanisms(SCString& ssMechanisms);
bool OnModuleLoading(const CString& sModName, const CString& sArgs,
CModInfo::EModuleType eType, bool& bSuccess,