Fix a regression issue orca couldn't login into BBL cloud (#13407)

* Add ticket-based OAuth flow for third-party login in HttpServer

* Fix legacy plugin login
This commit is contained in:
SoftFever
2026-04-30 16:12:08 +08:00
committed by GitHub
parent dae0694e90
commit d78ad8c44e
14 changed files with 162 additions and 8 deletions

View File

@@ -628,6 +628,17 @@ int BBLCloudServiceAgent::get_my_profile(std::string token, unsigned int* http_c
return -1;
}
int BBLCloudServiceAgent::get_my_token(std::string ticket, unsigned int* http_code, std::string* http_body)
{
auto& plugin = BBLNetworkPlugin::instance();
auto agent = plugin.get_agent();
auto func = plugin.get_get_my_token();
if (func && agent) {
return func(agent, ticket, http_code, http_body);
}
return -1;
}
// ============================================================================
// Analytics & Tracking
// ============================================================================

View File

@@ -98,6 +98,7 @@ public:
int get_model_mall_home_url(std::string* url) override;
int get_model_mall_detail_url(std::string* url, std::string id) override;
int get_my_profile(std::string token, unsigned int* http_code, std::string* http_body) override;
int get_my_token(std::string ticket, unsigned int* http_code, std::string* http_body) override;
// Analytics & Tracking
int track_enable(bool enable) override;

View File

@@ -176,7 +176,8 @@ int BBLNetworkPlugin::initialize(bool using_backup, const std::string& version)
<< ", version=" << (loaded_version.empty() ? "unknown" : loaded_version)
<< ", send_message=" << (m_send_message ? "loaded" : "null")
<< ", start_print=" << (m_start_print ? "loaded" : "null")
<< ", start_local_print=" << (m_start_local_print ? "loaded" : "null");
<< ", start_local_print=" << (m_start_local_print ? "loaded" : "null")
<< ", get_my_token=" << (m_get_my_token ? "loaded" : "null");
return 0;
}
@@ -622,6 +623,7 @@ void BBLNetworkPlugin::load_all_function_pointers()
m_get_model_mall_home_url = reinterpret_cast<func_get_model_mall_home_url>(get_function("bambu_network_get_model_mall_home_url"));
m_get_model_mall_detail_url = reinterpret_cast<func_get_model_mall_detail_url>(get_function("bambu_network_get_model_mall_detail_url"));
m_get_my_profile = reinterpret_cast<func_get_my_profile>(get_function("bambu_network_get_my_profile"));
m_get_my_token = reinterpret_cast<func_get_my_token>(get_function("bambu_network_get_my_token"));
m_track_enable = reinterpret_cast<func_track_enable>(get_function("bambu_network_track_enable"));
m_track_remove_files = reinterpret_cast<func_track_remove_files>(get_function("bambu_network_track_remove_files"));
m_track_event = reinterpret_cast<func_track_event>(get_function("bambu_network_track_event"));
@@ -725,6 +727,7 @@ void BBLNetworkPlugin::clear_all_function_pointers()
m_get_model_mall_home_url = nullptr;
m_get_model_mall_detail_url = nullptr;
m_get_my_profile = nullptr;
m_get_my_token = nullptr;
m_track_enable = nullptr;
m_track_remove_files = nullptr;
m_track_event = nullptr;

View File

