Skip to content

Commit 68e49ab

Browse files
authored
Merge pull request #322 from Groruk/master
Session based logins
2 parents 58056a7 + c95362e commit 68e49ab

21 files changed

+2406
-756
lines changed

CHANGELOG.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,21 @@ Legend:
99
! = Fixed bug
1010
? = Other stuff
1111
```
12+
(04/07/17): Version 1.6.2
13+
-----------------------
14+
```
15+
01. ! Fixed issue with group Banning
16+
02. ! Fixed AmxBans import issue
17+
03. ! Fixed possible XSS Injection
18+
04. + Adjusted regex for CSGO
19+
05. + Added option to disable 'comms' tab
20+
06. ! Fixed bugs with SteamID format
21+
07. ! Fixed version checks
22+
08. ? Git version is now only shown in dev builds
23+
09. ! Fixed issue with email links
24+
10. * Added session based logins
25+
```
26+
1227
(07/05/17): Version 1.6.1
1328
-----------------------
1429
```

game/addons/sourcemod/scripting/sbpp_admcfg.sp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ public Plugin myinfo =
3737
name = "SourceBans++: Admin Config Loader",
3838
author = "AlliedModders LLC, SourceBans++ Dev Team",
3939
description = "Reads Admin Files",
40-
version = "1.6.1",
41-
url = "https://sbpp.sarabveer.me/"
40+
version = "1.6.2",
41+
url = "https://sbpp.github.io"
4242
};
4343

4444

game/addons/sourcemod/scripting/sbpp_checker.sp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626

2727
#include <sourcemod>
2828

29-
#define VERSION "1.6.1"
29+
#define VERSION "1.6.2"
3030
#define LISTBANS_USAGE "sm_listsbbans <#userid|name> - Lists a user's prior bans from Sourcebans"
3131
#define INVALID_TARGET -1
3232

@@ -42,7 +42,7 @@ public Plugin:myinfo =
4242
author = "psychonic, Ca$h Munny, SourceBans++ Dev Team",
4343
description = "Notifies admins of prior bans from Sourcebans upon player connect.",
4444
version = VERSION,
45-
url = "https://sbpp.sarabveer.me/"
45+
url = "https://sbpp.github.io"
4646
};
4747

4848
public OnPluginStart()

game/addons/sourcemod/scripting/sbpp_comms.sp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
// Do not edit below this line //
4343
//-----------------------------//
4444

45-
#define PLUGIN_VERSION "1.6.1"
45+
#define PLUGIN_VERSION "1.6.2"
4646
#define PREFIX "\x04[SourceComms++]\x01 "
4747

4848
#define MAX_TIME_MULTI 30 // maximum mass-target punishment length
@@ -161,7 +161,7 @@ public Plugin:myinfo =
161161
author = "Alex, SourceBans++ Dev Team",
162162
description = "Advanced punishments management for the Source engine in SourceBans style",
163163
version = PLUGIN_VERSION,
164-
url = "https://sbpp.sarabveer.me/"
164+
url = "https://sbpp.github.io"
165165
};
166166

167167
public APLRes:AskPluginLoad2(Handle:myself, bool:late, String:error[], err_max)

game/addons/sourcemod/scripting/sbpp_main.sp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@
3232
#include <adminmenu>
3333
#tryinclude <updater>
3434

35-
#define SB_VERSION "1.6.1++"
36-
#define SBR_VERSION "1.6.1"
35+
#define SB_VERSION "1.6.2++"
36+
#define SBR_VERSION "1.6.2"
3737

3838
#if defined _updater_included
3939
#define UPDATE_URL "https://sbpp.github.io/updater/updatefile.txt"
@@ -137,7 +137,7 @@ public Plugin:myinfo =
137137
author = "SourceBans Development Team, SourceBans++ Dev Team",
138138
description = "Advanced ban management for the Source engine",
139139
version = SBR_VERSION,
140-
url = "https://sbpp.sarabveer.me/"
140+
url = "https://sbpp.github.io"
141141
};
142142

143143
#if SOURCEMOD_V_MAJOR >= 1 && SOURCEMOD_V_MINOR >= 3

game/addons/sourcemod/scripting/sbpp_sleuth.sp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
#undef REQUIRE_PLUGIN
3030
#include <sourcebans>
3131

32-
#define PLUGIN_VERSION "1.6.1"
32+
#define PLUGIN_VERSION "1.6.2"
3333

3434
#define LENGTH_ORIGINAL 1
3535
#define LENGTH_CUSTOM 2
@@ -57,7 +57,7 @@ public Plugin:myinfo =
5757
author = "ecca, SourceBans++ Dev Team",
5858
description = "Useful for TF2 servers. Plugin will check for banned ips and ban the player.",
5959
version = PLUGIN_VERSION,
60-
url = "https://sbpp.sarabveer.me/"
60+
url = "https://sbpp.github.io"
6161
};
6262

6363
public OnPluginStart()

