C代写:CSE320-Wolfie-Chat-Part5

User Accounts & Basic Security

Now it is time to add persistence to your server by creating user accounts. The user can then login and out of the server using a password. The server must be modified to contain a shared resource which holds user account information. Additionally, the login protocol must be updated to allow for account validation, eg. passwords.

You will replace the login protocol from Part I with the account login protocol.

Password Criteria

Passwords must meet the following criteria to be valid:

  • Must be at least 5 characters in length
  • Must contain at least 1 uppercase character
  • Must contain at least 1 symbol character
  • Must contain at least 1 number character

    Example: Cool320!

When the user types in the password, use the gctpass function so the password is not displayed as it is typed.

Server

Usage updated:

1
2
3
4
5
6
./server [-hv] PORT_NUMBER MOTD [ACCOUNTS_FILE]
-h Displays help menu & returns EXIT_SUCCESS.
-v Verbose print all incoming and outgoing protocol verbs & content.
PORT_NUMBER Port number to listen on.
MOTD Message to display to the client when they connect.
ACCOUNTS_FILE File containing username and password data to be loaded upon execution.

The server will request a password when a user attempts to log in. Also, it will create a new password for new users when they identify themselves upon login. There should now be two data structures central to your program: a Users list and an Accounts list. The Users list is a list of the users currently logged into the server. The Accounts list is the persistent list of users and their passwords loaded and saved to a file on the server’s execution and termination respectively. If an accounts file is provided on the command line, your server should load this file into the accounts list upon start-up. If no file is provided, the server should start with no existing accounts.

Do not use an array for either of these data structures, it MUST be an extendable format such as a linked list within your server program.

Added Server Command

/accts

When /accts is typed into the server’s terminal it should dump a list of all user accounts and information. This printout should be similarly formatted to the output of the /users command.

Client

To add user authentication we will modify the client program to take an additional argument for creating a new user on the server. When the optional -c argument is included, the client will attempt to create a new user on the server. If the argument is not provided, the client will attempt to login to the server as an existing user with an account.
Usage updated:

1
2
3
4
5
6
7
./client [-hcv] NAME SERVER_IP SERVER_PORT
-h Displays this help menu, and returns EXIT_SUCCESS.
-c Requests to server to create a new user
-v Verbose print all incoming and outgoing protocol verbs content.
NAME This is the username to display when chatting.
SERVER_IP The ipaddress of the server to connect to.
SERVER_PORT The port to connect to.

User Authentication Protocol

The protocol for logging into the server will now additionally include user creation. We will introduce new verbs IAMNEW, HINEW, NEWPASS.

Remember when the client prompts the user to enter their password, use the getpass function so the password is not displayed as it typed.

Once a user account has been established with the server, on subsequent client connections the user must be validated. We will introduce new verbs AUTH, HINEW, NEWPASS.