Author Topic: ULib MySQLOO Authentication  (Read 7100 times)

0 Members and 1 Guest are viewing this topic.

Offline Unknown Gamer

  • Jr. Member
  • **
  • Posts: 79
  • Karma: -2
    • TrueKnife TTT
ULib MySQLOO Authentication
« on: June 15, 2016, 07:43:11 PM »
Quote from: MrPresident link=topic=8377.msg29250#msg29250
What This Is
This is a replacement for ULib's UCL storage system. The current system saves and reads all stored users and their accesses from a single text file. This works fine, unless you have multiple servers or a LOT of information in that file.

What This Does
This overrides the Save and Load functions in UCL. Instead of loading and saving your users to the users.txt file, it will instead load and save them from a database.


What This Doesn't Do
This only handles users. It doesn't store groups or group permissions. Those are still going to be stored in the groups.txt
This doesn't handle banning. There are plenty of MySQL banning modules out there.

What Is Modified
You will need to *replace* your ucl.lua file in addons\ULib\lua\ulib\server\ucl.lua
We typically NEVER recommend that you replace any of our stock files as this could cause issues or the changes will be reverted the next time you update ULib.. However, due to the nature of this kind of modification simply writing it into an addon wouldn't work because of the way modules are loaded. If you choose to install this, I HIGHLY recommend making a backup of your ULib addon first.
Inside the ucl.lua file I added some MySQL functions. I also modified the SaveFile function as well as completely commented out the LoadFromFile function. I also slightly modified addUser and removeUser functions.

How To Install
1. Install the MySQLoo module. If you don't know where/how to get this I suggest Google.
2. Download the copy of ucl.lua from this post (YOU NEED TO BE LOGGED IN TO SEE IT)
3. Replace Addons\ULib\lua\server\ucl.lua with the one I provided.
4. Create a database in your MySQL called 'ulibsql' and set up a user to have permissions for it. (Don't create any tables inside of it, my code will handle that)
5. Edit the information at the top of the file to suit your MySQL database.
6. To be sure the table generated: run 'lua_run ULib_SQL_CreateTable()' from your server console.
7. From your server console or in game (if you are a superadmin) run ulib_loadlegacy to load your users from your users.txt and load them into your database.

WARNING/CAUTION
This is ONLY for people who know how to use the MySQLOO module. I will not provide support for getting that installed or configured.
This is not for server owners who do not know enough about lua or modifying files to at least edit the SQL configuration at the top of the file.
If you update ULib this modification will be lost and you'll have to reinstall it.
This comes as-is and while I did to testing, there is no way for me to know if it'll work in every situation. Please make a backup of your ULib files before installing this.

Help/Support
I am not going to help you install MySQLOO.
If you have MySQLOO installed and configured properly and are having trouble with this modification, please feel free to post here and I will try and assist you the best I can.

syl0r and I fixed the module up a bit, along with Freddy adding backwards support for the MySQLOO v9 other modules that used the old system this used. MrPresident is fine with you guys modifying and updating the code on the github page listed below.

https://github.com/MrUnknownGamer/ULib-MySQLOO
« Last Edit: June 16, 2016, 07:33:26 PM by Unknown Gamer »
Newb Coder. Soon to get better

Offline MrPresident

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 2728
  • Karma: 430
    • |G4P| Gman4President
Re: ULib MySQLOO Authentication
« Reply #1 on: June 15, 2016, 08:44:52 PM »
Thanks for posting updated code.

Offline JustPlayer

  • Newbie
  • *
  • Posts: 1
  • Karma: 0
Re: ULib MySQLOO Authentication
« Reply #2 on: June 21, 2016, 01:24:33 PM »
And it's clean (no known backdoor/server takeover)
:)

Offline MrPresident

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 2728
  • Karma: 430
    • |G4P| Gman4President
Re: ULib MySQLOO Authentication
« Reply #3 on: June 21, 2016, 04:34:28 PM »
Did my original code have something like that, or were you just stating that the code he posted didn't have anything added? :P

Offline kulcris

  • Newbie
  • *
  • Posts: 28
  • Karma: 0
Re: ULib MySQLOO Authentication
« Reply #4 on: July 31, 2016, 12:43:40 PM »
not sure if it is just me but it seems like the data is not properly being loaded from the database. i change a user to superadmin and they get demoted back to admin on join. but the information updates in the database as im doing it, i deleted the users.txt file thinking maybe it was still reading from tehre

Offline kulcris

  • Newbie
  • *
  • Posts: 28
  • Karma: 0
Re: ULib MySQLOO Authentication
« Reply #5 on: July 31, 2016, 01:03:10 PM »
ffs,,,, was fadmin things up nvm

Offline Bite That Apple

  • Hero Member
  • *****
  • Posts: 858
  • Karma: 416
  • Apple Innovations 2010®
    • Fun 4 Everyone Gaming
Re: ULib MySQLOO Authentication
« Reply #6 on: August 03, 2016, 02:06:17 AM »
ffs,,,, was fadmin <censor> things up nvm

Not sure, you know what JamminR always says.
Quote
If it doesn't work the first time, remove everything try again on a bare server. If it works, then something else is colliding with it.

As I recall, FAdmin is not offically supported by ULX, FAdmin did that on their own.
Quote from: John F. Kennedy 1963
A man may die, nations may rise and fall, but an idea lives on.

Offline Belly136

  • Newbie
  • *
  • Posts: 33
  • Karma: -2
Re: ULib MySQLOO Authentication
« Reply #7 on: September 03, 2016, 04:55:41 AM »
Can you add tmysql4 support? I have over 1600 users and sometimes ulx doesn't import anything.
« Last Edit: September 03, 2016, 05:00:48 AM by Belly136 »

Offline EdyTheCow

  • Newbie
  • *
  • Posts: 3
  • Karma: 0
Re: ULib MySQLOO Authentication
« Reply #8 on: November 10, 2016, 08:41:46 AM »
What if this ran by multiple servers and one of servers doesn't have a specific group user is part of in the database? Is user defaulted to default rank? If so, does ulib make the change in the database?

I know this is pretty silly question, was just curious what would happen.
« Last Edit: November 10, 2016, 08:52:37 AM by EdyTheCow »

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: ULib MySQLOO Authentication
« Reply #9 on: November 10, 2016, 02:51:54 PM »
Can't speak as to this addon, but default ULib makes NO changes to anyone in the default group, which in gmod, is "user".

EDIT -
EdyTheCow, split/ moved your next question to the help and support - it's a good question I don't know myself (and am too lazy to go test it or examine our code for handling) - https://forums.ulyssesmod.net/index.php/topic,10036.0.html

It's not on topic for this release thread, but is a decent question.
« Last Edit: November 11, 2016, 06:51:49 PM by JamminR »
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming