void Client::sendChangePassword(const std::string &oldpassword, const std::string &newpassword) { Player *player = m_env.getLocalPlayer(); if (player == NULL) return; std::string playername = player->getName(); if (m_proto_ver >= 25) { // get into sudo mode and then send new password to server m_password = oldpassword; m_new_password = newpassword; startAuth(choseAuthMech(m_sudo_auth_methods)); } else { std::string oldpwd = translatePassword(playername, oldpassword); std::string newpwd = translatePassword(playername, newpassword); NetworkPacket pkt(TOSERVER_PASSWORD_LEGACY, 2 * PASSWORD_SIZE); for (u8 i = 0; i < PASSWORD_SIZE; i++) { pkt << (u8) (i < oldpwd.length() ? oldpwd[i] : 0); } for (u8 i = 0; i < PASSWORD_SIZE; i++) { pkt << (u8) (i < newpwd.length() ? newpwd[i] : 0); } Send(&pkt); } }
/** * Callback for messages, arrived from MQTT broker */ void onMessageReceived(String topic, String message) { Serial.println("Message received: " + message); // Messages from mobile-app if (message.equals("AUTH_REQUEST")) { authStartRequest(); } if (message.equals("AUTH_REJECT")) { } if (message.equals("AUTH_END")) { setConfigMode(false); } // Messages from server if (message.equals("START_AUTH")) { startAuth(); } }
void Client::handleCommand_Hello(NetworkPacket* pkt) { if (pkt->getSize() < 1) return; u8 serialization_ver; u16 proto_ver; u16 compression_mode; u32 auth_mechs; std::string username_legacy; // for case insensitivity *pkt >> serialization_ver >> compression_mode >> proto_ver >> auth_mechs >> username_legacy; // Chose an auth method we support AuthMechanism chosen_auth_mechanism = choseAuthMech(auth_mechs); infostream << "Client: TOCLIENT_HELLO received with " << "serialization_ver=" << (u32)serialization_ver << ", auth_mechs=" << auth_mechs << ", proto_ver=" << proto_ver << ", compression_mode=" << compression_mode << ". Doing auth with mech " << chosen_auth_mechanism << std::endl; if (!ser_ver_supported(serialization_ver)) { infostream << "Client: TOCLIENT_HELLO: Server sent " << "unsupported ser_fmt_ver"<< std::endl; return; } m_server_ser_ver = serialization_ver; m_proto_ver = proto_ver; //TODO verify that username_legacy matches sent username, only // differs in casing (make both uppercase and compare) // This is only neccessary though when we actually want to add casing support if (m_chosen_auth_mech != AUTH_MECHANISM_NONE) { // we recieved a TOCLIENT_HELLO while auth was already going on errorstream << "Client: TOCLIENT_HELLO while auth was already going on" << "(chosen_mech=" << m_chosen_auth_mech << ")." << std::endl; if ((m_chosen_auth_mech == AUTH_MECHANISM_SRP) || (m_chosen_auth_mech == AUTH_MECHANISM_LEGACY_PASSWORD)) { srp_user_delete((SRPUser *) m_auth_data); m_auth_data = 0; } } // Authenticate using that method, or abort if there wasn't any method found if (chosen_auth_mechanism != AUTH_MECHANISM_NONE) { startAuth(chosen_auth_mechanism); } else { m_chosen_auth_mech = AUTH_MECHANISM_NONE; m_access_denied = true; m_access_denied_reason = "Unknown"; m_con.Disconnect(); } }
void Client::sendChangePassword(const std::string &oldpassword, const std::string &newpassword) { LocalPlayer *player = m_env.getLocalPlayer(); if (player == NULL) return; // get into sudo mode and then send new password to server m_password = oldpassword; m_new_password = newpassword; startAuth(choseAuthMech(m_sudo_auth_methods)); }
void Client::handleCommand_AcceptSudoMode(NetworkPacket* pkt) { deleteAuthData(); m_password = m_new_password; verbosestream << "Client: Recieved TOCLIENT_ACCEPT_SUDO_MODE." << std::endl; // send packet to actually set the password startAuth(AUTH_MECHANISM_FIRST_SRP); // reset again m_chosen_auth_mech = AUTH_MECHANISM_NONE; }
void Display::login(QLocalSocket *socket, const QString &user, const QString &password, const Session &session) { m_socket = socket; //the SDDM user has special privileges that skip password checking so that we can load the greeter //block ever trying to log in as the SDDM user if (user == QLatin1String("sddm")) { return; } // authenticate startAuth(user, password, session); }