scar-chat7/server/auth/authenticator.h

30 lines
810 B
C
Raw Normal View History

2025-12-07 12:00:44 -07:00
#pragma once
#include "../database/database.h"
#include "../shared/crypto/argon2_wrapper.h"
#include "../shared/auth/jwt.h"
#include <memory>
#include <string>
namespace scar {
class Authenticator {
public:
Authenticator(std::shared_ptr<Database> db, const std::string& jwt_secret);
// Authenticate user with username/password (returns JWT token on success)
std::string authenticate(const std::string& username, const std::string& password);
// Verify JWT token (returns username on success, empty string on failure)
std::string verifyToken(const std::string& token);
// Create new user
bool createUser(const std::string& username, const std::string& password);
private:
std::shared_ptr<Database> db_;
std::string jwt_secret_;
};
} // namespace scar