test: Add 8 and update 14 files
This commit is contained in:
@@ -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
|
||||
|
Reference in New Issue
Block a user