mirror of
https://github.com/OpenFusionProject/OpenFusion.git
synced 2026-03-28 23:50:02 +00:00
Refactor login packet handler for more flexible auth (#298)
This PR enables auth cookies to be used simultaneously with plaintext paasswords sent in the cookie authID field. * Hoist a bunch of checks from the login packet handler into helper functions. * Rename the LoginType enum to AuthMethod and distinguish it from the iLoginType packet field (see comment in code for why these should be decoupled). * If the provided token does not pass the cookie check and password auth is enabled, treat it as a plaintext password and authenticate if it is correct.
This commit is contained in:
11
src/main.cpp
11
src/main.cpp
@@ -222,6 +222,17 @@ time_t getTimestamp() {
|
||||
return (time_t)value.count();
|
||||
}
|
||||
|
||||
// timing safe strcmp implementation for e.g. cookie validation
|
||||
int timingSafeStrcmp(const char* a, const char* b) {
|
||||
int diff = 0;
|
||||
while (*a && *b) {
|
||||
diff |= *a++ ^ *b++;
|
||||
}
|
||||
diff |= *a;
|
||||
diff |= *b;
|
||||
return diff;
|
||||
}
|
||||
|
||||
// convert integer timestamp (in s) to FF systime struct
|
||||
sSYSTEMTIME timeStampToStruct(uint64_t time) {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user