[feat] authenticate controller sessions with device keys

This commit is contained in:
dijunkun
2026-11-02 03:00:18 +08:00
parent adcb0f17dd
commit 425698e22e
5 changed files with 6 additions and 8 deletions
@@ -709,7 +709,6 @@ int GuiRuntime::ConnectTo(const std::string& remote_id, const char* password,
props->audio_capture_button_pressed_ = !background;
memcpy(&props->params_, &params_, sizeof(Params));
props->params_.user_id = props->local_id_.c_str();
props->params_.on_signal_exchange = nullptr;
props->peer_events_ = std::make_shared<PeerEventHandler>(*this);
props->params_.user_data = props->peer_events_.get();
props->peer_ = CreatePeer(&props->params_);
@@ -20,7 +20,6 @@ int DeviceLogin::Exchange(SignalExchangeStage stage, const nlohmann::json& messa
password_.clear();
request_ = message;
const auto login = message.at("user_id").get<std::string>();
if (login.rfind("C-", 0) == 0) return 0;
if (!identity) return -1; // Never fall back when local key storage fails.
const auto at = login.find('@');
request_["user_id"] = login.substr(0, at);
@@ -44,7 +43,7 @@ int DeviceLogin::Exchange(SignalExchangeStage stage, const nlohmann::json& messa
auto reply = request_;
used_password_ = message.at("password_required").get<bool>();
if (used_password_) {
if (id.empty() || password_.empty()) return -1;
if (id.empty() || id.rfind("C-", 0) == 0 || password_.empty()) return -1;
reply["user_id"] = id + "@" + password_;
}
const auto transcript = nlohmann::json::array(