web/includes/CUserManager.php

Lines changed: 17 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,12 @@ class CUserManager
3838
* @param $password the current user's password
3939
* @return noreturn.
4040
*/
41-
public function __construct($aid, $password)
41+
public function __construct($aid)
4242
{
4343
$this->dbh = new Database(DB_HOST, DB_PORT, DB_NAME, DB_USER, DB_PASS, DB_PREFIX);
4444

45-
if ($this->CheckLogin($password, $aid)) {
46-
$this->aid = $aid;
47-
$this->GetUserArray($aid);
48-
}
45+
$this->aid = $aid;
46+
$this->GetUserArray($aid);
4947
}
5048

5149

@@ -63,7 +61,7 @@ public function GetUserArray($aid = null)
6361
}
6462
// Invalid aid
6563
if ($aid < 0 || empty($aid)) {
66-
return 0;
64+
return false;
6765
}
6866

6967
// We already got the data from the DB, and its saved in the manager
@@ -82,7 +80,7 @@ public function GetUserArray($aid = null)
8280
$res = $this->dbh->single();
8381

8482
if (!$res) {
85-
return 0; // ohnoes some type of db error
83+
return false; // ohnoes some type of db error
8684
}
8785

8886
$user = array();
@@ -212,30 +210,24 @@ public function CheckLogin($password, $aid)
212210

213211
public function login($aid, $password, $save = true)
214212
{
215-
if ($this->CheckLogin($this->encrypt_password($password), $aid)) {
213+
if ($this->CheckLogin($this->encrypt_password($password), $aid) || $this->CheckLogin($this->hash($password), $aid)) {
216214
//Old password hash detected update it.
217215
$this->dbh->query('UPDATE `:prefix_admins` SET password = :password WHERE aid = :aid');
218-
$this->dbh->bind(':password', $this->hash($password));
216+
$this->dbh->bind(':password', password_hash($password, PASSWORD_BCRYPT));
219217
$this->dbh->bind(':aid', $aid);
220218
$this->dbh->execute();
221219

222-
setcookie("aid", $aid);
223-
setcookie("password", $this->hash($password));
224-
setcookie("user", $_SESSION['user']['user']);
220+
\SessionManager::sessionStart('login', 604800, 0);
221+
$_SESSION['aid'] = $aid;
225222
return true;
226223
}
227224

228-
if ($this->CheckLogin($this->hash($password), $aid)) {
229-
if ($save) {
230-
//Sets cookies
231-
setcookie("aid", $aid, time()+LOGIN_COOKIE_LIFETIME);
232-
setcookie("password", $this->hash($password), time()+LOGIN_COOKIE_LIFETIME);
233-
setcookie("user", isset($_SESSION['user']['user'])?$_SESSION['user']['user']:null, time()+LOGIN_COOKIE_LIFETIME);
234-
return true;
235-
}
236-
setcookie("aid", $aid);
237-
setcookie("password", $this->hash($password));
238-
setcookie("user", $_SESSION['user']['user']);
225+
$this->dbh->query('SELECT password FROM `:prefix_admins` WHERE aid = :aid');
226+
$this->dbh->bind(':aid', $aid);
227+
$hash = $this->dbh->single();
228+
if (password_verify($password, $hash['password'])) {
229+
\SessionManager::sessionStart('login', 604800, 0);
230+
$_SESSION['aid'] = $aid;
239231
return true;
240232
}
241233
return false;
@@ -332,19 +324,13 @@ public function AddAdmin($name, $steam, $password, $email, $web_group, $web_flag
332324
throw new RuntimeException('Password must be at least ' . MIN_PASS_LENGTH . ' characters long.');
333325
}
334326
if (empty($password)) {
335-
// Silently generate a token for account if there is no password set
336-
// the token is required in Steam OAuth routines.
337-
// Due to ugly codebase and lack of migrations we store the token as password hash.
338-
// Also we use a prefix here to prevent any possible collisions with `encrypt_password` implementation.
339-
$password_hash = '$token$' . $this->random_string();
340-
} else {
341-
$password_hash = $this->hash($password);
327+
throw new RuntimeException('Password must not be empty!');
342328
}
343329
$this->dbh->query('INSERT INTO `:prefix_admins` (user, authid, password, gid, email, extraflags, immunity, srv_group, srv_flags, srv_password)
344330
VALUES (:user, :authid, :password, :gid, :email, :extraflags, :immunity, :srv_group, :srv_flags, :srv_password)');
345331
$this->dbh->bind(':user', $name);
346332
$this->dbh->bind(':authid', $steam);
347-
$this->dbh->bind(':password', $password_hash);
333+
$this->dbh->bind(':password', password_hash($password, PASSWORD_BCRYPT));
348334
$this->dbh->bind(':gid', $web_group);
349335
$this->dbh->bind(':email', $email);
350336
$this->dbh->bind(':extraflags', $web_flags);

0 commit comments

Comments
 (0)