demote logs

This commit is contained in:
Pliable Pixels 2019-05-12 15:45:39 -04:00
parent cc0d23ce4e
commit 21710b6e49
4 changed files with 9 additions and 9 deletions

View File

@ -35,7 +35,7 @@ std::pair <std::string, unsigned int> verifyToken(std::string jwt_token_str, std
} }
if (decoded.has_payload_claim("user")) { if (decoded.has_payload_claim("user")) {
username = decoded.get_payload_claim("user").as_string(); username = decoded.get_payload_claim("user").as_string();
Info ("Got %s as user claim from token", username.c_str()); Debug (1, "Got %s as user claim from token", username.c_str());
} }
else { else {
Error ("User not found in claim"); Error ("User not found in claim");
@ -44,7 +44,7 @@ std::pair <std::string, unsigned int> verifyToken(std::string jwt_token_str, std
if (decoded.has_payload_claim("iat")) { if (decoded.has_payload_claim("iat")) {
token_issued_at = (unsigned int) (decoded.get_payload_claim("iat").as_int()); token_issued_at = (unsigned int) (decoded.get_payload_claim("iat").as_int());
Info ("Got IAT token=%u", token_issued_at); Debug (1,"Got IAT token=%u", token_issued_at);
} }
else { else {
@ -73,7 +73,7 @@ bool verifyPassword(const char *username, const char *input_password, const char
} }
if (db_password_hash[0] == '*') { if (db_password_hash[0] == '*') {
// MYSQL PASSWORD // MYSQL PASSWORD
Info ("%s is using an MD5 encoded password", username); Debug (1,"%s is using an MD5 encoded password", username);
SHA_CTX ctx1, ctx2; SHA_CTX ctx1, ctx2;
unsigned char digest_interim[SHA_DIGEST_LENGTH]; unsigned char digest_interim[SHA_DIGEST_LENGTH];
@ -96,14 +96,14 @@ bool verifyPassword(const char *username, const char *input_password, const char
sprintf(&final_hash[i*2]+1, "%02X", (unsigned int)digest_final[i]); sprintf(&final_hash[i*2]+1, "%02X", (unsigned int)digest_final[i]);
final_hash[SHA_DIGEST_LENGTH *2 + 1]=0; final_hash[SHA_DIGEST_LENGTH *2 + 1]=0;
Info ("Computed password_hash:%s, stored password_hash:%s", final_hash, db_password_hash); Debug (1,"Computed password_hash:%s, stored password_hash:%s", final_hash, db_password_hash);
Debug (5, "Computed password_hash:%s, stored password_hash:%s", final_hash, db_password_hash); Debug (5, "Computed password_hash:%s, stored password_hash:%s", final_hash, db_password_hash);
password_correct = (strcmp(db_password_hash, final_hash)==0); password_correct = (strcmp(db_password_hash, final_hash)==0);
} }
else if ((db_password_hash[0] == '$') && (db_password_hash[1]== '2') else if ((db_password_hash[0] == '$') && (db_password_hash[1]== '2')
&&(db_password_hash[3] == '$')) { &&(db_password_hash[3] == '$')) {
// BCRYPT // BCRYPT
Info ("%s is using a bcrypt encoded password", username); Debug (1,"%s is using a bcrypt encoded password", username);
BCrypt bcrypt; BCrypt bcrypt;
std::string input_hash = bcrypt.generateHash(std::string(input_password)); std::string input_hash = bcrypt.generateHash(std::string(input_password));
password_correct = bcrypt.validatePassword(std::string(input_password), std::string(db_password_hash)); password_correct = bcrypt.validatePassword(std::string(input_password), std::string(db_password_hash));

View File

@ -152,7 +152,7 @@ User *zmLoadTokenUser (std::string jwt_token_str, bool use_remote_addr ) {
key += remote_addr; key += remote_addr;
} }
Info ("Inside zmLoadTokenUser, formed key=%s", key.c_str()); Debug (1,"Inside zmLoadTokenUser, formed key=%s", key.c_str());
std::pair<std::string, unsigned int> ans = verifyToken(jwt_token_str, key); std::pair<std::string, unsigned int> ans = verifyToken(jwt_token_str, key);
std::string username = ans.first; std::string username = ans.first;
@ -192,7 +192,7 @@ User *zmLoadTokenUser (std::string jwt_token_str, bool use_remote_addr ) {
return NULL; return NULL;
} }
Info ("Got stored expiry time of %u",stored_iat); Debug (1,"Got stored expiry time of %u",stored_iat);
Info ("Authenticated user '%s' via token", username.c_str()); Info ("Authenticated user '%s' via token", username.c_str());
mysql_free_result(result); mysql_free_result(result);
return user; return user;

View File

@ -161,7 +161,7 @@ int main( int argc, const char *argv[] ) {
strncpy( auth, value, sizeof(auth)-1 ); strncpy( auth, value, sizeof(auth)-1 );
} else if ( !strcmp( name, "token" ) ) { } else if ( !strcmp( name, "token" ) ) {
jwt_token_str = value; jwt_token_str = value;
Info("ZMS: JWT token found: %s", jwt_token_str.c_str()); Debug(1,"ZMS: JWT token found: %s", jwt_token_str.c_str());
} else if ( !strcmp( name, "user" ) ) { } else if ( !strcmp( name, "user" ) ) {
username = UriDecode( value ); username = UriDecode( value );

View File

@ -345,7 +345,7 @@ foreach ( array_map('basename', glob('skins/'.$current_skin.'/css/*',GLOB_ONLYDI
dbQuery('UPDATE Users SET APIEnabled=1 WHERE Id=?', array($markUid)); dbQuery('UPDATE Users SET APIEnabled=1 WHERE Id=?', array($markUid));
// echo "UPDATE Users SET APIEnabled=1"." WHERE Id=".$markUid."<br/>"; // echo "UPDATE Users SET APIEnabled=1"." WHERE Id=".$markUid."<br/>";
} }
echo "Updated."; echo "Updated";
} }
if(array_key_exists('revokeAllTokens',$_POST)){ if(array_key_exists('revokeAllTokens',$_POST)){