What's new

[PAID] Mojito Auth V2 | Lua remote code loading and IP Authentication

Mojito

Bronze Elite
Joined
Mar 27, 2021
Messages
6
Reaction score
7
Points
146
Gone
 
Last edited:

Zan1456

Zan#1456
VIP
Joined
Mar 19, 2021
Messages
788
Solutions
5
Reaction score
66,114
Points
421
Location
Hungary
Website
vfivem.com
Mojito Auth



NodeJS authentication server for remote loading and IP restricting fivem resources. Using Express JS for the REST API and Discord.js for logging and whitelisting.



Usage



The usage has been simplified in the v2 update, only adding new files to the system needs to be done manually. For this example I will use a resources called "mojito_auth".


First add an empty array to the database.json as follows

Code:
{
    "mojito_auth-server": []
}

Then, place your file in the ./scripts directory i.e. ./scripts/mojito_auth-server.lua

Note that this file can be obfuscated or left in source code form


To access within a script you need to use a HTTP request as follows:

Code:
-- Perform request to IP and port of the auth server with the resource name as a query
PerformHttpRequest("http://127.0.0.1:3000/?script=mojito_auth-server"), function(err, data, headers)
    if data then
        -- if data is returned we run the code
        local loading = load or loadstring
        loading(data)()
    else
        -- if the user is not authorised the code is not sent and you can print a message or do whatever
        print("YOU ARE NOT AUTHORISED TO USE THIS SCRIPT")
    end
end, "GET")

If you wish to remote load a client file you can use a callback or some event handlers
Code:
-- client
TriggerCallback("grab-code", function(data)
        local loading = load or loadstring
        loading(data)()
end)
-- server
CreateCallback("grab-code", function(source, cb)
    PerformHttpRequest("http://127.0.0.1:3000/?script=mojito_auth-server"), function(err, data, headers)
        if data then
            cb(data)
        end
    end, "GET")
end)

To whitelist an IP address for a script, create a .env file containing your discord bot token and prefix i.e.

Code:
TOKEN=                              [BOT Token]

CLIENT_ID=                          [Bot's Client ID]

GUILD_ID=                           [Discord Guild / Server ID]

WEBHOOK=                            [Full Webhook URL]

PERMISSION_ROLE=                    [ID of the Required Role]

Use the command /authorise and follow the prompts to whitelist an IP for a product

WegsjaY.png


and /deauthorise to remove an IP address from the whitelist for a script

IcyELVp.png



Webhook Logging:

kC0djm1.png
WFqJJGS.png


v2.0 update:

- Refactor to discord.js v13

- Fixed issue with unauthorised players recieving false as a string

- Code Cleanup and Easier Useage

 

Attachments

  • IMG_20220123_081435.jpg
    IMG_20220123_081435.jpg
    38 KB · Views: 61

Luauth

Member
Joined
Mar 20, 2024
Messages
4
Reaction score
0
Points
16
Location
DE
if anyone looking for the same idea but crack proof check luauth.io
 
Top