Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CS5331 Submission #34

Open
wants to merge 44 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
8438cfb
Add project skeleton and switch to node
Feb 16, 2018
57b7c39
Added routes for users paths
Feb 16, 2018
8c25579
Add routes for diary endpoints
Feb 16, 2018
11cb684
Add User model
Feb 17, 2018
13390ff
Add Diary model
Feb 17, 2018
2cff46f
Add connection to db
Feb 17, 2018
84ea0c1
Hash user's password before storing it in the db
kowshik-sundararajan Feb 18, 2018
6c40f38
Add user methods to generate and remove auth token
kowshik-sundararajan Feb 18, 2018
ab8ebd6
Add empty controller files
kowshik-sundararajan Feb 18, 2018
3c3cbf0
Updating Models (Users: username is unique; Diaries: publish_date is …
anushaAnandan Feb 22, 2018
7fd6c7b
API code
anushaAnandan Feb 22, 2018
26b3cf2
Formating files
anushaAnandan Feb 23, 2018
ef969d8
Merge pull request #1 from CS5331-Web-Security-Group14/develop-api
kowshik-sundararajan Feb 23, 2018
04f9226
Refactor to fix eslint errors
kowshik-sundararajan Feb 23, 2018
46ed1b2
Update endpoints list
kowshik-sundararajan Mar 3, 2018
2692672
Update Docker config
kowshik-sundararajan Mar 3, 2018
5e15996
Update diary api response spec
kowshik-sundararajan Mar 5, 2018
9988ef1
Update user api response spec
kowshik-sundararajan Mar 5, 2018
a307765
Update eslint environment
kowshik-sundararajan Mar 5, 2018
7194275
Add frontend
kowshik-sundararajan Mar 5, 2018
dcd7471
Add express-cors
kowshik-sundararajan Mar 5, 2018
6e24735
Update responses to match spec
kowshik-sundararajan Mar 5, 2018
67b3563
Get token param from response
kowshik-sundararajan Mar 5, 2018
e515362
Update /meta/members response
kowshik-sundararajan Mar 5, 2018
89de31c
Update front-end
kowshik-sundararajan Mar 5, 2018
bc68e08
Update front-end code to suit apache2
kowshik-sundararajan Mar 5, 2018
fc7a894
Permission toggle not working properly
anushaAnandan Mar 5, 2018
930b274
Few UI bug fixes
anushaAnandan Mar 5, 2018
842931b
Minor bug
anushaAnandan Mar 5, 2018
4d1649e
wrong group no
anushaAnandan Mar 5, 2018
bd4f9e5
Adding screenshots
anushaAnandan Mar 5, 2018
222d2f3
Adding screenshots
anushaAnandan Mar 5, 2018
d743995
Adding localhost:8080 for cors
anushaAnandan Mar 5, 2018
1e973e7
Update README.md
kowshik-sundararajan Mar 5, 2018
9cb36ff
Update README.md
kowshik-sundararajan Mar 5, 2018
15e12a9
Update README.md
kowshik-sundararajan Mar 5, 2018
04ad2b3
Update Docker
kowshik-sundararajan Mar 5, 2018
bc25b44
Merge branch 'develop' of github.com:CS5331-Web-Security-Group14/rest…
kowshik-sundararajan Mar 5, 2018
5eb93c9
Merge pull request #2 from CS5331-Web-Security-Group14/develop
kowshik-sundararajan Mar 5, 2018
1ecbbd9
Update Dockerfile
kowshik-sundararajan Mar 5, 2018
bbab45b
Update Dockerfile-node
kowshik-sundararajan Mar 5, 2018
ebf6e34
Update Dockerfile
kowshik-sundararajan Mar 5, 2018
feda923
Update Dockerfile-node
kowshik-sundararajan Mar 5, 2018
4f3c145
Update README.md
kowshik-sundararajan Mar 5, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"extends": "airbnb-base",
"rules": {
"no-console": "off",
},
"env": {
"browser": true,
"commonjs": true,
"es6": true,
"jquery": true,
}
}
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
node_modules/

