static void SendSASL(LocalUser* user, const std::string& agent, char mode, const std::vector<std::string>& parameters)
{
- CommandBase::Params params(parameters.size() + 3);
+ CommandBase::Params params;
params.push_back(user->uuid);
params.push_back(agent);
params.push_back(ConvToStr(mode));
}
}
+static ClientProtocol::EventProvider* g_protoev;
+
/**
* Tracks SASL authentication state like charybdis does. --nenolod
*/
SaslResult result;
bool state_announced;
- void SendHostIP()
+ void SendHostIP(UserCertificateAPI& sslapi)
{
std::vector<std::string> params;
params.push_back(user->GetRealHost());
params.push_back(user->GetIPString());
- params.push_back(SSLIOHook::IsSSL(&user->eh) ? "S" : "P");
+ params.push_back(sslapi && sslapi->GetCertificate(user) ? "S" : "P");
SendSASL(user, "*", 'H', params);
}
public:
- SaslAuthenticator(LocalUser* user_, const std::string& method)
- : user(user_), state(SASL_INIT), state_announced(false)
+ SaslAuthenticator(LocalUser* user_, const std::string& method, UserCertificateAPI& sslapi)
+ : user(user_)
+ , state(SASL_INIT)
+ , state_announced(false)
{
- SendHostIP();
+ SendHostIP(sslapi);
std::vector<std::string> params;
params.push_back(method);
- const std::string fp = SSLClientCert::GetFingerprint(&user->eh);
+ const std::string fp = sslapi ? sslapi->GetFingerprint(user) : "";
if (fp.size())
params.push_back(fp);
return this->state;
if (msg[2] == "C")
- this->user->Write("AUTHENTICATE %s", msg[3].c_str());
+ {
+ ClientProtocol::Message authmsg("AUTHENTICATE");
+ authmsg.PushParamRef(msg[3]);
+
+ ClientProtocol::Event authevent(*g_protoev, authmsg);
+ LocalUser* const localuser = IS_LOCAL(user);
+ if (localuser)
+ localuser->Send(authevent);
+ }
else if (msg[2] == "D")
{
this->state = SASL_DONE;
public:
SimpleExtItem<SaslAuthenticator>& authExt;
Cap::Capability& cap;
+ UserCertificateAPI sslapi;
+
CommandAuthenticate(Module* Creator, SimpleExtItem<SaslAuthenticator>& ext, Cap::Capability& Cap)
: SplitCommand(Creator, "AUTHENTICATE", 1)
, authExt(ext)
, cap(Cap)
+ , sslapi(Creator)
{
works_before_reg = true;
allow_empty_last_param = false;
SaslAuthenticator *sasl = authExt.get(user);
if (!sasl)
- authExt.set(user, new SaslAuthenticator(user, parameters[0]));
+ authExt.set(user, new SaslAuthenticator(user, parameters[0], sslapi));
else if (sasl->SendClientMessage(parameters) == false) // IAL abort extension --nenolod
{
sasl->AnnounceState();
CommandAuthenticate auth;
CommandSASL sasl;
Events::ModuleEventProvider sasleventprov;
+ ClientProtocol::EventProvider protoev;
public:
ModuleSASL()
, auth(this, authExt, cap)
, sasl(this, authExt)
, sasleventprov(this, "event/sasl")
+ , protoev(this, auth.name)
{
saslevprov = &sasleventprov;
+ g_protoev = &protoev;
}
void init() CXX11_OVERRIDE