I'm working on the authentication scheme for a multiplayer game using only C++ and SLD2.

It's an RPG with a kind of complicated character-group/permadeath scheme, and world-instances are intended to be hosted by the players. So it matters that players have exclusive access to controlling their characters. I want players to be allowed to save the current state of a multiplayer world instance, close it, and come back to it later, or set up their own dedicated world instance for them and their friends to join/quit/rejoin at will. Absent player characters will simply not be present in the world until their creator returns

Servers will be hosted by player-computers. I'm not planning to set this up with a dedicated hole-punching or identity server, so players will just be playing with people who they intentionally connect to. I don't want to deal with encryption, so I'm not planning to require passwords to log in. I figure since there's no formal identity server and no encryption, passwords might do more harm than good. Player character names will change over the course of the game, and I don't necessarily mind if two players have the same username.

Here's my current authentication strategy:

When a player creates an account on his/her game instance, the account will just consist of a username and an automatically generated (random) UUID. The username and UUID will be stored in a SQLite file that the user can copy onto any computer with this game installed, and access their unique account. The username and a naively hashed UUID will be stored in a connection log on every server that the player connects to (so the server can assign them to the right character when they log back in). I recognize this means that programmers who know what they're doing will be able to hack each other's accounts, but I'm not convinced that I should really be concerned about that in the case of this particular game.

Here are my questions:

  • Is copying the file too much to expect from users who want to switch computers?
  • Can you guys think of any potential issues with this, other than what I've already pointed out?
  • Is there a better (common) way to achieve what I'm trying to do?



Is copying the file too much to expect from users who want to switch computers?

Not really. Well, it could be for younger less tech savvy players. Regardless, you want to make it easy. The user might not know what files to copy or where to find them. Have an export and import feature.

If I understand correctly, this is not only for the world, but also for the characters. That is, I would move my character to a different machine.

It could be a hassle to set up a multiplayer session if it requires to get everybody's character files in the server. However, that has the advantage that it ensures that only those players can join.

Can you guys think of any potential issues with this, other than what I've already pointed out?

Hmm... Let me be thorough.

From a game design stand point. If people are moving their character files around, and could tamper with them... could they set up some overpowered characters? Or perhaps they could bring tons of items and wreck the economy? I do not know what information is in those files or if there is an economy in your game. I suppose that if it is all cosmetic, there is no problem.

From an information security stand point, we want to – at least – protect the following properties of the information:

  • Confidentiality: People who are not the right users should NOT have access.
  • Availability: The right user should have access.
  • Integrity: The information should not be corrupted.

On that framework, the first concern is integrity. One simple solution is to have backups. The export and import feature would help with that. Consider to auto backup when the world is loaded. You may also consider to have a checksum for the world, so you can detect when it was corrupted.

Beyond that, we would only have reason to worry about in the scenarion where they are playing on a public network (public as in public WiFi). Probably not the intended use case. I would warn the players not to do that.

Under the assumption of a public network. The second concern is confidenciality. Two problems:

  • An uninvited player joins.

    If we have to move the character files to the server, this is covered.

    Aside from that, you could have the option to have a password. However, not a password for the users, but for the world. So that only players that input the world password can add their characted and join the game.

    Yeah, of course, the password could be circumvented by having access to the machine. However, whoever has access to the machine has control over the game world. Thus, do not worry about that. You may even store the password in plain text, you have my blessing.

  • A malicious user spies.

    I'm thinking about in-game chat. Well, the solution is to not have chat. Har har.

    Baring that, you could use symmetric cryptography. In fact, you can derive the key from the world password. On that note, see: Should I encrypt my multiplayer network traffic?.

There is a third concern: availability. You would be listening to some ports. On a public network somebody could try a denial of service attack by spamming those ports. You want some good defensive programming against network input. I'd suggest to soft ban IPs that are sending invalid traffic. In fact, while we are at it, make sure you do not have any buffer overflow vulnerabilities. Hopefully not, nobody writes network code like that anymore, right? RIGHT?

Is there a better (common) way to achieve what I'm trying to do?

Password protected games and matches are very common.

Aside from password for the world/match, which the players input to join...

A less popular idea is asking the player who is acting as server to grant access to every player who wants to join. There would be no password, any body could request to join. The drawback is that if you allow them to join mid-play it would interrupt the player. So this is something you would do on a lobby for a match.

Moving a character from server to server is very rare. I do not have any more common or better way to do it that just moving the files.

You can consider to automate sending the files over the network from one game intance to another. Then you open the possiblity of some rando in the public network sending you a character file.

  • \$\begingroup\$ Thanks for this thoughtful response! Your suggestions are really making a difference in my actual implementation. \$\endgroup\$ Feb 6 '20 at 18:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.