.DS_Store
.git
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ RUN pip install -U flask-cors
RUN echo "ServerName localhost " >> /etc/apache2/apache2.conf
RUN echo "$user hard nproc 20" >> /etc/security/limits.conf
ADD ./src/service /service
ADD ./src/html /var/www/html
ADD ./src/public /var/www/html
EXPOSE 80
EXPOSE 8080
CMD ["/bin/bash", "/service/start_services.sh"]
27 changes: 27 additions & 0 deletions Dockerfile-node
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#FROM ubuntu:latest
#RUN apt-get update
#RUN apt-get install -y python-pip
#RUN apt-get install -y apache2
#RUN pip install -U pip
#RUN pip install -U flask
#RUN pip install -U flask-cors
#RUN echo "ServerName localhost " >> /etc/apache2/apache2.conf
#RUN echo "$user hard nproc 20" >> /etc/security/limits.conf
#ADD ./src/service /service
#ADD ./src/html /var/www/html
#EXPOSE 80
#EXPOSE 8080
#CMD ["/bin/bash", "/service/start_services.sh"]

FROM node:latest
WORKDIR /usr/src/app
COPY package*.json ./

RUN npm install

COPY . .

#EXPOSE 80
EXPOSE 8080

CMD ["npm", "start"]
151 changes: 59 additions & 92 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,140 +4,107 @@ CS5331 Assignment 1 Project Reference Repository

## Instructions

Your objective is to implement a web application that provides the endpoints
The objective is to implement a web application that provides the endpoints
specified here: https://cs5331-assignments.github.io/rest-api-development/.

The project has been packaged in an easy to set-up docker container with the
skeleton code implemented in Python Flask. You are not restricted in terms of
which language, web stack, or database you desire to use. However, please note
that very limited support can be given to those who decide to veer off the
beaten path.

You may be required to modify the following files/directories:

- Dockerfile - contains the environment setup scripts to ensure a homogenous
development environment
- src/ - contains the front-end code in `html` and the skeleton Flask API code
in `service`
- img/ - contains images used for this README

Assuming you're developing on an Ubuntu 16.04 machine, the quick instructions
to get up and running are:

```
# Install Docker

sudo apt-get update
sudo apt-get install \
apt-transport-https \
ca-certificates \
curl \
software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
stable"
sudo apt-get update
sudo apt-get install docker-ce

# Verify Docker Works

sudo docker run hello-world

# Run the skeleton implementation

sudo ./run.sh
```

