Git Product home page Git Product logo

kryptonite's Introduction

CelestialCode Auth/Authz Application

Table of Contents

Project Overview

The Kryptonian App is an application crafted by CelestialCoders to manage user authentication, incorporating Two-Factor Authentication (2FA) with One-Time Passwords (OTP), and secure file uploads. The application follows contemporary RESTful API design principles and utilizes various technologies to guarantee security and efficiency.

Features Implemented

  1. Kryptonian Registration and Authentication:

    • User Registration: Allows new users to register with merely an email address.
      • Sends a confirmation email.
    • User Login: Authenticates users with email and password.
      • Checks if the user's email is confirmed before allowing login.
      • Generates an OTP and sends it to the user's email for successful login, also generates a temporary token.
    • OTP Generation and Validation: Ensures secure login by generating and validating OTPs.
      • Checks if an existing OTP is still valid before generating a new one.
    • JWT Token Handling: Issues JWT tokens for authenticated sessions.
      • Temporary JWT token issued for OTP validation.
  2. File Upload Service:

    • Users can upload image files using their API key.
    • Uploaded files are stored as Base64 strings in the database.
    • Uploaded files are deleted from the system after being stored.
    • Only image files are allowed.
  3. Image Access:

    • Images can be accessed without authentication, as required.

API Endpoint

Base URL: https://localhost:3000/

User Authentication

  • Register

    • Registers a new user and sends a confirmation email.

    • POST api/auth/register

    • Request:

      {
      	"email": "[email protected]"
      }
    • Response:

      {
      	"message": "User registered."
      }
  • Verify OTP

    • Verifies the OTP and logs in the user.

    • POST api/auth/confirm-email

    • Request:

      {
      	"email": "[email protected]",
      	"otp": "198876"
      }
    • Response:

      {
      	"message": "OTP verified"
      }

File Upload

  • Upload File
    • Uploads an image file and associates it with the user.
    • POST /api/files/upload
    • Headers:
      {
        "x-api-key": "your_api_key"
      }
      
    • Request: (using Form-data)
      Key: file
      Value: (Select an image file from your system)
    • Response:
      {
      	"message": "File uploaded"
      }

API KEY Management

  • Generate Key

    • Generates an API key on Request.

    • POST /api-key/create

    • Response:

      {
      	"apiKey": {
      		"key": "your-api-key",
      		"version": 1,
      		"invalidated": false
      	}
      }

Access Images

  • Get All Images

    • Retrieves all images.
    • GET /api/images
    • Response:
      {
      	"data": [
      		{
      			"_id": "image_id",
      			"base64": "base64_string_of_image1"
      		},
      		{
      			"_id": "image_id",
      			"base64": "base64_string_of_image2"
      		}
      	]
      }
  • Get Single Image

    • Retrieves a single image.
    • GET /api/images/:id
    • Response:
      {
      	"data": {
      		"_id": "image_id",
      		"base64": "base64_string_of_the_image"
      	}
      }

Setup Instructions

  1. Clone the Repository:

    git clone https://github.com/izzdwizz/Kryptonite.git
    cd Kryptonite
  2. Install Dependencies:

    npm install
  3. Environment Variables: - Create a .env file in the root directory. - Add the following environment variables: env PORT=3000 MONGODB_URI=mongodb+srv://uchenduizu:[email protected]/?retryWrites=true&w=majority&appName=Cluster0 REDIS_HOST=127.0.0.1 REDIS_PORT=6379 EMAIL_HOST=gmail [email protected] EMAIL_PASS=nsoptanpcsnjihao

  4. Run the Application:

    npm start

Contributing

Contributions are welcome! Please follow these steps:

  1. Fork the repository.
  2. Create a new branch (git checkout -b feature-branch).
  3. Commit your changes (git commit -m 'Add new feature').
  4. Push to the branch (git push origin feature-branch).
  5. Open a Pull Request.

kryptonite's People

Contributors

izzdwizz avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.