Skip to content

A robust, cloud-native user authentication service built with Django REST Framework

Notifications You must be signed in to change notification settings

shreyagupta30/secure-auth-service-webapp

Repository files navigation

Cloud-Native User Authentication Service

A robust, cloud-native user authentication service built with Django REST Framework, designed for CSYE-6225 Network Structures and Cloud Computing (Spring 2024).

Features

  • User Authentication and Authorization
  • RESTful API Endpoints
  • PostgreSQL Database Integration
  • Health Check Endpoint
  • Cloud-Native Architecture
  • Serverless Microservice Support
  • Comprehensive Test Coverage

Tech Stack

  • Backend Framework: Django 4.x
  • API Framework: Django REST Framework
  • Database: PostgreSQL
  • Authentication: JWT (JSON Web Tokens)
  • Cloud Services: Google Cloud Platform
  • Testing: pytest
  • Documentation: drf-yasg (Swagger/OpenAPI)

Prerequisites

  • Python 3.x
  • Pipenv
  • PostgreSQL
  • Google Cloud Platform Account (for cloud deployment)

Installation

  1. Install Pipenv:
pip install pipenv
  1. Clone the repository:
git clone https://github.com/shreyagupta30/webapp-csye6225.git
cd webapp-csye6225
  1. Activate the virtual environment:
pipenv shell
  1. Install dependencies:
pipenv install

Database Setup

  1. Create a PostgreSQL database:
CREATE DATABASE your_database_name;
  1. Grant privileges:
GRANT ALL PRIVILEGES ON your_database_name TO your_username;
  1. Configure environment variables: Create a .env file in the root directory:
DEBUG='True'
DB_HOST=localhost
DB_NAME=<your_database_name>
DB_USER=<your_username>
DB_PASSWORD=<your_password>
DB_PORT=5432

Running the Application

  1. Apply database migrations:
python manage.py makemigrations
python manage.py migrate
  1. Start the development server:
python manage.py runserver

API Endpoints

Health Check

GET /healthz

Returns HTTP 200 if the service is healthy.

User Authentication

Create User

POST /v1/user
Content-Type: application/json

{
    "username": "[email protected]",
    "firstname": "John",
    "lastname": "Doe",
    "password": "secure_password"
}

Get User Profile

GET /v1/user/self
Authorization: Bearer <jwt_token>

Update User Profile

PUT /v1/user/self
Authorization: Bearer <jwt_token>
Content-Type: application/json

{
    "firstname": "John",
    "lastname": "Smith",
    "password": "new_password"
}

Testing

Run the test suite:

pytest

Cloud Deployment

The application is designed for cloud deployment with the following features:

  • Packer configuration for AMI creation
  • GitHub Actions for CI/CD
  • Serverless microservice support
  • Health check monitoring

Security Considerations

  • Passwords are hashed using bcrypt
  • JWT-based authentication
  • Environment variable configuration for sensitive data
  • Input validation and sanitization

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Commit your changes
  4. Push to the branch
  5. Create a Pull Request

License

This project is part of the CSYE-6225 course at Northeastern University.

References

About

A robust, cloud-native user authentication service built with Django REST Framework

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published