Git Product home page Git Product logo

django-authy-2fa-test's Introduction

django-authy-2fa-test

Test project implementing rest api for two factor authentication using django rest framework, rest_auth and authy servie for 2FA.

API Endpoints

User Details

/rest-auth/user/
Allow: GET, PUT, PATCH

- On GET/PUT/PATCH: returns: 'email', 'username', 'auth_method', 'authy_id'
- On PUT allow to change auth_method. Values: 'SMS' (sms confirm) and 
  'ATH'(authy one touch confirm)
# HTTP 200 OK
{
    "email": "[email protected]",
    "username": "testuser",
    "auth_method": "ATH",
    "authy_id": "200133705"
}

Set Phone

/rest-auth/phone/
Allow: PUT, PATCH

Change two factor authentication phone number of user
previously logged in

Accept the following parameters: country_code, phone
Return username and new authy_id
# HTTP 200 OK
{
    "username": "testuser",
    "authy_id": 200142333
}

Register

/rest-auth/registration/
Allow: POST

New user registration. Register new user in django db and authy service 
# HTTP 201 Created
{
    "key": "a1472e7551f4ad4c581bb941e0ce7b44f8832bdf"
}

Request Confirmation Code

/rest-auth/login/request-code/ Allow: POST

Request SMS or Authy Notification confirmation code,
depending on user.authy_method state
If user is logged in in django then username and password
could be skipped

Accept the following POST parameters: username, password
Authy one touch uuid or "SMS token was send" message  
# HTTP 200 OK
{
    "uuid": "0389d5b0-d6a9-0137-f041-0a44db1d137e"
}  
or
# HTTP 200 OK
{
    "success": true,
    "message": "SMS token was sent",
    "cellphone": "+7-XXX-XXX-XX36"
}

Login

/rest-auth/login/
Allow: POST

Check the credentials and return the REST Token
if the credentials are valid and authenticated.
Calls Django Auth login method to register User ID
in Django session framework

Accept the following POST parameters: username, password, confirmation_code
Return the REST Framework Token Object's key.    
# HTTP 200 OK
{
    "key": "21580883ddc29e94a7d8b675b021868174d62f0e"
}
or 
# HTTP 403 Forbidden
{
    "detail": "SMS/Authy verification failed"
}

Logout

/rest-auth/logout/ Allow: POST

Calls Django logout method and delete the Token object
assigned to the current User object.

Accepts/Returns nothing.

Password Change

/rest-auth/password/change/ Allow: POST

Calls Django Auth SetPasswordForm save method.

Accepts the following POST parameters: new_password1, new_password2
Returns the success/fail message.

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.