/Two-Factor-Authentication-Django-Rest

:mailbox: A simple application created using django rest framework that features two-factor authentication by sending activation emails when registering a new user and sending a PIN code to the user administrator's email when he sign in.

Primary LanguagePython

Two-Factor-API

API developed with djangorestframework to registering new users and sending activation emails.

Installation

Use the package manager pip to install the dependencies needed.

Create a new virtual environment:

python3.8 -m venv venv

Activate virtualenv (OBS: on Linux):

source venv/bin/activate

Install all dependencies from requirements.txt:

pip install -r requirements.txt

Settings

Copy the content of .env.example and paste on .env:

cp backend/core/.env.example backend/core/.env

Inside .env file, we already have some default values set. Then you can change to your taste:

mail-env

Running

Apply the migrations:

backend/manage.py migrate

Run the server:

backend/manage.py runserver

Endpoints

/api/register/

Body:

{
    "email": "some_email",
    "password": "some_passoword",
    "full_name": "some_name"
}

/api/login/

Body:

{
    "email": "some_email",
    "password": "some_passoword"
}

/api/user/

Header:

Authorization: Token <generated on login>

/api/logout/

Header:

Authorization: Token <generated on login>