Giter Site home page Giter Site logo

cd-auth-api's Introduction

Two-Factor Authentication API

The Two-Factor Authentication (2FA) API provides a simple server-side implementation of Time-based One-Time Password (TOTP) for securing user authentication. It supports the generation of secret keys, provisioning of mobile apps with QR codes, and verification of one-time passwords. Additionally, it integrates with Twilio for sending OTP via SMS and supports sending OTP via email.

Table of Contents

Getting Started

Prerequisites

  • Node.js and npm installed
  • Twilio account for sending SMS (optional)
  • Nodemailer-compatible email service for sending emails (optional)

Installation

  1. Clone the repository:

    git clone https://github.com/Mr-vero/CD-Auth-API.git
  2. Install dependencies:

    cd two-factor-auth-api
    npm install
  3. Set up environment variables:

    Create a .env file and add the following:

    TWILIO_ACCOUNT_SID=your_twilio_account_sid
    TWILIO_AUTH_TOKEN=your_twilio_auth_token
    TWILIO_PHONE_NUMBER=your_twilio_phone_number
    EMAIL_SERVICE_API_KEY=your_email_service_api_key
    EMAIL_SENDER_ADDRESS=your_email_sender_address

    Replace the placeholders with your actual credentials.

  4. Start the server:

    npm start

    The server will be running on http://localhost:3000.

API Endpoints

Generate Secret Key

  • Endpoint: /generate-secret-key
  • Method: GET
  • Description: Generates a secret key for TOTP.

Request One-Time Password

  • Endpoint: /request-one-time-password
  • Method: POST
  • Description: Generates and sends a one-time password. Requires a valid secret key and optional issuer and phone number parameters.

Verify

  • Endpoint: /verify
  • Method: POST
  • Description: Verifies a provided one-time password. Requires a valid secret key, OTP, and last OTP timestamp.

Generate QR Code for Provisioning Mobile Apps

  • Endpoint: /generate-qr-code-for-provisioning-mobile-apps
  • Method: POST
  • Description: Generates a QR code for provisioning mobile apps. Requires a valid secret key, issuer, and email.

Integrations

Twilio

To enable Twilio integration for sending SMS, provide your Twilio credentials in the .env file.

Email Service

To enable email integration, provide your email service API key and sender address in the .env file.

Configuration

  • The server runs on the specified port (default is 3000).
  • Environment variables are used for configuration, and you can customize the .env file as needed.

Contributing

Feel free to contribute by opening issues and submitting pull requests. Please follow the code of conduct.

License

This project is licensed under the MIT License - see the LICENSE file for details.


Make sure to customize the placeholders (like `your_twilio_account_sid`, `your_twilio_auth_token`, etc.) with your actual credentials and modify the content based on your specific implementation and requirements.

cd-auth-api's People

Contributors

mr-vero avatar

Watchers

 avatar  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.