Add RSA keypair generation and public key upload in loadTokenFromFile
Some checks failed
CI / build-and-test (push) Has been cancelled
Some checks failed
CI / build-and-test (push) Has been cancelled
This commit is contained in:
@@ -282,6 +282,18 @@ bool OverteAuth::loadTokenFromFile() {
|
|||||||
|
|
||||||
std::cout << "[OverteAuth] Loaded saved token for " << m_username << std::endl;
|
std::cout << "[OverteAuth] Loaded saved token for " << m_username << std::endl;
|
||||||
|
|
||||||
|
// Generate keypair if we don't have one
|
||||||
|
if (!hasKeypair()) {
|
||||||
|
std::cout << "[OverteAuth] Generating RSA keypair..." << std::endl;
|
||||||
|
if (!generateKeypair()) {
|
||||||
|
std::cerr << "[OverteAuth] Failed to generate keypair" << std::endl;
|
||||||
|
} else if (!uploadPublicKey()) {
|
||||||
|
std::cerr << "[OverteAuth] Warning: Failed to upload public key to metaverse" << std::endl;
|
||||||
|
} else {
|
||||||
|
std::cout << "[OverteAuth] ✓ RSA keypair generated and public key uploaded" << std::endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Check if token needs refresh
|
// Check if token needs refresh
|
||||||
if (isTokenExpired()) {
|
if (isTokenExpired()) {
|
||||||
std::cout << "[OverteAuth] Token expired, attempting refresh..." << std::endl;
|
std::cout << "[OverteAuth] Token expired, attempting refresh..." << std::endl;
|
||||||
@@ -811,6 +823,9 @@ bool OverteAuth::uploadPublicKey() {
|
|||||||
curl_slist_free_all(headers);
|
curl_slist_free_all(headers);
|
||||||
curl_easy_cleanup(curl);
|
curl_easy_cleanup(curl);
|
||||||
|
|
||||||
|
std::cout << "[OverteAuth] HTTP status: " << httpCode << std::endl;
|
||||||
|
std::cout << "[OverteAuth] Server response: " << response << std::endl;
|
||||||
|
|
||||||
if (res != CURLE_OK) {
|
if (res != CURLE_OK) {
|
||||||
m_lastError = std::string("Public key upload failed: ") + curl_easy_strerror(res);
|
m_lastError = std::string("Public key upload failed: ") + curl_easy_strerror(res);
|
||||||
return false;
|
return false;
|
||||||
@@ -818,7 +833,6 @@ bool OverteAuth::uploadPublicKey() {
|
|||||||
|
|
||||||
if (httpCode != 200) {
|
if (httpCode != 200) {
|
||||||
m_lastError = "Public key upload failed with HTTP " + std::to_string(httpCode);
|
m_lastError = "Public key upload failed with HTTP " + std::to_string(httpCode);
|
||||||
std::cerr << "[OverteAuth] Server response: " << response << std::endl;
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user