Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
135 commits
Select commit Hold shift + click to select a range
3d18a19
Update team member list for the meta end-point
NgoKimPhu Feb 23, 2018
bcccf33
Ignore .pyc files
NgoKimPhu Feb 23, 2018
0db39e2
Add unit tests
NgoKimPhu Feb 23, 2018
06d3209
Merge pull request #1 from cs5331jan2018-prdz/QA
NgoKimPhu Feb 23, 2018
96132e5
add commands to Dockerfile to set up MongoDB
OuyangDanwen Feb 23, 2018
136a8e4
remove redundant file
OuyangDanwen Feb 23, 2018
b9ea2c2
add installation of pymongo to Dockerfile for interfacing with the da…
OuyangDanwen Feb 24, 2018
e34a620
add database test
OuyangDanwen Feb 24, 2018
dfd70bf
add comments for exposing port and remove redundant import
OuyangDanwen Feb 24, 2018
1ea2f5d
change assertEqual to assertDictEqual for dictionary comparison
OuyangDanwen Feb 24, 2018
a27c27b
fix assertEqual
OuyangDanwen Feb 24, 2018
5672159
fix wrong list
OuyangDanwen Feb 24, 2018
5624db9
fix typo
OuyangDanwen Feb 24, 2018
ce44305
switch to insert
OuyangDanwen Feb 24, 2018
6979229
syntax fix
OuyangDanwen Feb 24, 2018
10a64c4
syntax fix
OuyangDanwen Feb 24, 2018
903aa68
fix import
OuyangDanwen Feb 24, 2018
1f4d4d2
fix bson format
OuyangDanwen Feb 24, 2018
8890508
Revert back to using app.py in /service instead of src/service
NgoKimPhu Feb 24, 2018
f12aa09
Merge pull request #2 from cs5331jan2018-prdz/docker/setup_mongoDB
NgoKimPhu Feb 24, 2018
f8671c5
upgrade mongodb to 3.6 for security
OuyangDanwen Feb 24, 2018
aec9f28
update test
OuyangDanwen Feb 24, 2018
993cac6
add mongoengine support to Dockerfile for schema design
OuyangDanwen Feb 25, 2018
315669e
add simple schema for users and some api calls
OuyangDanwen Feb 25, 2018
37e23b1
add basic exception handing and proper imports
OuyangDanwen Feb 25, 2018
d093ab5
add test for registerUser
OuyangDanwen Feb 25, 2018
6a3a793
fix relative imports
OuyangDanwen Feb 25, 2018
a8bbc64
fix import path for schema
OuyangDanwen Feb 25, 2018
00cdd8b
remove import
OuyangDanwen Feb 25, 2018
ac5d234
switch to flask_mongoengine
OuyangDanwen Feb 25, 2018
023de62
switch back to mongoengine
OuyangDanwen Feb 25, 2018
23911c9
fix tests
OuyangDanwen Feb 25, 2018
2fe5282
fix expected out in tests
OuyangDanwen Feb 25, 2018
258a2a4
fix import error
OuyangDanwen Feb 25, 2018
b776803
Add API routes
NgoKimPhu Feb 24, 2018
ea409cc
Ignore vim's .swp file
NgoKimPhu Feb 25, 2018
252504c
Follow python naming standard to prepare for pytest
NgoKimPhu Feb 25, 2018
a1ae2a3
fix import error
OuyangDanwen Feb 25, 2018
989b947
fix bcrypt
OuyangDanwen Feb 25, 2018
b815aa9
fix typo
OuyangDanwen Feb 25, 2018
2309cc9
Use pytest on circleCI to output report in junit format
NgoKimPhu Feb 25, 2018
aa5d667
fix error
OuyangDanwen Feb 25, 2018
c14ab0b
Merge branch 'master' into QA
NgoKimPhu Feb 25, 2018
2a70ab3
remove alias
OuyangDanwen Feb 25, 2018
173ce01
Merge pull request #4 from cs5331jan2018-prdz/QA
NgoKimPhu Feb 25, 2018
4382ae1
add missing filed
OuyangDanwen Feb 25, 2018
3876518
change to connect to localhost
OuyangDanwen Feb 25, 2018
06bcf91
fix no new line
OuyangDanwen Feb 25, 2018
c14a2bf
fix no new line
OuyangDanwen Feb 25, 2018
e494cb5
Clean up
NgoKimPhu Feb 25, 2018
eef4cf5
Merge branch 'master' into HEAD
NgoKimPhu Feb 25, 2018
f127ae2
Change equal assertion to inclusion
NgoKimPhu Feb 25, 2018
ab8e5eb
Merge pull request #5 from cs5331jan2018-prdz/mongodb_update_cleanup
OuyangDanwen Feb 25, 2018
1eea563
remove wildcard imports
OuyangDanwen Feb 25, 2018
9b0c477
fix import
OuyangDanwen Feb 25, 2018
30cd270
fix import
OuyangDanwen Feb 25, 2018
e702923
Merge pull request #3 from cs5331jan2018-prdz/mongodb_update
NgoKimPhu Feb 25, 2018
0711f9a
Skeleton Login Page
zandercx Feb 26, 2018
6d564b0
Merge branch 'master' into routes
NgoKimPhu Feb 26, 2018
ec7e371
Minor Change
zandercx Feb 26, 2018
8015b8a
add post table schema and insertPost
OuyangDanwen Feb 26, 2018
5682027
Minor Changes II
zandercx Feb 26, 2018
7cb5ae5
add age field to user schema
OuyangDanwen Feb 26, 2018
4d5e1a7
fix type
OuyangDanwen Feb 26, 2018
ce2744a
Merge pull request #6 from cs5331jan2018-prdz/db_schema
NgoKimPhu Feb 26, 2018
bb6c20b
Minor Changes III
zandercx Feb 26, 2018
e38e714
add token transactions
OuyangDanwen Feb 26, 2018
a0f1cb4
Merge branch 'origin/db_schema' into routes
NgoKimPhu Feb 26, 2018
279b0a5
Handling db connection with `with` statement
NgoKimPhu Feb 26, 2018
bda1c18
First commit of frontend pages.
ruibinch Feb 26, 2018
bf0a664
Merge branch 'frontend' of https://github.com/cs5331jan2018-prdz/rest…
ruibinch Feb 26, 2018
de821fb
add post transcations
OuyangDanwen Feb 26, 2018
87dcc51
Minor additions to FE.
ruibinch Feb 26, 2018
14b2f81
Save bcrypt in app object
NgoKimPhu Feb 26, 2018
31f2f9e
Hardcode team member list to avoid path issues
NgoKimPhu Feb 26, 2018
c22fcbd
Fix db api and schemas
NgoKimPhu Feb 26, 2018
5e4e70e
Update setup and db tests, add db cleanup in tear-down
NgoKimPhu Feb 26, 2018
62f5c5a
Extract db configs to config file
NgoKimPhu Feb 26, 2018
4aad636
Add meta and users endpoint tests
NgoKimPhu Feb 26, 2018
a70de33
Hook up db api to users endpoints
NgoKimPhu Feb 26, 2018
c5fd59c
Put debug boolean in config file
NgoKimPhu Feb 26, 2018
9575689
Minor changes
ruibinch Feb 27, 2018
e9b3887
Updated FE with all key widgets.
ruibinch Feb 27, 2018
9731ebb
Merge branch 'master' of https://github.com/cs5331jan2018-prdz/rest-a…
ruibinch Feb 27, 2018
ce48de9
Refactor
NgoKimPhu Feb 27, 2018
6f071a8
Fix db fields
NgoKimPhu Feb 27, 2018
679f767
Update counter before attempting to create diary entry
NgoKimPhu Feb 27, 2018
450505b
Handle bad request without password field
NgoKimPhu Feb 27, 2018
93af652
Merge branch 'back_end' of https://github.com/cs5331jan2018-prdz/rest…
zandercx Feb 27, 2018
b4cc84e
Fix db fields
NgoKimPhu Feb 27, 2018
539517b
Update counter before attempting to create diary entry
NgoKimPhu Feb 27, 2018
a69fa0d
Handle bad request without password field
NgoKimPhu Feb 27, 2018
1d51f67
Refactor test
NgoKimPhu Feb 27, 2018
91635bb
Add diary endpoint tests
NgoKimPhu Feb 27, 2018
5f7dcea
Fix more db api bugs
NgoKimPhu Feb 27, 2018
dfff73c
Implement diary endpoints
NgoKimPhu Feb 27, 2018
b5bff62
Merge remote-tracking branch 'origin/back_end' into frontend
zandercx Feb 27, 2018
b626ced
De-expose mongodb service
NgoKimPhu Feb 27, 2018
ba758f0
Merge pull request #7 from cs5331jan2018-prdz/back_end
NgoKimPhu Feb 27, 2018
27ba77d
Skeleton AJAX code
zandercx Feb 27, 2018
5292e6f
Merge branch 'master' of https://github.com/cs5331jan2018-prdz/rest-a…
zandercx Feb 27, 2018
a531a41
Merge branch 'upstream/master' (CS5331-Assignments/rest-api-development)
NgoKimPhu Feb 27, 2018
806af2e
Update app and tests to follow new specs introduced in cf046de
NgoKimPhu Feb 27, 2018
c345384
Merge pull request #8 from cs5331jan2018-prdz/hotfix-standardized-res…
NgoKimPhu Feb 27, 2018
b20fbdc
Registration API Call Successful, Skeleton Login
zandercx Feb 27, 2018
eaa1fa4
Merge remote-tracking branch 'origin/master' into frontend
zandercx Feb 27, 2018
824f907
Registration, Login, Home Page API Call success.
zandercx Feb 27, 2018
63b8ef1
Included creation of diary entry
ruibinch Feb 28, 2018
dcea629
More FE-BE integration.
ruibinch Feb 28, 2018
b5f5ead
Minor bug fixes
ruibinch Feb 28, 2018
43df4d6
More minor bug fixes
ruibinch Feb 28, 2018
42f8f80
Removed dummy data
ruibinch Feb 28, 2018
fb25da4
viewentries.html bugfix. jquery buttons will now pop up.
zandercx Feb 28, 2018
32efecf
Implemented final feature, pending testing.
ruibinch Mar 1, 2018
dba0fe0
Merge branch 'frontend' of https://github.com/cs5331jan2018-prdz/rest…
ruibinch Mar 1, 2018
0665db6
All features integrated into FE, pending testing
ruibinch Mar 1, 2018
13b1333
Some Minor Changes:
zandercx Mar 1, 2018
985fe10
Cleaning up. Remove JS codes from html pages.
zandercx Mar 1, 2018
298e82a
Updated several stuff:
zandercx Mar 2, 2018
9ce22bd
Fixed cosmetic display bug
ruibinch Mar 3, 2018
3703c3d
Updated README.
ruibinch Mar 5, 2018
0c93e67
Merge branch 'frontend' of https://github.com/cs5331jan2018-prdz/rest…
ruibinch Mar 5, 2018
f05a512
Update README.md
zandercx Mar 5, 2018
516fd00
Minor changes to README.
ruibinch Mar 5, 2018
cff1c7f
Merge branch 'frontend' of https://github.com/cs5331jan2018-prdz/rest…
ruibinch Mar 5, 2018
ad5780e
Added DOMPurify for client-side XSS sanitisation.
ruibinch Mar 5, 2018
5f8ce3a
Removed redundant files.
ruibinch Mar 5, 2018
28a0a90
Minor changes to README.
ruibinch Mar 5, 2018
3bd1727
Updated README.
ruibinch Mar 5, 2018
775c5bd
Update README.md in short questions and contribution parts
NgoKimPhu Mar 5, 2018
c92bed3
Fixed issues with DOMPurify
ruibinch Mar 5, 2018
9ab9bcf
Removed redundant file.
ruibinch Mar 5, 2018
bb1cefe
Merge pull request #11 from cs5331jan2018-prdz/frontend
NgoKimPhu Mar 5, 2018
6aabc03
Merge branch 'master' into release-1.0
NgoKimPhu Mar 5, 2018
240095b
Merge pull request #12 from cs5331jan2018-prdz/release-1.0
NgoKimPhu 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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
*.pyc
*.swp
.pytest_cache/
16 changes: 16 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,26 @@ RUN apt-get install -y apache2
RUN pip install -U pip
RUN pip install -U flask
RUN pip install -U flask-cors
RUN pip install -U mongoengine
RUN pip install -U pymongo
RUN pip install -U flask-bcrypt
RUN \
apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 2930ADAE8CAF5059EE73BB4B58712A2291FA4AD5 && \
echo "deb [ arch=amd64,arm64 ] http://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.6 multiverse" | tee /etc/apt/sources.list.d/mongodb-org-3.6.list && \
apt-get update && \
apt-get install -y mongodb-org && \
rm -rf /var/lib/apt/lists/*
VOLUME ["/data/db"]
VOLUME ["/log/mongodb.log"]
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
# Expose ports for testing from host only, remove this for deployment
# - 27017: process
# - 28017: http
# EXPOSE 27017
# EXPOSE 28017
CMD ["/bin/bash", "/service/start_services.sh"]
92 changes: 69 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,59 +85,105 @@ If a response is received, you're good to go.

## Screenshots

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

![Sample Screenshot](./img/samplescreenshot.png)
![Login Page](./img/login.png)

Register User

![Login Page](./img/register.png)

Create Diary Entry

![Create Diary Entry](./img/createentry.png)

View Public Entries

![View Public Entries](./img/viewpublicentries.png)

View My Personal Entries

![View My Personal Entries](./img/viewmyentries.png)

View Diary Entry Details and Modify Permissions

![View Diary Entry Details and Modify Permissions](./img/viewentrydialog.png)

Delete Entry

![Delete Entry](./img/deleteentry.png)

## 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. Ngo Kim Phu
2. Choo Rui Bin
3. Ouyang Danwen
4. Chai Wai Aik Zander

### Short Answer Questions

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

Answer: Please replace this sentence with your answer.
The web app is written on Python Flask framework that connects to a MongoDB database and the frontend web server is hosted on Apache.
The frontend is designed using HTML, Bootstrap 4 and JavaScript (jQuery 3.3.1).

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

Answer: Please replace this sentence with your answer.
We had identified the following security considerations, however it had been stated in the assignment brief that there is no need to implement the actual security measures to counter these issues.

Implemented:
- Password salted-hashing using bcrypt
- Client-side XSS sanitisation using DOMPurify

Considered but not implemented:
- JWT for better management of the authentication token
- Basic Auth tokens to prevent direct access to the API endpoints
- Enhanced challenge/response password authentication to prevent login timing attacks
- CSRF tokens
- Server-side XSS sanitisation

#### 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.
Include a Basic Auth token to be sent along with every RESTful API call; this token will be generated upon login and subsequently validated on the server-side. This prevents direct access to the API endpoints (without the need for a user login), which otherwise represents a potential information leak.

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

Answer: Please replace this sentence with your answer.
The generated cookie has an expiry time of 2 hours to reduce the possibility of replay attacks. However, this can be deemed insecure (See Question 5).

#### 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.
One potential weakness is in the cookie management - currently we are still using the default JavaScript cookie functions. Since these are implemented at the client side, a better implementation would be to use JWT. However, it was assured that we would not have to do its implementation in this current assignment.

Another vulnerability is the lack of SSL. Due to that, all web traffic is sent / received in the clear, allowing all kinds of MITM attacks to occur.

Our usage of DOMPurify provides client-side sanitisation for our web app. However, it is not a foolproof way. For a more rigorous defense (e.g. against persistent XSS), server-side sanitisation should be employed as well.

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

Answer: Please replace this sentence with your answer.
Logging should be done on the server-side to track all the significant actions made by all the users of the web app.
A framework/tool we could use to test our final webapp would be really appreciated.
The API should also consider RESTful features like: correct http verbs for end-points (GET for idempotent, resource-info-acquiring end-points, DELETE for resource deletion...), response status codes that make more sense (4xx for client-side errors), maybe a header instead of a field for the auth token...

### 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. Ngo Kim Phu
- Managed project, GitHub organization, repository
- Configured CircleCI continuous integration for quality control
- Wrote the back-end routing and logic code
2. Choo Rui Bin
- Wrote the front-end code
- Integrated the RESTful API into the front-end
- Wrote the documentation
3. Ouyang Danwen
- Designed the Docker configuration
- Designed the database schema
- Wrote the back-end db code
4. Chai Wai Aik Zander
- Wrote the front-end code
- Integrated the RESTful API into the front-end
Binary file added img/createentry.png
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/deleteentry.png
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.png
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.png
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/viewentrydialog.png
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/viewmyentries.png
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/viewpublicentries.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@ fi
TEAMID=`md5sum README.md | cut -d' ' -f 1`
docker kill $(docker ps -q)
docker rm $(docker ps -a -q)
docker volume rm $(docker volume ls -qf dangling=true)
docker build . -t $TEAMID
docker run -p 80:80 -p 8080:8080 -t $TEAMID
6 changes: 6 additions & 0 deletions src/html/css/bootstrap.min.css

Large diffs are not rendered by default.

14 changes: 14 additions & 0 deletions src/html/css/home.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
.btn-circle {
width: 30px;
height: 30px;
text-align: center;
background-color: white;
padding: 0px 0;
font-size: 16px;
border-radius: 50%;
border-color: black;
}

.jqueryDialogNoTitle .ui-dialog-titlebar {
display: none;
}
47 changes: 47 additions & 0 deletions src/html/css/index.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
.wrapper {
margin-top: 80px;
margin-bottom: 20px;
}

.form-signin {
max-width: 420px;
padding: 30px 38px 25px;
margin: 0 auto;
background-color: #eee;
border: 3px dotted rgba(0,0,0,0.1);
}

.form-signin-heading {
text-align:center;
margin-bottom: 30px;
}

.form-control {
position: relative;
font-size: 16px;
height: auto;
padding: 10px;
}

input[type="text"] {
margin-bottom: 0px;
border-bottom-left-radius: 0;
border-bottom-right-radius: 0;
}

input[type="password"] {
margin-bottom: 20px;
border-top-left-radius: 0;
border-top-right-radius: 0;
}

.colorgraph {
height: 7px;
border-top: 0;
background: #c4e17f;
border-radius: 5px;
background-image: -webkit-linear-gradient(left, #c4e17f, #c4e17f 12.5%, #f7fdca 12.5%, #f7fdca 25%, #fecf71 25%, #fecf71 37.5%, #f0776c 37.5%, #f0776c 50%, #db9dbe 50%, #db9dbe 62.5%, #c49cde 62.5%, #c49cde 75%, #669ae1 75%, #669ae1 87.5%, #62c2e4 87.5%, #62c2e4);
background-image: -moz-linear-gradient(left, #c4e17f, #c4e17f 12.5%, #f7fdca 12.5%, #f7fdca 25%, #fecf71 25%, #fecf71 37.5%, #f0776c 37.5%, #f0776c 50%, #db9dbe 50%, #db9dbe 62.5%, #c49cde 62.5%, #c49cde 75%, #669ae1 75%, #669ae1 87.5%, #62c2e4 87.5%, #62c2e4);
background-image: -o-linear-gradient(left, #c4e17f, #c4e17f 12.5%, #f7fdca 12.5%, #f7fdca 25%, #fecf71 25%, #fecf71 37.5%, #f0776c 37.5%, #f0776c 50%, #db9dbe 50%, #db9dbe 62.5%, #c49cde 62.5%, #c49cde 75%, #669ae1 75%, #669ae1 87.5%, #62c2e4 87.5%, #62c2e4);
background-image: linear-gradient(to right, #c4e17f, #c4e17f 12.5%, #f7fdca 12.5%, #f7fdca 25%, #fecf71 25%, #fecf71 37.5%, #f0776c 37.5%, #f0776c 50%, #db9dbe 50%, #db9dbe 62.5%, #c49cde 62.5%, #c49cde 75%, #669ae1 75%, #669ae1 87.5%, #62c2e4 87.5%, #62c2e4);
}
Loading