You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
Michele Sessa 73d7b44898 docs(gatecrashers): change example, now content-type is application/json 2 years ago
..
README.md docs(gatecrashers): change example, now content-type is application/json 2 years ago

README.md

Gatecrashers

Instructions

Unfortunately many of your guests started to invite plus ones, that started to invite plus ones, that started... to be short, everybody is inviting everybody and the situation is rapidly going out of control.

To fix this issue you will introduce a Basic Access Authentication on your server.

To modify the guest list now your friends will need to make authenticated requests. You decided that only your 3 best friends (Caleb_Squires, Tyrique_Dalton and Rahima_Young) will be able to modify the list. You also told them the secret password abracadabra in order to do that.

The request query will look like this curl -u Caleb_Squires:abracadabra ....

The server should properly handle unauthorized requests using the error code 401.

Apart for the authentication part your server's behavior should remain unchanged:

  • You will listen to port 5000 and print a message containing the port you are using.
  • For each authorized http POST request, your program should create the corresponding JSON file and store the contents of the body, and then provide the content as JSON in the HTTP response, if possible.

Example

To test your program, you should be able to expect the following behavior once your program is up and running.

Unauthorized attempt:

curl -i -X POST localhost:5000/Ricky_Banni -H "Content-Type: application/json" -d '{"answer": "yes", "drink": "alcohol", "food": "bats"}'
HTTP/1.1 401 Unauthorized
Content-Type: application/json
Date: [date]
Connection: keep-alive
Keep-Alive: timeout=5
Transfer-Encoding: chunked

Authorization Required%

Authorized attempt:

curl -i -u Rahima_Young:abracadabra -X POST localhost:5000/Ricky_Banni -H "Content-Type: application/json" -d '{"answer": "yes", "drink": "alcohol", "food": "bats"}'
HTTP/1.1 200 OK
Content-Type: application/json
Date: [date]
Connection: keep-alive
Keep-Alive: timeout=5
Transfer-Encoding: chunked

{
  "answer": "yes",
  "drink": "alcohol",
  "food": "bats"
}

Notions

Provided files

Download guests.zip to have at your disposal the guests directory containing the files with the guest information. You must save it in your gatecrashers exercise directory to test your program on it.