Post: Server-sided auth code using keys (Elite or custom licensing)
01-25-2016, 03:22 AM #1
Tustin
Balls of Steel
(adsbygoogle = window.adsbygoogle || []).push({}); Sup?

I wrote this code for The Tesseract re-release but that never happened, so here we are. I had also originally posted this in the Gaming Squad section, but I figured it could be useful for everyone. You can use this code to either authenticate your app for Elite or using a custom key system - it's all up to you. The example uses Elite auth by default but you can change it pretty easily by just getting rid of the validate_elite_key function call. Follow the steps below for installing this on your server.

Prerequisites:

  • A server
  • A web server installed (nginx, apache2, it doesn't matter)
  • MySQL installed
  • PHP installed
  • Root login info for MySQL


How to setup:

  1. Download zip and extract contents to a location on your PC
  2. Open up 'autoload.php' and add a name for the DATABASE_NAME constant at the top.
  3. In the same file, add the credentials for your MySQL login. This user should have permissions to create tables and databases (so ideally use root)
  4. Save file, and upload all the files to a directory on your server.
  5. Go to the directory in your browser and load the setup.php script first.
  6. If you used proper MySQL credentials, it will successfully create both a database and two tables in said database.
  7. DELETE setup.php from your server
  8. Create a new MySQL user with only the required permissions (SELECT, INSERT, UPDATE, etc) and replace your root user's credentials inside `autoload.php` with this new MySQL user information (thanks to JB for catching this error)
  9. To test, access auth.php with a GET request for key using your NGU Elite key (example: You must login or register to view this content.)
  10. If the setup worked properly, it should output "Some useful information" (hilarious, right?) and if you check your log and users table, you should see your Elite key there.


It's a basic system for getting your app up and running. However this does do automatic banning for users who share multiple keys under so many different IPs in a certain period of time (like 24 hrs I think). The ban check is done each time the auth script executes, so unless your app gets little to no traffic, it should do just fine. If you really want you can setup a cron job to run the unban/ban process every so often.

You must login or register to view this content.

Enjoy and let me know if you have any issues or just need help with it.

The following 27 users say thank you to Tustin for this useful post:

BaSs_HaXoR, BaumHF1, Sabotage, Discrepancy, Egzec, endojunky, Father Luckeyy, Frosty, Geo, Kam, Kronos, Kryptus, JokerRey, Norway-_-1999, Darth Saul, Pink Guy, ProfoundModz, Rath, Adrian, Sloth, Specter, Swaqq, Wu., xK ELITE GaminG
12-27-2017, 01:29 AM #20
I need help coding this into the sprx, it always freezes for me
01-09-2018, 06:18 PM #21
How would u add login system for like website
01-15-2018, 02:48 AM #22
Algebra
[move]mov eax, 69[/move]
Originally posted by sparbymodzdev View Post
How would u add login system for like website


I would suggest making your own login system then given keys to users even sort out a subscription handler. Some of the functions in this are used for demonstration purposes then again I could be wrong.
05-17-2018, 08:23 PM #23
hi can you help me when i open setup.php :
ERROR occurred when creating database '' - 42000 (maybe MySQL user doesn't have sufficent permissions?)
ERROR occurred when creating table 'users' - 3D000
ERROR occurred when creating table 'log' - 3D000
Completed operations.

The user is root and have all privileges
05-18-2018, 12:48 PM #24
Algebra
[move]mov eax, 69[/move]
Originally posted by SXSXMODS View Post
hi can you help me when i open setup.php :
ERROR occurred when creating database '' - 42000 (maybe MySQL user doesn't have sufficent permissions?)
ERROR occurred when creating table 'users' - 3D000
ERROR occurred when creating table 'log' - 3D000
Completed operations.

The user is root and have all privileges


What storage engine are you using for your DBMS.

Copyright © 2024, NextGenUpdate.
All Rights Reserved.

Gray NextGenUpdate Logo