├── .github
└── FUNDING.yml
├── .poggit.yml
├── CONTRIBUTING.md
├── LICENSE
├── README.md
├── ServerAuth
├── plugin.yml
├── resources
│ ├── config.yml
│ └── languages
│ │ ├── CZ_cz.yml
│ │ ├── EN_en.yml
│ │ ├── ES_es.yml
│ │ ├── IT_it.yml
│ │ ├── NL_nl.yml
│ │ ├── PT_br.yml
│ │ ├── RU_ru.yml
│ │ ├── TR_tr.yml
│ │ └── ja_JP.yml
└── src
│ └── ServerAuth
│ ├── Commands
│ ├── ChangePassword.php
│ ├── Commands.php
│ ├── Login.php
│ ├── Logout.php
│ ├── Register.php
│ ├── ServerAuthCommand.php
│ ├── ServerAuthCommandHandler.php
│ └── Unregister.php
│ ├── EventListener.php
│ ├── Events
│ ├── ServerAuthAuthenticateEvent.php
│ ├── ServerAuthChangePasswordEvent.php
│ ├── ServerAuthDeauthenticateEvent.php
│ ├── ServerAuthEvent.php
│ ├── ServerAuthLoadPluginEvent.php
│ ├── ServerAuthRegisterEvent.php
│ └── ServerAuthUnregisterEvent.php
│ ├── HashAlgs
│ ├── DefaultHash.php
│ ├── DefaultHashSalted.php
│ ├── HashAlg.php
│ └── SimpleAuthHash.php
│ ├── Importers
│ ├── HereAuthJSONImporter.php
│ ├── HereAuthMySQLImporter.php
│ ├── Importer.php
│ ├── ServerAuthMySQLImporter.php
│ ├── ServerAuthSQLiteImporter.php
│ ├── ServerAuthYAMLImporter.php
│ ├── SimpleAuthMySQLImporter.php
│ ├── SimpleAuthSQLiteImporter.php
│ └── SimpleAuthYAMLImporter.php
│ ├── Providers
│ ├── MySQLProvider.php
│ ├── Provider.php
│ ├── SQLiteProvider.php
│ └── YAMLProvider.php
│ ├── ServerAuth.php
│ └── Tasks
│ ├── MessageTask.php
│ └── MySQLTask.php
├── ServerAuthAccountManager
├── ServerAuthWebAPI.php
├── account.php
├── admin.php
├── config.php
├── css
│ ├── font-awesome.css
│ ├── font-awesome.min.css
│ ├── xweb.css
│ └── xweb.min.css
├── fonts
│ ├── fontawesome-webfont.eot
│ ├── fontawesome-webfont.svg
│ ├── fontawesome-webfont.ttf
│ └── fontawesome-webfont.woff
├── index.php
├── js
│ ├── jquery.min.js
│ ├── xweb.js
│ └── xweb.min.js
├── login.php
└── register.php
└── ServerAuthWebAPI
└── ServerAuthWebAPI.php
/.github/FUNDING.yml:
--------------------------------------------------------------------------------
1 | custom: "https://paypal.me/Flavius12"
2 |
--------------------------------------------------------------------------------
/.poggit.yml:
--------------------------------------------------------------------------------
1 | --- # Poggit-CI Manifest. Open the CI at https://poggit.pmmp.io/ci/EvolSoft/ServerAuth
2 | branches:
3 | - master
4 | projects:
5 | ServerAuth:
6 | path: ServerAuth/
7 | ...
8 |
--------------------------------------------------------------------------------
/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | 
2 |
3 | # Contributing to ServerAuth
4 |
5 | First of all thank you to contribute and help us to improve our projects.
6 |
7 | ## Issues
8 |
9 | If you want to report bugs or suggestions use the [Issue Tracker](https://github.com/EvolSoft/ServerAuth/issues)
10 |
11 | - Please **don't** duplicate issues. Do a small search on current issues before report yours
12 | - Please provide as more detailed informations as you can about the issue
13 | - Please **don't** post issues related to unofficial source code
14 | - Please **don't** post fake or support issues
15 | - Please write in English
16 |
17 | ## Code contributions
18 |
19 | If you want to contribute on code simply do a [Pull Request](https://github.com/EvolSoft/ServerAuth/pull/new). Before doing this **be sure** that:
20 | - The code is correct, clear and written in English
21 | - You provided a good and descriptive title
22 | - The Pull Request doesn't already exist
23 |
24 | ## Translation contributions
25 |
26 | If you want to contribute on translations make a [Pull Request](https://github.com/EvolSoft/ServerAuth/pull/new).
27 |
28 | Remember that your translation file **must** follow the default ServerAuth language file structure
29 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2015 EvolSoft
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
23 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | 
2 |
3 | **THE PLUGIN IS NOT READY TO BE USED YET. IT HAS NOT BEEN TESTED CAREFULLY AND IT STILL CONTAINS LOTS OF BUGS! PLEASE WAIT THE OFFICIAL RELEASE ON POGGIT!**
4 |
5 | # ServerAuth
6 |
7 | [](https://gitter.im/EvolSoft/ServerAuth?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
8 |
9 | An advanced authentication plugin for PocketMine
10 |
11 | [](http://gestyy.com/er3ftX)
12 |
13 | ## Category
14 |
15 | PocketMine-MP plugins, PHP Web scripts
16 |
17 | ## Requirements
18 |
19 | [PocketMine-MP](https://github.com/pmmp/PocketMine-MP) API 3.0.0-ALPHA7 - 3.0.0-ALPHA8
20 | PHP >= 5.4.0 *(for ServerAuthAccountManager)*
21 | PHP MySQLi extension
22 |
23 | ## Overview
24 |
25 | **ServerAuth** is the most advanced authentication system for PocketMine-MP.
26 |
27 | ***This Plugin uses the New API. You can't install it on old versions of PocketMine.***
28 |
29 | ***To prevent bugs, delete all old plugin data if you are updating ServerAuth.***
30 |
31 | ***WARNING: If you're updating from old versions of ServerAuth to ServerAuth v2.12 or newer you MAY NEED to delete the current language folder!!!***
32 |
33 | ***Features:***
34 |
35 | - MySQL support
36 | - Multi-language support
37 | - Web API
38 | - Online Account Manager
39 | - IP Sessions
40 | - /register, /unregister, /login, /logout and /changepassword commands
41 |
42 | And more...
43 |
44 | **What is included?**
45 |
46 | In the ZIP file you will find:
47 | *- ServerAuth_v2.13.phar : ServerAuth Plugin + API*
48 | *- ServerAuthAccountManager : An advanced online script to manage ServerAuth accounts*
49 | *- ServerAuthWebAPI : ServerAuth Web API to use on your own web scripts*
50 |
51 | **Commands:**
52 |
53 | ***/serverauth*** *- ServerAuth commands (aliases: [sa, sauth, auth])*
54 | ***/register*** *- Allows registering an account (aliases: [reg])*
55 | ***/login*** *- Allows logging into an account*
56 | ***/changepassword*** *- Allows changing account password (aliases: [ch, chp, chpass])*
57 | ***/unregister*** *- Allows unregistering an account*
58 | ***/logout*** *- Allows to do the log out*
59 |
60 | ***To-Do:***
61 |
62 |
ServerAuth Account Manager v1.0.
233 |© 2015 EvolSoft. Licensed under MIT.
234 |ServerAuth Account Manager is a simple web script that let you to fully manage your ServerAuth accounts.
With ServerAuth Account Manager you can:
ServerAuth Account Manager is a simple web script that let you to fully manage your ServerAuth accounts.
With ServerAuth Account Manager you can:
ServerAuth Account Manager v1.0. Register an account"; } ?>
72 |© 2015 EvolSoft. Licensed under MIT.
73 |ServerAuth Account Manager v1.0. Register an account"; } ?>
126 |© 2015 EvolSoft. Licensed under MIT.
127 |ServerAuth Account Manager v1.0.
181 |© 2015 EvolSoft. Licensed under MIT.
182 | 183 | 184 | 185 | 186 | -------------------------------------------------------------------------------- /ServerAuthWebAPI/ServerAuthWebAPI.php: -------------------------------------------------------------------------------- 1 | host = $host; 74 | $this->port = $port; 75 | $this->username = $username; 76 | $this->password = $password; 77 | $this->dbname = $database; 78 | $this->table_prefix = $table_prefix; 79 | $this->database = @new \mysqli($host, $username, $password, $database, $port); 80 | if($this->database->connect_error){ 81 | $this->status = ServerAuthWebAPI::ERR_MYSQL; 82 | }else{ 83 | $query = "SELECT api_version, version, password_hash FROM " . $table_prefix . "serverauth LIMIT 1"; 84 | if($this->database->query($query)){ 85 | $this->api_version = $this->getDatabase()->query($query)->fetch_assoc()["api_version"]; 86 | $this->version = $this->getDatabase()->query($query)->fetch_assoc()["version"]; 87 | $this->password_hash = $this->getDatabase()->query($query)->fetch_assoc()["password_hash"]; 88 | if($this->api_version > ServerAuthWebAPI::CURRENT_API){ 89 | $this->status = ServerAuthWebAPI::ERR_OUTDATED_WEBAPI; 90 | }elseif($this->api_version < ServerAuthWebAPI::CURRENT_API){ 91 | $this->status = ServerAuthWebAPI::ERR_OUTDATED_PLUGIN; 92 | }else{ 93 | $this->status = ServerAuthWebAPI::SUCCESS; 94 | } 95 | }else{ 96 | $this->status = ServerAuthWebAPI::ERR_MYSQL; 97 | } 98 | } 99 | } 100 | 101 | /** 102 | * Get the current ServerAuthWebAPI instance status 103 | * 104 | * @return int (SUCCESS|ERR_OUTDATED_WEBAPI|ERR_OUTDATED_PLUGIN|ERR_MYSQL) 105 | */ 106 | public function getStatus(){ 107 | return $this->status; 108 | } 109 | 110 | /** 111 | * Get ServerAuth plugin version 112 | * 113 | * @return string|int the current version string on SUCCESS, otherwise the current status 114 | */ 115 | public function getVersion(){ 116 | if($this->getStatus() == ServerAuthWebAPI::SUCCESS){ 117 | return $this->version; 118 | }else{ 119 | return $this->getStatus(); 120 | } 121 | } 122 | 123 | /** 124 | * Get ServerAuth plugin API version 125 | * 126 | * @return string|int the current API version string on SUCCESS, otherwise the current status 127 | */ 128 | public function getAPIVersion(){ 129 | if($this->getStatus() == ServerAuthWebAPI::SUCCESS){ 130 | return $this->api_version; 131 | }else{ 132 | return $this->getStatus(); 133 | } 134 | } 135 | 136 | /** 137 | * Get ServerAuthWebAPI version 138 | * 139 | * @return string 140 | */ 141 | public static function getWebAPIVersion(){ 142 | return ServerAuthWebAPI::WEBAPI_VERSION; 143 | } 144 | 145 | /** 146 | * Get ServerAuth password hash 147 | * 148 | * @return string 149 | */ 150 | public function getPasswordHash(){ 151 | return $this->password_hash; 152 | } 153 | 154 | /** 155 | * Get MySQL host 156 | * 157 | * @return string 158 | */ 159 | public function getHost(){ 160 | return $this->host; 161 | } 162 | 163 | /** 164 | * Get MySQL port 165 | * 166 | * @return int 167 | */ 168 | public function getPort(){ 169 | return $this->port; 170 | } 171 | 172 | /** 173 | * Get MySQL username 174 | * 175 | * @return string 176 | */ 177 | public function getUsername(){ 178 | return $this->username; 179 | } 180 | 181 | /** 182 | * Get MySQL password 183 | * 184 | * @return string 185 | */ 186 | public function getPassword(){ 187 | return $this->password; 188 | } 189 | 190 | /** 191 | * Get MySQL ServerAuth database name 192 | * 193 | * @return string 194 | */ 195 | public function getDatabaseName(){ 196 | return $this->dbname; 197 | } 198 | 199 | /** 200 | * Get ServerAuth MySQL table prefix 201 | * 202 | * @return string 203 | */ 204 | public function getTablePrefix(){ 205 | return $this->table_prefix; 206 | } 207 | 208 | /** 209 | * Get the current MySQL database instance 210 | * 211 | * @return mysqli|boolean 212 | */ 213 | public function getDatabase(){ 214 | if($this->database instanceof \mysqli){ 215 | return $this->database; 216 | }else{ 217 | return false; 218 | } 219 | } 220 | 221 | /** 222 | * Check if a player is registered to ServerAuth 223 | * 224 | * @param string $player 225 | * 226 | * @return boolean|int true or false on SUCCESS, otherwise the current status 227 | */ 228 | public function isPlayerRegistered($player){ 229 | if($this->getStatus() == ServerAuthWebAPI::SUCCESS){ 230 | //Check MySQL connection 231 | if($this->getDatabase() && $this->getDatabase()->ping()){ 232 | $stmt = $this->getDatabase()->prepare("SELECT user, password, ip, firstlogin, lastlogin FROM " . $this->getTablePrefix() . "serverauthdata WHERE user=?"); 233 | $stmt_player = strtolower($player); 234 | $stmt->bind_param("s", $stmt_player); 235 | $stmt->execute(); 236 | $stmt->store_result(); 237 | if($stmt->num_rows == 0){ 238 | $stmt->close(); 239 | return false; 240 | }else{ 241 | $stmt->close(); 242 | return true; 243 | } 244 | }else{ 245 | return ServerAuthWebAPI::ERR_MYSQL; 246 | } 247 | }else{ 248 | return $this->getStatus(); 249 | } 250 | } 251 | 252 | /** 253 | * Get player data 254 | * 255 | * @param string $player 256 | * 257 | * @return array|int the array of player data on SUCCESS, otherwise the current status 258 | */ 259 | public function getPlayerData($player){ 260 | if($this->getStatus() == ServerAuthWebAPI::SUCCESS){ 261 | if($this->isPlayerRegistered($player)){ 262 | //Check MySQL connection 263 | if($this->getDatabase() && $this->getDatabase()->ping()){ 264 | $stmt = $this->getDatabase()->prepare("SELECT user, password, ip, firstlogin, lastlogin FROM " . $this->getTablePrefix() . "serverauthdata WHERE user=?"); 265 | $stmt_player = strtolower($player); 266 | $stmt->bind_param("s", $stmt_player); 267 | if($stmt->execute()){ 268 | $stmt->bind_result($user, $password, $ip, $firstlogin, $lastlogin); 269 | $stmt->fetch(); 270 | $data = array( 271 | "password" => $password, 272 | "ip" => $ip, 273 | "firstlogin" => $firstlogin, 274 | "lastlogin" => $lastlogin 275 | ); 276 | $stmt->close(); 277 | return $data; 278 | }else{ 279 | $stmt->close(); 280 | return ServerAuthWebAPI::ERR_GENERIC; 281 | } 282 | }else{ 283 | return ServerAuthWebAPI::ERR_GENERIC; 284 | } 285 | }else{ 286 | return $this->isPlayerRegistered($player); 287 | } 288 | }else{ 289 | return $this->getStatus(); 290 | } 291 | } 292 | 293 | /** 294 | * Register a player to ServerAuth 295 | * 296 | * @param string $player 297 | * @param string $password 298 | * @param string $ip 299 | * @param int|double $firstlogin (UNIX timestamp) 300 | * @param int|double $lastlogin (UNIX timestamp) 301 | * 302 | * @return int|boolean true on SUCCESS or false if the player is already registered, otherwise the current status 303 | */ 304 | public function registerPlayer($player, $password, $ip, $firstlogin, $lastlogin){ 305 | if($this->getStatus() == ServerAuthWebAPI::SUCCESS){ 306 | if(!$this->isPlayerRegistered($player)){ 307 | //Check MySQL connection 308 | if($this->getDatabase() && $this->getDatabase()->ping()){ 309 | $stmt = $this->getDatabase()->prepare("INSERT INTO " . $this->getTablePrefix() . "serverauthdata (user, password, ip, firstlogin, lastlogin) VALUES (?, ?, ?, ?, ?)"); 310 | $password = hash($this->getPasswordHash(), $password); 311 | $stmt->bind_param("sssss", $player, $password, $ip, $firstlogin, $lastlogin); 312 | if($stmt->execute()){ 313 | $stmt->close(); 314 | return ServerAuthWebAPI::SUCCESS; 315 | }else{ 316 | $stmt->close(); 317 | return ServerAuthWebAPI::ERR_MYSQL; 318 | } 319 | }else{ 320 | return ServerAuthWebAPI::ERR_MYSQL; 321 | } 322 | }else{ 323 | return $this->isPlayerRegistered($player); 324 | } 325 | }else{ 326 | return $this->getStatus(); 327 | } 328 | } 329 | 330 | /** 331 | * Unregister a player 332 | * 333 | * @param string $player 334 | * 335 | * @return int|boolean true on SUCCESS or false if the player is not registered, otherwise the current status 336 | */ 337 | public function unregisterPlayer($player){ 338 | if($this->getStatus() == ServerAuthWebAPI::SUCCESS){ 339 | if($this->isPlayerRegistered($player)){ 340 | //Check MySQL connection 341 | if($this->getDatabase() && $this->getDatabase()->ping()){ 342 | $stmt = $this->getDatabase()->prepare("DELETE FROM " . $this->getTablePrefix() . "serverauthdata WHERE user=?"); 343 | $stmt_player = strtolower($player); 344 | $stmt->bind_param("s", $stmt_player); 345 | if($stmt->execute()){ 346 | $stmt->close(); 347 | return ServerAuthWebAPI::SUCCESS; 348 | }else{ 349 | $stmt->close(); 350 | return ServerAuthWebAPI::ERR_MYSQL; 351 | } 352 | }else{ 353 | return ServerAuthWebAPI::ERR_MYSQL; 354 | } 355 | }else{ 356 | return $this->isPlayerRegistered($player); 357 | } 358 | }else{ 359 | return $this->getStatus(); 360 | } 361 | } 362 | 363 | /** 364 | * Change player password 365 | * 366 | * @param string $player 367 | * @param string $new_password 368 | * 369 | * @return int|boolean true on SUCCESS or false if the player is not registered, otherwise the current status 370 | */ 371 | public function changePlayerPassword($player, $new_password){ 372 | if($this->getStatus() == ServerAuthWebAPI::SUCCESS){ 373 | if($this->isPlayerRegistered($player)){ 374 | //Check MySQL connection 375 | if($this->getDatabase() && $this->getDatabase()->ping()){ 376 | $stmt = $this->getDatabase()->prepare("UPDATE " . $this->getTablePrefix() . "serverauthdata SET password=? WHERE user=?"); 377 | $stmt_password = hash($this->getPasswordHash(), $new_password); 378 | $stmt_player = strtolower($player); 379 | $stmt->bind_param("ss", $stmt_password, $stmt_player); 380 | if($stmt->execute()){ 381 | $stmt->close(); 382 | return ServerAuthWebAPI::SUCCESS; 383 | }else{ 384 | $stmt->close(); 385 | return ServerAuthWebAPI::ERR_MYSQL; 386 | } 387 | } 388 | }else{ 389 | return $this->isPlayerRegistered($player); 390 | } 391 | }else{ 392 | return $this->getStatus(); 393 | } 394 | } 395 | } 396 | --------------------------------------------------------------------------------