From 0fc89abe46fc3f98603340bc914f4ab4376c6708 Mon Sep 17 00:00:00 2001 From: brain Date: Fri, 21 Mar 2008 19:30:50 +0000 Subject: Not finished yet. currently, this passes AUTHENTICATE messages to and from services and a client using ENCAP, and makes itself available via CAP git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@9147 e03df62e-2008-0410-955e-edbf42e46eb7 --- src/modules/m_sasl.cpp | 89 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 89 insertions(+) create mode 100644 src/modules/m_sasl.cpp (limited to 'src') diff --git a/src/modules/m_sasl.cpp b/src/modules/m_sasl.cpp new file mode 100644 index 000000000..fc4a75fe3 --- /dev/null +++ b/src/modules/m_sasl.cpp @@ -0,0 +1,89 @@ +/* +------------------------------------+ + * | Inspire Internet Relay Chat Daemon | + * +------------------------------------+ + * + * InspIRCd: (C) 2002-2008 InspIRCd Development Team + * See: http://www.inspircd.org/wiki/index.php/Credits + * + * This program is free but copyrighted software; see + * the file COPYING for details. + * + * --------------------------------------------------- + */ + +#include "inspircd.h" +#include "m_cap.h" + +/* $ModDesc: Provides support for atheme SASL via AUTHENTICATE. */ + +class CommandAuthenticate : public Command +{ + public: + CommandAuthenticate (InspIRCd* Instance) : Command(Instance,"AUTHENTICATE", 0, 1) + { + this->source = "m_sasl.so"; + } + + CmdResult Handle (const char* const* parameters, int pcnt, User *user) + { + if (user->registered != REG_ALL) + { + /* Only allow AUTHENTICATE on unregistered clients */ + std::deque params; + params.push_back("*"); + for (int i = 0; i < pcnt; ++i) + params.push_back(parameters[0]); + } + return CMD_FAILURE; + } +}; + + +class ModuleSASL : public Module +{ + CommandAuthenticate* sasl; + + public: + + ModuleSASL(InspIRCd* Me) + : Module(Me) + { + Implementation eventlist[] = { I_OnEvent }; + ServerInstance->Modules->Attach(eventlist, this, 1); + + sasl = new CommandAuthenticate(ServerInstance); + } + + + virtual ~ModuleSASL() + { + } + + virtual Version GetVersion() + { + return Version(1,2,0,1,VF_VENDOR,API_VERSION); + } + + virtual void OnEvent(Event *ev) + { + GenericCapHandler(ev, "sasl", "sasl"); + + if (ev->GetEventID() == "encap_received") + { + /* Received encap reply, look for AUTHENTICATE */ + std::deque* parameters = (std::deque*)ev->GetData(); + + User* target = ServerInstance->FindNick((*parameters)[0]); + + if (target) + { + /* Found a user */ + parameters->pop_front(); + std::string line = irc::stringjoiner(" ", *parameters, 0, parameters->size() - 1).GetJoined(); + target->WriteServ("AUTHENTICATE %s", line.c_str()); + } + } + } +}; + +MODULE_INIT(ModuleSASL) -- cgit v1.2.3