fixes lol
All checks were successful
Build and Push / build-all (push) Successful in 9m12s

This commit is contained in:
doomtube 2026-01-07 02:14:34 -05:00
parent 99151c6692
commit 3676dc46ed
16 changed files with 894 additions and 89 deletions

View file

@ -31,6 +31,16 @@ struct UserInfo {
int tokenVersion = 1; // SECURITY FIX #10: Token version for revocation
};
// Result structure for refresh token operations
struct RefreshTokenResult {
bool success = false;
std::string error;
std::string accessToken;
std::string refreshToken;
std::string familyId;
UserInfo user;
};
// Chat service compatibility struct
struct UserClaims {
std::string userId;
@ -71,6 +81,20 @@ public:
// Chat service compatibility method
std::optional<UserClaims> verifyToken(const std::string& token);
// Refresh token methods
void createRefreshTokenFamily(int64_t userId,
std::function<void(bool success, const std::string& refreshToken,
const std::string& familyId)> callback);
void validateAndRotateRefreshToken(const std::string& refreshToken,
std::function<void(RefreshTokenResult)> callback);
void revokeTokenFamily(const std::string& familyId,
std::function<void(bool success)> callback);
void revokeAllUserTokenFamilies(int64_t userId,
std::function<void(bool success)> callback);
// New method to fetch complete user info including color
void fetchUserInfo(int64_t userId, std::function<void(bool, const UserInfo&)> callback);
@ -89,4 +113,12 @@ private:
bool validatePassword(const std::string& password, std::string& error);
void validateAndLoadJwtSecret(); // SECURITY FIX #5
// Refresh token helpers
std::string generateRefreshToken(); // Generates random 256-bit token
std::string hashToken(const std::string& token); // SHA256 hash for storage
std::string generateUUID(); // Generate UUID for family_id
static constexpr int ACCESS_TOKEN_EXPIRY_MINUTES = 150; // 2.5 hours (gives buffer for 2-hour refresh)
static constexpr int REFRESH_TOKEN_EXPIRY_DAYS = 90;
};