Welcome to FortiChat, where Conversations Forge Lasting Connections! π
Developed with the MERN Stack:
- π FortiChat - Social Media Platform π
- Key Features π
- β’οΈ Systems Threat Model β’οΈ
- π Mission Statement for FortiChat π
- π Project Website Specifications for FortiChat π
- π‘οΈ Assets to Protect in FortiChat π‘οΈ
- π Data Flow Chart π
- π¦ Threats to FortiChat π¦
- π Risk Assessment and Prioritization π
- π¨ Plan for Incident Response π¨
- βοΈ Cyber Security Measures βοΈ
- ποΈ Database ποΈ
- π FortiChat Use Cases π
- β¨ FortiChat Contribution List β¨
- π Installation & Setup Guide π
Feature | Description |
---|---|
Cyber Security Focus π | OWASP Top10 taken intro consideration during development. |
Friend System π₯ | Add or remove friends to build a personalized network. |
Posts and Interactions π¬ | Share thoughts, images, and like other users' posts. |
Responsive Design π± | Seamlessly adaptable to various devices, enhancing user accessibility. |
To create an engaging, secure, and user-friendly social media platform that fosters meaningful connections and community building.
- To develop a comprehensive social media experience that prioritizes user engagement, data security, and a seamless interface.
- To offer a platform where individuals from diverse backgrounds can connect, share ideas, and foster a sense of community in a safe and welcoming digital environment.
- User-Centric Design π₯
- Privacy and Security π
- Community and Connection π€
- To build a robust, scalable social media platform that supports real-time communication, content sharing, and community engagement. π
- To implement state-of-the-art security measures, ensuring the integrity and confidentiality of user data. π‘οΈ
- To continually adapt and grow, responding to user feedback and emerging digital trends to improve the platform. π±
Feature Category | Description |
---|---|
User Authentication and Registration π | - Secure login and registration system. - Password encryption using bcrypt. - JWT-based session management. |
User Profile Management π€ | - Personalized user profiles with editable details like location and occupation. - Profile picture upload. - View and manage friends list. |
Post Creation and Management π | - Create posts with text and image content. - Like and comment on posts. - Image uploads for posts using multer. |
Real-time Feed π | - Dynamic feed displaying posts from friends. - Real-time updates for new content. |
Friends System π₯ | - Add/remove friends to build a personalized network. - Access control for managing friends list. |
Security Features π | - Rate limiting to prevent abuse and DoS attacks. - Input validation and sanitation against XSS and injection attacks. - Helmet for enhanced HTTP security. - Generic error responses for security. - CORS configuration for cross-origin request management. |
Database Management πΎ | - MongoDB with mongoose for database operations. - Secure database connection handling. |
Responsive Design π± | - Adaptable design for accessibility on various devices. |
Aspect | Strategy |
---|---|
MERN Stack | Utilization of MongoDB, Express.js, React.js, and Node.js for full-stack development. |
Modular Design | Each feature (authentication, profile management, etc.) is designed as a modular, scalable unit. |
API-First Approach | Backend development with a focus on RESTful API principles for scalability and flexibility. |
Focus | Practices |
---|---|
OWASP Top 10 Adherence | Following guidelines for web application security. |
Dependency Management | Regular updates and reviews of dependencies and libraries for security. |
Sensitive Data Management | Use of environment variables to securely manage sensitive data and credentials. |
Below is a breakdown of these primary assets and the measures in place to protect them.
- Content: Usernames, email addresses, and passwords.
- Protection: Bcrypt for password hashing and secure JWT token management.
- Content: Text posts and images shared by users.
- Protection: Server-side validation for content integrity.
- Content: User profile data like names, locations, occupations, and profile pictures.
- Protection: Secure MongoDB storage, input validation, and sanitation to prevent data leakage and injection attacks.
- Content: Information about user connections and friendships.
- Protection: Access control checks ensuring interactions are confined within the user's network.
- Content: Data on user interactions (likes, comments) and activity logs.
- Protection: Access control and rate limiting to prevent unauthorized actions and abuse.
- Content: Operational integrity of backend services, APIs, and frontend interactions.
- Protection: Helmet for HTTP security, CORS configurations, and consistent error handling.
flowchart LR
A[User Interface] -->|Authentication| B[Auth Module]
B -->|JWT Token| A
A -->|Create/View Posts| C[Posts Module]
C -->|Store/Retrieve Images| D[Local Storage]
C -->|Store/Retrieve Data| E[MongoDB]
A -->|Manage Profile| F[User Profile Module]
F --> E
A -->|Add/Remove Friends| G[Friends Module]
G --> E
E -->|Fetch Data| A
D -->|Fetch Images| A
- User Interface π₯οΈ: The point of interaction for users, including login, post creation, profile management, and friend system.
- Auth Module π: Handles user authentication, generating and validating JWT tokens.
- Posts Module βοΈ: Manages the creation and retrieval of posts, interfacing with both AWS S3 for image storage and MongoDB for text content.
- User Profile Module π€: Manages user profile information, storing and retrieving data from MongoDB.
- Friends Module π₯: Handles the addition and removal of friends, updating the friend list in MongoDB.
- Local Storage πΎ: Responsible for the storage and retrieval of image files uploaded by users as part of their posts or profile pictures.
- MongoDB ποΈ: The primary database for storing user data, posts, and other relevant information.
- How/Why: Could occur through stolen credentials or token leakage, granting attackers access to user accounts or administrative interfaces.
- How/Why: Possible if attackers trick users into submitting requests to the web application where they are authenticated.
- How/Why: Might result from inadequate database security, leading to unauthorized access to sensitive user data.
- How/Why: Occurs when untrusted data is sent to an interpreter within a command or query, potentially leading to SQL, NoSQL, or JavaScript injection.
- How/Why: Can happen when services are overwhelmed, making the application unresponsive.
- How/Why: If the application includes untrusted data without proper validation, attackers could execute scripts in users' browsers.
- How/Why: Potential risk during data transmission, where attackers intercept and alter communications.
- How/Why: Occurs when user access limitations are not properly enforced.
- How/Why: A risk if users are allowed to upload files without stringent size, type, or content checks.
- How/Why: Arises due to improper configuration or failure to update software, exposing vulnerabilities.
- How/Why: Happens when someone with legitimate access misuses it, impacting the application's security.
- How/Why: Occurs when attackers deceive users into revealing sensitive information or compromising security.
- High Risk:
- Social Engineering and Phishing - reliant on user awareness.
- Medium Risk:
- Insider Threats - potential access to critical functionalities.
- XSS - if not specifically mitigated.
- Low Risk:
- Unauthorized Access, Data Breach, Injection Attacks, DoS, Broken Access Control, File Upload Vulnerabilities, Misconfiguration and Outdated Software - covered by existing security measures.
- Monitoring: Utilize tools like morgan & winston for continuous monitoring of activities.
- Alerts: Set up automated alerts for suspicious activities signaling potential incidents. (WIP)
- User Reporting: Encourage users to report any unusual activities or security concerns.
- Immediate Response: Quickly isolate affected systems to halt further spread.
- Backup: Regular backups to maintain data integrity and assist in recovery.
- Root Cause Analysis: Investigate to find the cause, examining logs, user activities, and system changes.
- Remediation: Address the root cause to remove the issue, potentially involving software patches or security updates.
- Restoration: Carefully restore services, monitoring for signs of recurrence.
- Testing: Conduct extensive testing to ensure the issue is fully resolved and systems are functioning normally. (WIP)
- Review and Analysis: Conduct a thorough review of the incident and the response effectiveness.
- Documentation: Document the incident, response actions, and insights for future reference.
- Communication: Keep all relevant parties informed about the incident and the measures taken.
- Training and Improvements: Update training and security measures based on the incident's learnings.
FortiChat is built by taking the OWASP API Security Top 10 into careful consideration.
- VerifyToken Middleware: Ensures authentication across routes.
- Validation Checks: Users can only access or modify their own data.
- ObjectId Validation: Maintains data integrity and prevents unauthorized access.
- JWT and Bcrypt: Manages user sessions and password hashing securely.
- JWT Token Management: Securely managed with appropriate expiration.
- Brute Force Protection: Implemented loginLimiter to guard against brute force attacks.
- Extra Validation Layers: Added validateLoginData & validateRegistrationData middleware.
- Data Validation: Implemented using Joi and other validation middleware.
- Data Sanitation: Prevents excessive data exposure.
- Rate Limiting: Mitigates DDoS and prevents API resource abuse.
- Helmet: Sets various HTTP security headers.
- CORS Settings: Configured to manage cross-origin requests.
- Generic Error Messages: Avoids disclosing sensitive information.
- Validation Checks: Rate limiting and parameter validations for security.
- Documented Endpoints: API endpoints are well-documented and monitored.
- Clean Routing: Unused or debug routes removed for production.
- Multer Integration: Manages file uploads securely.
- Configuration Limits: Limits file size and type for secure storage.
- Morgan & Winston: Used for logging HTTP requests and errors.
- Security Monitoring: Aids in detecting and responding to threats.
- Generic Error Handlers: Avoids revealing sensitive application or server details.
- Secure MongoDB Connection: With proper authentication and encryption.
- Public Access Restriction: Ensures database security.
- Dotenv Management: Keeps sensitive data like JWT secrets secure.
- Regular Updates: Addresses vulnerabilities in dependencies and libraries.
The backbone of this system is MongoDB, a popular NoSQL database known for its flexibility, scalability, and performance.
"When you could also just use SQL? (q· v ·q)? ..."
- Why It Rocks: In the ever-changing world of social media, nothing stays the same. With this idea in mind I chose MongoDB's because of its flexible schema which means FortiChat can easily evolve. New features? Different post types? No problem!
- In Simple Words: It's like having a backpack that magically expands to fit everything, no matter how much stuff you add. α( β’Μ α β’Μ )α
- Why It's Awesome: Posts, comments, images, likes - social media is a wild mix of data. MongoDB handles this variety effortlessly, letting FortiChat store and manage all sorts of content.
- Put Simply: Itβs like a wizard's hat that can hold anything from a rabbit to a bouquet of flowers - all at once! βα’. .α’β βΛβΉβ‘
- The Cool Factor: As more users join FortiChat, MongoDB grows as well! It's built to handle tons of data and users without breaking a sweat.
- In Human Terms: Imagine a party where everyone's invited, and the room magically gets bigger as more friends pile in. *ΰ©β©β§βΛ
- Why We Love It: I want to continue tinkering and improving FortiChat. MongoDBβs developer-friendly setup lets me roll out updates quickly.
- Plain Speak: It's like cooking in a well-organized kitchen - everything you need is right there, making it a breeze to whip up something new. β§βΛ β ππ© β§βΛ β
- The Wow Factor: Whatβs social media without the 'social' part? MongoDB helps me deliver real-time updates and notifications, keeping the FortiChat community buzzing.
- In Everyday Words: It's like having a conversation where replies come instantly - no awkward pauses or delays. ৻( β’Μ α β’Μ ΰ§»)
- Here's the Deal: SQL is great, but it's like a well-oiled machine with fixed parts - not ideal for the spontaneity and fluidity of what I had an idea in mind for this project. I also wanted to further develop my NoSQL (specifically MongoDB) skills, but that was besides the point.
- Bottom Line: I chose MongoDB because it's like a living, breathing organism that adapts and grows with the community. (ΰΉα΅β‘α΅)(Λβ‘Λc)
Modelled with Lucidchart
- π Users can create a new account by providing their email, name, and password.
- π The system securely stores user credentials, including hashed passwords.
- π€ Users can log in to the platform using their email and password.
- π‘οΈ The system authenticates users and issues a JWT for session management.
- π Users can view their profile information, including names, location, occupation, and profile picture.
- πΈ Users have the option to upload a profile picture, which is stored securely.
- π€ Users can send friend requests to other users.
- π The system updates the friends list upon accepting friend requests.
- π Users can create posts with text and optionally include images.
- π€³ All posts are associated with user details and can have likes and comments.
- βοΈ Users do not have an option to edit or delete posts, as itβs supposed to be a diary-style social media.
- π Users can view a feed of posts made by their friends and other connections.
- π Users can like posts in their feed.
- π¬ Users can comment on posts in their feed β To be implemented
- π Users can search for other users by name or email.
- π The system retrieves and displays user profiles matching the search criteria.
- Structured MongoDB collections for users, posts, and friendships.
- Configured MongoDB to store operational data with efficiency.
- Leveraged MongoDB for its schema flexibility and performance.
- Optimized queries and indexes for snappy data retrieval.
- Established backup procedures for disaster recovery with MongoDB.
- Applied JWT and bcrypt for secure database interactions.
- Created middleware for rate limiting and secure data validation.
- Set up detailed logging for monitoring and operational insight.
This guide will walk you through setting up and running the FortiChat project on your local machine. Before starting, ensure you have Node.js installed and a MongoDB instance ready for use.
Node.js is essential for running the JavaScript backend.
- Download Node.js here.
- For a quick start guide on Node.js, visit Getting Started with Node.js.
git clone https://github.com/AGiljanovic/FortiChat.git
cd FortiChat
- Install the required npm packages for both frontend and backend.
- Navigate to the frontend and backend directories in separate terminal windows.
- Run
npm install
in each directory to install the dependencies listed in package.json. - Frontend packages
- Backend packages
To store and manage application data, set up a MongoDB instance.
- If you don't have MongoDB, download and install it from MongoDB Official Site.
- For guidance on setting up MongoDB, refer to MongoDB Installation Guide..
- Create a .env file in the root of the backend directory and fill in the details:
MONGO_URL = ""
PORT = 3001
JWT_SECRET = ""
MONGO_DB_NAME = ""
MONGO_URL
: Your MongoDB connection string.PORT
: The port on which the backend server will run.JWT_SECRET
: A secret key for signing JWT tokens.MONGO_DB_NAME
: Name of your MongoDB database.
With the setup complete, you can now run the application:
- In the backend directory, run
node index.js
to start the backend server. - In the frontend directory, run
npm start client
to launch the React application.
- To have some initial data in the application, you can populate your database with predefined users and posts. This step is optional but recommended for a better initial experience with FortiChat.
- In the
index.js
file of the backend directory, uncomment the following lines:
// Import models and initial data
import User from "./models/user.js";
import Post from "./models/post.js";
import { users, posts } from "./data/index.js";
// Add data to the database (Run this only once to avoid duplicates)
User.insertMany(users);
Post.insertMany(posts);
- Save the changes and run your backend server. This will insert the initial users and posts into your MongoDB database.
- Important: Once the data is successfully added, comment out these lines again to prevent duplicate entries if you restart the server.
// Prevent duplicate data insertion
// User.insertMany(users);
// Post.insertMany(posts);
- Restart your backend server to continue with the normal operation of the application.
Now, your FortiChat application should have some preloaded data to interact with! Ω©(ΛαΛ*)Ω β‘