Longwelwind / Phi

Phi is a Rimworld mod that enables multiplayer interactions between players
50 stars 19 forks source link

Authentication Upgrade & Spam Fix #32

Closed thomotron closed 6 years ago

thomotron commented 6 years ago

Description

This is a reworked and more secure version of the current username/key authentication system which solves two issues:

  1. Fixes #29 by limiting transactions to one every three seconds for each user

  2. Hashed keys are no longer distributed to clients, preventing attackers from pulling them from the user list and posing as other users

New Auth Process

Authentication is now essentially a username and password based login, using the existing implementation of user ids and hashed keys. Each user is already assigned a unique id, so I moved the authentication system from checking the hashed key (and more recently the username) to checking both the user's id and hashed key.

When a user attempts to connect, they provide their hashed key and optionally a user id. If a user id is provided, the server checks whether that user id exists and whether the key matches. If either of these checks fail, the user is registered with a new id and their key is assigned to it. If a user id is not provided they follow the aforementioned registration process. The remainder of the authentication process remains the same. The user's hashed key is only stored in memory on the server and never propagated to other users.

Summarised Changes

Please don't hesitate to make comments or suggestions on the auth process or other details that I may have missed