(Docker CE installation instructions are from this
[link](https://docs.docker.com/install/linux/docker-ce/ubuntu/#install-using-the-repository).)

**Please consult your assignment hand-out for detailed setup information.**
## Screenshots

## Grading
1. User Sign-up.

The implementation will be graded in an automated fashion on an Ubuntu 16.04
virtual machine by building the docker container found in your repository and
running it. The grading script will interact with your API.
![Signup Screenshot](./img/Register.JPG)

The following ports are expected to be accessible:
2. User Log-in.

1. 80, on which static HTML content, including the front-end, is served.
2. 8080, on which the API is exposed.
![Login Screenshot](./img/Login.JPG)

To verify this, please run the following commands:
3. View public diary entries.

```
sudo ./run.sh
```
![Public Entries Screenshot](./img/PublicEntries.JPG)

On a different window:
4. View user's public and private entries. (Toggle permission and delete entries)

```
curl http://localhost:80
curl http://localhost:8080
```
![User Entries Screenshot](./img/UserEntries.JPG)

If a response is received, you're good to go.
5. Create new diary entry.

**Please replace the details below with information relevant to your team.**
![New Entry Screenshot](./img/CreateEntry.JPG)

## Screenshots
5. View user profile.

Please replace the example screenshots with screenshots of your completed
project. Feel free to include more than one.

![Sample Screenshot](./img/samplescreenshot.png)
![User Profile Screenshot](./img/Profile.JPG)

## Administration and Evaluation

Please fill out this section with details relevant to your team.

### Team Members

1. Member 1 Name
2. Member 2 Name
3. Member 3 Name
4. Member 4 Name
1. **Luis Vazquez Diaz**
2. **Divya Kamal Maddi**
3. **Anusha Anandan**
4. **Kowshik Sundararajan**

### Short Answer Questions

#### Question 1: Briefly describe the web technology stack used in your implementation.

Answer: Please replace this sentence with your answer.
Answer: Our tech stacks consists of:
* Backend: NoSQL database (MongoDB)
* Server: Node.js with Express framework and Mongoose wrapper for MongoDB
* Front-end: HTML, CSS, JavaScript, jQuery, Bootstrap4

#### Question 2: Are there any security considerations your team thought about?

Answer: Please replace this sentence with your answer.
Answer: We considered the following security measures (have not implemented them):
* XSS defenses by input/output sanitization and escaping.
* CSRF defenses by using tokens and checking origin header.
* Implementing CSP to prevent general injection attacks.
* Password requirements (length, special characters, etc)

We have implemented the following:
* NoSQL injection defenses (implemented by using Mongoose prepared statements).

#### Question 3: Are there any improvements you would make to the API specification to improve the security of the web application?

Answer: Please replace this sentence with your answer.
Answer: Since the token is sent in cleartext, session hijacking can take place.

#### Question 4: Are there any additional features you would like to highlight?

Answer: Please replace this sentence with your answer.
Answer: We have implemented the following features:
* Password security: Using a combination of hashing and salts.
* We implemented a whitelist such that only http://localhost:80 can make requests to the API.

#### Question 5: Is your web application vulnerable? If yes, how and why? If not, what measures did you take to secure it?

Answer: Please replace this sentence with your answer.
Answer: Yes, the web application is vulnerable to the following types of attacks:
* XSS: inputs and outputs are not sanitized, html and urls are not escaped.
* CSP: No implementation of CSP directives allows for injection of malicious scripts.
* Lack of auto expiry of auth token can leave the app vulnerable if an attacker gains access - CSRF.
* Unencrypted traffic - opens the gate for MiTM attacks.

#### Feedback: Is there any other feedback you would like to give?

Answer: Please replace this sentence with your answer.
Answer: There are inconsistencies with the API documentation. `/diary/delete` should be implemented using `DELETE` verb and `/diary/permission` should be implemented using `PUT`.

Appreciate the flexibility in choosing our own tech stack, however with lack of experience in Docker, it has been quite difficult.

### Declaration

#### Please declare your individual contributions to the assignment:

1. Member 1 Name
- Integrated feature x into component y
- Implemented z
2. Member 2 Name
- Wrote the front-end code
3. Member 3 Name
- Designed the database schema
4. Member 4 Name
- Implemented x
1. **Luis Vazquez Diaz**
- Implemented Docker

2. **Divya Kamal Maddi**
- Front-end
- Documentation

3. **Anusha Anandan**
- Server-side
- Database
- Front-end

4. **Kowshik Sundararajan**
- Server-side
- Database
- Front-end
- Documentation

26 changes: 26 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
version: "2"
services:
app:
container_name: app
restart: always
build: .
ports:
- "80:80"
- "8080:8080"
links:
- mongo
depends_on:
- mongo
mongo:
container_name: mongo
image: mongo
volumes:
- ./data:/data/db
ports:
- "27017:27017"
node:
container_name: node
build:
context: .
dockerfile: Dockerfile-node

Binary file added img/CreateEntry.JPG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/Login.JPG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/Profile.JPG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/PublicEntries.JPG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/Register.JPG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/UserEntries.JPG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading