mirror of
https://github.com/znc/znc.git
synced 2026-03-28 17:42:41 +01:00
SASL Authentication for Clients
This commit is contained in:
@@ -116,6 +116,10 @@ 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_bPlaybackActive(false),
|
||||
m_pUser(nullptr),
|
||||
m_pNetwork(nullptr),
|
||||
@@ -124,6 +128,8 @@ class CClient : public CIRCSocket {
|
||||
m_sUser(""),
|
||||
m_sNetwork(""),
|
||||
m_sIdentifier(""),
|
||||
m_sSaslBuffer(""),
|
||||
m_sSaslMechanism(""),
|
||||
m_spAuth(),
|
||||
m_ssAcceptedCaps(),
|
||||
m_ssSupportedTags(),
|
||||
@@ -156,6 +162,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; }}},
|
||||
}) {
|
||||
EnableReadLine();
|
||||
// RFC says a line can have 512 chars max, but we are
|
||||
@@ -333,6 +340,10 @@ class CClient : public CIRCSocket {
|
||||
unsigned int DetachChans(const std::set<CChan*>& sChans);
|
||||
|
||||
bool OnActionMessage(CActionMessage& Message);
|
||||
void OnAuthenticateMessage(CAuthenticateMessage& Message);
|
||||
|
||||
CString EnumerateSaslMechanisms(SCString& ssMechanisms);
|
||||
|
||||
bool OnCTCPMessage(CCTCPMessage& Message);
|
||||
bool OnJoinMessage(CJoinMessage& Message);
|
||||
bool OnModeMessage(CModeMessage& Message);
|
||||
@@ -362,6 +373,10 @@ 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_bPlaybackActive;
|
||||
CUser* m_pUser;
|
||||
CIRCNetwork* m_pNetwork;
|
||||
@@ -370,6 +385,8 @@ class CClient : public CIRCSocket {
|
||||
CString m_sUser;
|
||||
CString m_sNetwork;
|
||||
CString m_sIdentifier;
|
||||
CString m_sSaslBuffer;
|
||||
CString m_sSaslMechanism;
|
||||
std::shared_ptr<CAuthBase> m_spAuth;
|
||||
SCString m_ssAcceptedCaps;
|
||||
SCString m_ssSupportedTags;
|
||||
|
||||
@@ -78,6 +78,7 @@ class CMessage {
|
||||
Unknown,
|
||||
Account,
|
||||
Action,
|
||||
Authenticate,
|
||||
Away,
|
||||
Capability,
|
||||
CTCP,
|
||||
@@ -250,6 +251,13 @@ class CActionMessage : public CTargetMessage {
|
||||
};
|
||||
REGISTER_ZNC_MESSAGE(CActionMessage);
|
||||
|
||||
class CAuthenticateMessage : public CMessage {
|
||||
public:
|
||||
CString GetText() const { return GetParam(0); }
|
||||
void SetText(const CString& sText) { SetParam(0, sText); }
|
||||
};
|
||||
REGISTER_ZNC_MESSAGE(CAuthenticateMessage);
|
||||
|
||||
class CCTCPMessage : public CTargetMessage {
|
||||
public:
|
||||
bool IsReply() const { return GetCommand().Equals("NOTICE"); }
|
||||
|
||||
@@ -1308,6 +1308,14 @@ class CModule {
|
||||
*/
|
||||
virtual void OnClientCapRequest(CClient* pClient, const CString& sCap,
|
||||
bool bState);
|
||||
virtual EModRet OnSaslServerChallenge(const CString& sMechanism,
|
||||
CString& sResponse);
|
||||
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.
|
||||
@@ -1587,6 +1595,15 @@ 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,
|
||||
CString& sResponse);
|
||||
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,
|
||||
CString& sRetMsg);
|
||||
|
||||
Reference in New Issue
Block a user