1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd: (C) 2002-2008 InspIRCd Development Team
6 * See: http://www.inspircd.org/wiki/index.php/Credits
8 * This program is free but copyrighted software; see
9 * the file COPYING for details.
11 * ---------------------------------------------------
17 /* $ModDesc: Provides support for atheme SASL via AUTHENTICATE. */
19 class CommandAuthenticate : public Command
22 CommandAuthenticate (InspIRCd* Instance) : Command(Instance,"AUTHENTICATE", 0, 1)
24 this->source = "m_sasl.so";
27 CmdResult Handle (const char* const* parameters, int pcnt, User *user)
29 if (user->registered != REG_ALL)
31 /* Only allow AUTHENTICATE on unregistered clients */
32 std::deque<std::string> params;
33 params.push_back("*");
34 for (int i = 0; i < pcnt; ++i)
35 params.push_back(parameters[0]);
42 class ModuleSASL : public Module
44 CommandAuthenticate* sasl;
48 ModuleSASL(InspIRCd* Me)
51 Implementation eventlist[] = { I_OnEvent };
52 ServerInstance->Modules->Attach(eventlist, this, 1);
54 sasl = new CommandAuthenticate(ServerInstance);
62 virtual Version GetVersion()
64 return Version(1,2,0,1,VF_VENDOR,API_VERSION);
67 virtual void OnEvent(Event *ev)
69 GenericCapHandler(ev, "sasl", "sasl");
71 if (ev->GetEventID() == "encap_received")
73 /* Received encap reply, look for AUTHENTICATE */
74 std::deque<std::string>* parameters = (std::deque<std::string>*)ev->GetData();
76 User* target = ServerInstance->FindNick((*parameters)[0]);
81 parameters->pop_front();
82 std::string line = irc::stringjoiner(" ", *parameters, 0, parameters->size() - 1).GetJoined();
83 target->WriteServ("AUTHENTICATE %s", line.c_str());
89 MODULE_INIT(ModuleSASL)