Database integration, permissions and custom routes in plugin

Plugin Development
  • I'll define my requirements in the form of conversation.

    • A link will be generated and given to the user within Minecraft.
    • The user can click this link, and if the user is authenticated and has the necessary permissions, then he/she can link their in-game Minecraft account with their forum account.

    I understand how to achieve this, my concern is getting the data and specifying custom routes and permissions.

  • Using only the currently logged in nodebb user and minecraft player.

    Two routes needed:

    • Server-only route: POST route. Requires a unique key parameter. Only the forum and the minecraft server know the key. e.g. /mc/link?key=key
    • User route: GET route. Used to link accounts, requires a UUID and a unique player key. e.g. /mc/link/:uuid/:key

    Minimum two DB keys need:

    • {uuid}:key String key, stores the unique player key for the UUID. (Could also be a hash to store additional data.)
    • user:{uid}:uuid String key, stores the UUID linked to the user. (Could also be stored on the user hash, or made into a set for multiple linkings.)

    Process:

    https://www.lucidchart.com/documents/view/382333e7-c772-43b7-8061-57b3bbd83e97

    • Minecraft player types a command.
    • Server users server-only route to tell the forum it needs a registration link. Sending the unique key to verify the request is valid.
    • Forum creates a unique player key and stores it in the DB, then sends the player key to the server.
    • Server gives a link to the player, using the unique player key and the players' UUID.
    • User visits link, if the user is logged in, and the uuid-key pair matches what is already in the DB, then the accounts are linked, using additional DB entries.
    • The player key is deleted.

    Concerns:

    • The player key should expire relatively quickly, like 5 minutes.
    • Invalid requests to the user route should be monitored and blocked after a low threshold, like 3 tries.
    • NodeBB middleware already validates the logged in user, which is why we do no additional checks.

    Note:

    On the last line in the diagram, I send a confirmation message, but we can't actually do this because we have not established a persistent connection. You could solve this by either having an http server on the server, or creating a socket connection to the forum.



    Or you could use Minecraft-Integration 😉


Suggested Topics


  • 0 Votes
    1 Posts
    253 Views

    Hi!

    I wrote a plugin for OpenLDAP.
    It overrides the default login and falls back to local login if the user is not found in LDAP.
    It also creates all groups found in LDAP and automatically joins the user into them.
    Using it as an alternative login is not implemented as I couldn't figure it out quick enough. It should be easy to do - feel free to add a pull request.

    The source is on github. Pull requests are welcome!
    Please be kind, my JavaScript skills are limited.

  • 5 Votes
    5 Posts
    1k Views

    @psychobunny Pinging you since this is a fork of your plugin for paypal.

    Ok so, Update 1:
    Removed the function onload wrapper. Still same problem as above, however step closer, Now clicking the navigation once more loads the GET files. But doesnt do it on initial visit from navmenu.

    I guess a quick fix would be to just have it refresh or reload page when visiting it, but that isnt good i dont think.

    UPDATE 2: SOLVED.. Nevermind its not solved. Some times it works some times theres a delay and still never gets sent..

    Found another bug.. You may call me the bug hunter. 😄
    https://github.com/edthefifth/nodebb-plugin-stripe-subscriptions/blob/master/library.js line 90 - Getting an error i assume due to the template not entirely sure about this one.

    ajaxify.js in console brings up the following..
    7f8febd0-20fd-4704-b9dd-2b783675586d-image.png

    So if you're subscribed, then go back to visit the Subscribe link in navmenu, the loading bar will continue to spin but not load or /redirect you. Unless you refresh.

  • 0 Votes
    14 Posts
    3k Views

    @baris
    no, just I got an empty pull down menu when I clicked Topic Tools.

    Today I tried again, and got the pull down popolated.

    Strange....

  • 0 Votes
    7 Posts
    2k Views

    Gamification is a great boost for communities that aren't very active, even though it's forced. Many of the bbs communities I'm involved with rely on this.I will try to fix the point-ns, not now though.

  • 0 Votes
    3 Posts
    2k Views

    Thanks a lot. This should save me loads of time! 🙂