@@ -107,6 +107,7 @@ typedef int (*func_get_subtask)(void *agent, BBLModelTask* task, OnGetSubTaskFn
typedef int (*func_get_model_mall_home_url)(void *agent, std::string* url);
typedef int (*func_get_model_mall_detail_url)(void *agent, std::string* url, std::string id);
typedef int (*func_get_my_profile)(void *agent, std::string token, unsigned int *http_code, std::string *http_body);
typedef int (*func_get_my_token)(void *agent, std::string ticket, unsigned int *http_code, std::string *http_body);
typedef int (*func_track_enable)(void *agent, bool enable);
typedef int (*func_track_remove_files)(void *agent);
typedef int (*func_track_event)(void *agent, std::string evt_key, std::string content);
@@ -361,6 +362,7 @@ public:
func_get_model_mall_home_url get_get_model_mall_home_url() const { return m_get_model_mall_home_url; }
func_get_model_mall_detail_url get_get_model_mall_detail_url() const { return m_get_model_mall_detail_url; }
func_get_my_profile get_get_my_profile() const { return m_get_my_profile; }
func_get_my_token get_get_my_token() const { return m_get_my_token; }
func_track_enable get_track_enable() const { return m_track_enable; }
func_track_remove_files get_track_remove_files() const { return m_track_remove_files; }
func_track_event get_track_event() const { return m_track_event; }
@@ -496,6 +498,7 @@ private:
func_get_model_mall_home_url m_get_model_mall_home_url{nullptr};
func_get_model_mall_detail_url m_get_model_mall_detail_url{nullptr};
func_get_my_profile m_get_my_profile{nullptr};
func_get_my_token m_get_my_token{nullptr};
func_track_enable m_track_enable{nullptr};
func_track_remove_files m_track_remove_files{nullptr};
func_track_event m_track_event{nullptr};

View File

@@ -353,6 +353,14 @@ public:
*/
virtual int get_my_profile(std::string token, unsigned int* http_code, std::string* http_body) = 0;
/**
* Exchange a one-time login ticket (from a third-party OAuth callback)
* for token + profile JSON. Used by the localhost callback handler when
* the auth server redirects with ?ticket=...&redirect_url=... instead of
* passing tokens directly in the URL.
*/
virtual int get_my_token(std::string ticket, unsigned int* http_code, std::string* http_body) = 0;
// ========================================================================
// Analytics & Tracking
// ========================================================================

View File

@@ -781,6 +781,12 @@ int NetworkAgent::get_my_profile(std::string token, unsigned int* http_code, std
return -1;
}
int NetworkAgent::get_my_token(std::string ticket, unsigned int* http_code, std::string* http_body)
{
if (m_cloud_agent) return m_cloud_agent->get_my_token(ticket, http_code, http_body);
return -1;
}
int NetworkAgent::track_enable(bool enable)
{
this->enable_track = enable;

View File

@@ -144,6 +144,7 @@ public:
int get_model_mall_home_url(std::string* url);
int get_model_mall_detail_url(std::string* url, std::string id);
int get_my_profile(std::string token, unsigned int* http_code, std::string* http_body);
int get_my_token(std::string ticket, unsigned int* http_code, std::string* http_body);
int track_enable(bool enable);
int track_remove_files();
int track_event(std::string evt_key, std::string content);

View File

@@ -2474,6 +2474,14 @@ int OrcaCloudServiceAgent::get_my_profile(std::string token, unsigned int* http_
return BAMBU_NETWORK_SUCCESS;
}
int OrcaCloudServiceAgent::get_my_token(std::string ticket, unsigned int* http_code, std::string* http_body)
{
BOOST_LOG_TRIVIAL(debug) << "OrcaCloudServiceAgent: get_my_token (stub) - Orca cloud uses code-based OAuth, not tickets";
if (http_code) *http_code = 0;
if (http_body) *http_body = "";
return -1;
}
int OrcaCloudServiceAgent::track_enable(bool enable)
{
std::lock_guard<std::recursive_mutex> lock(state_mutex);

View File

@@ -199,6 +199,7 @@ public:
int get_model_mall_home_url(std::string* url) override;
int get_model_mall_detail_url(std::string* url, std::string id) override;
int get_my_profile(std::string token, unsigned int* http_code, std::string* http_body) override;
int get_my_token(std::string ticket, unsigned int* http_code, std::string* http_body) override;
// ========================================================================
// ICloudServiceAgent Interface Implementation - Analytics & Tracking