mirror of
https://github.com/OpenFusionProject/OpenFusion.git
synced 2024-11-24 05:51:05 +00:00
Add config option for auth cookie support
This commit is contained in:
parent
a38b14b79a
commit
c29899f2b9
@ -17,6 +17,8 @@ acceptallcustomnames=true
|
|||||||
# should attempts to log into non-existent accounts
|
# should attempts to log into non-existent accounts
|
||||||
# automatically create them?
|
# automatically create them?
|
||||||
autocreateaccounts=true
|
autocreateaccounts=true
|
||||||
|
# support logging in with auth cookies?
|
||||||
|
useauthcookies=false
|
||||||
# how often should everything be flushed to the database?
|
# how often should everything be flushed to the database?
|
||||||
# the default is 4 minutes
|
# the default is 4 minutes
|
||||||
dbsaveinterval=240
|
dbsaveinterval=240
|
||||||
|
@ -112,6 +112,10 @@ void CNLoginServer::login(CNSocket* sock, CNPacketData* data) {
|
|||||||
if (isCookieAuth) {
|
if (isCookieAuth) {
|
||||||
// username encoded in TEGid raw
|
// username encoded in TEGid raw
|
||||||
userLogin = std::string((char*)login->szCookie_TEGid);
|
userLogin = std::string((char*)login->szCookie_TEGid);
|
||||||
|
|
||||||
|
// clients that use web login but without proper cookies
|
||||||
|
// send their passwords instead, so store that
|
||||||
|
userPassword = std::string((char*)login->szCookie_authid);
|
||||||
} else {
|
} else {
|
||||||
/*
|
/*
|
||||||
* The std::string -> char* -> std::string maneuver should remove any
|
* The std::string -> char* -> std::string maneuver should remove any
|
||||||
@ -121,6 +125,11 @@ void CNLoginServer::login(CNSocket* sock, CNPacketData* data) {
|
|||||||
userPassword = std::string(AUTOU16TOU8(login->szPassword).c_str());
|
userPassword = std::string(AUTOU16TOU8(login->szPassword).c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!settings::USEAUTHCOOKIES) {
|
||||||
|
// use normal login flow
|
||||||
|
isCookieAuth = false;
|
||||||
|
}
|
||||||
|
|
||||||
// check username regex
|
// check username regex
|
||||||
if (!CNLoginServer::isUsernameGood(userLogin)) {
|
if (!CNLoginServer::isUsernameGood(userLogin)) {
|
||||||
// send a custom error message
|
// send a custom error message
|
||||||
|
@ -13,6 +13,7 @@ bool settings::SANDBOX = true;
|
|||||||
int settings::LOGINPORT = 23000;
|
int settings::LOGINPORT = 23000;
|
||||||
bool settings::APPROVEALLNAMES = true;
|
bool settings::APPROVEALLNAMES = true;
|
||||||
bool settings::AUTOCREATEACCOUNTS = true;
|
bool settings::AUTOCREATEACCOUNTS = true;
|
||||||
|
bool settings::USEAUTHCOOKIES = false;
|
||||||
int settings::DBSAVEINTERVAL = 240;
|
int settings::DBSAVEINTERVAL = 240;
|
||||||
|
|
||||||
int settings::SHARDPORT = 23001;
|
int settings::SHARDPORT = 23001;
|
||||||
@ -87,6 +88,7 @@ void settings::init() {
|
|||||||
LOGINPORT = reader.GetInteger("login", "port", LOGINPORT);
|
LOGINPORT = reader.GetInteger("login", "port", LOGINPORT);
|
||||||
APPROVEALLNAMES = reader.GetBoolean("login", "acceptallcustomnames", APPROVEALLNAMES);
|
APPROVEALLNAMES = reader.GetBoolean("login", "acceptallcustomnames", APPROVEALLNAMES);
|
||||||
AUTOCREATEACCOUNTS = reader.GetBoolean("login", "autocreateaccounts", AUTOCREATEACCOUNTS);
|
AUTOCREATEACCOUNTS = reader.GetBoolean("login", "autocreateaccounts", AUTOCREATEACCOUNTS);
|
||||||
|
USEAUTHCOOKIES = reader.GetBoolean("login", "useauthcookies", USEAUTHCOOKIES);
|
||||||
DBSAVEINTERVAL = reader.GetInteger("login", "dbsaveinterval", DBSAVEINTERVAL);
|
DBSAVEINTERVAL = reader.GetInteger("login", "dbsaveinterval", DBSAVEINTERVAL);
|
||||||
SHARDPORT = reader.GetInteger("shard", "port", SHARDPORT);
|
SHARDPORT = reader.GetInteger("shard", "port", SHARDPORT);
|
||||||
SHARDSERVERIP = reader.Get("shard", "ip", SHARDSERVERIP);
|
SHARDSERVERIP = reader.Get("shard", "ip", SHARDSERVERIP);
|
||||||
|
@ -8,6 +8,7 @@ namespace settings {
|
|||||||
extern int LOGINPORT;
|
extern int LOGINPORT;
|
||||||
extern bool APPROVEALLNAMES;
|
extern bool APPROVEALLNAMES;
|
||||||
extern bool AUTOCREATEACCOUNTS;
|
extern bool AUTOCREATEACCOUNTS;
|
||||||
|
extern bool USEAUTHCOOKIES;
|
||||||
extern int DBSAVEINTERVAL;
|
extern int DBSAVEINTERVAL;
|
||||||
extern int SHARDPORT;
|
extern int SHARDPORT;
|
||||||
extern std::string SHARDSERVERIP;
|
extern std::string SHARDSERVERIP;
|
||||||
|
Loading…
Reference in New Issue
Block a user