test: Add 8 and update 14 files
Some checks failed
Build-Test-Publish / build (linux/amd64) (push) Failing after 22s
Build-Test-Publish / build (linux/arm64) (push) Failing after 32s
Build-Test-Publish / create-manifest (push) Has been skipped

This commit is contained in:
Your Name
2025-08-10 21:18:40 +12:00
parent 1fed086348
commit 8ab6028597
22 changed files with 1392 additions and 81 deletions

View File

@@ -19,6 +19,7 @@
#include "welcome_page.hpp"
#include "rate_limiter.hpp"
#include "HttpController.hpp"
#include "bcrypt.hpp" // For secure token hashing
namespace simple_object_storage {
@@ -67,7 +68,16 @@ bool Server::validate_write_request(const drogon::HttpRequestPtr &req, drogon::H
return false;
}
bool write_token_valid = std::find(config_.write_tokens.begin(), config_.write_tokens.end(), token) != config_.write_tokens.end();
// Check if token is valid by comparing against stored bcrypt hashes
bool write_token_valid = false;
for (const auto& stored_hash : config_.write_tokens) {
// Verify the token against the stored bcrypt hash
if (BCrypt::verifyPassword(token, stored_hash)) {
write_token_valid = true;
break;
}
}
if (!write_token_valid) {
// Only count failed attempt (increment the limiter)
auth_rate_limiter_->is_allowed(client_ip); // This will increment the count