4 Commits

Author SHA1 Message Date
d9b6aedd5b Fix nested ifdefs for windows 2024-10-06 20:58:20 -07:00
CakeLancelot
145113062b Update tdata reference to fix invalid label 2024-10-05 16:51:39 -05:00
d717c5d74d Update tdata reference for the car paths 2024-09-22 04:28:28 +02:00
a6eb0e2349 Auth Cookie Support (#285)
* Auth cookie support

* Add config option for auth cookie support

* Safe handling of TEGid/auth_id strings

* Fix bad size calculation due to pointer cast

* Expiration timestamp instead of valid bit

* Change setting to "allowed auth methods"

This allows plaintext password auth to be disabled altogether

* PR feedback
2024-09-17 20:41:48 -07:00
5 changed files with 9 additions and 8 deletions

View File

@@ -53,7 +53,7 @@ namespace Database {
void updateAccountLevel(int accountId, int accountLevel);
// return true iff cookie is valid for the account.
// return true if cookie is valid for the account.
// invalidates the stored cookie afterwards
bool checkCookie(int accountId, const char *cookie);

View File

@@ -130,7 +130,8 @@ bool Database::checkCookie(int accountId, const char *tryCookie) {
return false;
}
/* since cookies are immediately invalidated, we don't need to be concerned about
/*
* since cookies are immediately invalidated, we don't need to be concerned about
* timing-related side channel attacks, so strcmp is fine here
*/
bool match = (strcmp(cookie, tryCookie) == 0);
@@ -141,7 +142,7 @@ bool Database::checkCookie(int accountId, const char *tryCookie) {
rc = sqlite3_step(stmt);
sqlite3_finalize(stmt);
if (rc != SQLITE_DONE)
std::cout << "[WARN] Database fail on consumeCookie(): " << sqlite3_errmsg(db) << std::endl;
std::cout << "[WARN] Database fail on checkCookie(): " << sqlite3_errmsg(db) << std::endl;
return match;
}

View File

@@ -682,8 +682,7 @@ bool CNLoginServer::isCharacterNameGood(std::string Firstname, std::string Lastn
bool CNLoginServer::isLoginTypeAllowed(LoginType loginType) {
// the config file specifies "comma-separated" but tbh we don't care
switch (loginType)
{
switch (loginType) {
case LoginType::PASSWORD:
return settings::AUTHMETHODS.find("password") != std::string::npos;
case LoginType::COOKIE:

2
tdata

Submodule tdata updated: 8c98c83682...bdb611b092

View File

@@ -22,13 +22,14 @@
#endif
#include <errno.h>
#if defined(_WIN32) || defined(_WIN64)
// On windows we need to generate random bytes differently.
#if defined(_WIN32) && !defined(_WIN64)
typedef __int32 ssize_t;
#elif defined(_WIN32) && defined(_WIN64)
typedef __int64 ssize_t;
#endif
#if defined(_WIN32) || defined(_WIN64)
// On windows we need to generate random bytes differently.
#define BCRYPT_HASHSIZE 60
#include "bcrypt.h"