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 * ---------------------------------------------------
18 /* $ModDesc: Provides support for atheme SASL via AUTHENTICATE. */
20 class CommandAuthenticate : public Command
23 CommandAuthenticate (InspIRCd* Instance) : Command(Instance,"AUTHENTICATE", 0, 1)
25 this->source = "m_sasl.so";
28 CmdResult Handle (const char* const* parameters, int pcnt, User *user)
30 if (user->registered != REG_ALL)
32 /* Only allow AUTHENTICATE on unregistered clients */
33 std::deque<std::string> params;
34 params.push_back("*");
35 for (int i = 0; i < pcnt; ++i)
36 params.push_back(parameters[0]);
43 class ModuleSASL : public Module
45 CommandAuthenticate* sasl;
49 ModuleSASL(InspIRCd* Me)
52 Implementation eventlist[] = { I_OnEvent };
53 ServerInstance->Modules->Attach(eventlist, this, 1);
55 sasl = new CommandAuthenticate(ServerInstance);
63 virtual Version GetVersion()
65 return Version(1,2,0,1,VF_VENDOR,API_VERSION);
68 virtual void OnEvent(Event *ev)
70 GenericCapHandler(ev, "sasl", "sasl");
72 if (ev->GetEventID() == "encap_received")
74 /* Received encap reply, look for AUTHENTICATE */
75 std::deque<std::string>* parameters = (std::deque<std::string>*)ev->GetData();
77 User* target = ServerInstance->FindNick((*parameters)[0]);
82 parameters->pop_front();
83 std::string line = irc::stringjoiner(" ", *parameters, 0, parameters->size() - 1).GetJoined();
84 target->WriteServ("AUTHENTICATE %s", line.c_str());
87 else if (ev->GetEventID() == "account_login")
89 AccountData* ac = (AccountData*)ev->GetData();
90 ac->user->WriteServ("903 %s :SASL authentication successful", ac->user->nick);
95 MODULE_INIT(ModuleSASL)