Generate a secured base32 one time password to authenticate your user! πŸ”

Overview

Django SOTP πŸ”

Generate a secured base32 one time password to authenticate your user!


Case Study πŸ“‘

Before I mention why you should use django-sotp in your next project, have you every had to build from scratch; every time, a layer of your authentication system?

Ah, yesss - me too, I know the feeling. With django-sotp, you won't have to worry about figuring out how to build that layer of your authentication infrastructure. That's right, this package does everything you'd need, or not.

Django SOTP does just two things, and it does them really well.

  • One - it is stupidly secured and simple to integrate
  • Two - it clears out OTPs at elapsed time

Damn yes, you saw right! You don't have to worry about making the last reason happen, it's been done for you. All you need to do is figure out how to implement it onto your system. Super cool, yes? I knowwwwww.


Installation ⏳

Installing django-sotp is very easy, you'll be using (I'd recommend you use a virtual environment, so you don't break your system) the command pip.

Here's how to go about it:

pip install django-sotp

Next is, adding the installed packages to your project:

INSTALLED_APPS = [
    ...
    'sotp',    
]

Now you've done it, all you need to do is add the time which you want your OTPs to expire:

SOTP_TIME_EXPIRATION = 5 # in minutes

Now, you set the email address that you want to use to send emails to your user(s):

SOTP_FROM_EMAIL = "[email protected]" # replace the email

Yesss. That's all of it? Of course, not! Don't forget to make migrations and migrate to your database and you're good to go!!

python manage.py makemigrations && python manage.py migrate

Congratulations, buddy! You're all set! Let's jump right into how to start using it.


How-To Use πŸ“

You've got django-sotp installed and ready to use, here's how to start using it!

  • Step 1: Import the library to the file you want to use
from sotp.services import GenerateSOTP
  • Step 2: Instantiate the class
otp = GenerateSOTP()
  • Step 3: Call the generate_otp logic (method) directly in the logics or views file, and pass the user's email; since generate_otp requires the user email address to generate the otp code.
# Generate otp code for user
otp.generate_otp(user_email=user.email) 
  • Step 4: Everything will be handled for you πŸ€“ . A base32 secured token and code has been created, saved and sent to the user! Oh, let's not forget about the scheduler that has been called to remove the user otp and token after the SOTP_TIME_EXPIRATION has elapsed! 🀝
  • Last Step (maybe?): You can call the function anywhere, anytime.

If you are still finding it difficult to use this package, kindly check the example app I made for reference, or create an issue and state the problem you are experiencing!


Shell Example πŸ₯

Try to test out this baby on your shell? Let's go then!

  • Step 1: Run the command:
python manage.py shell
  • Step 2: Import the libray directly on the shell:
from sotp.services import GenerateSOTP
  • Step 3: Call the generate_otp method, don't forget to add a user email address:
otp.generate_otp(user_email="[email protected]")
  • Step 4: Token and OTP is generated, sent to user via email, and saved to database.
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Subject: Confirm OTP
From: [email protected]
To: [email protected]
Date: Tue, 07 Jun 2022 12:04:37 -0000
Message-ID: <165460347795.27037.15319720132602712964@sonOdin> 

Use this secured OTP to authenticate your account
OTP: 957092
-------------------------------------------------------------------------------
Scheduler started...
{'totp': '5ZCLA7UQVXFP2B5WL5OZG4QDFDJ4GL65', 'OTP': '957092'}
Comments
  • Bump django from 4.0.4 to 4.0.6

    Bump django from 4.0.4 to 4.0.6

    Bumps django from 4.0.4 to 4.0.6.

    Commits
    • caad462 [4.0.x] Bumped version for 4.0.6 release.
    • c732152 [4.0.x] Updated man page for Django 4.0.6.
    • 0dc9c01 [4.0.x] Fixed CVE-2022-34265 -- Protected Trunc(kind)/Extract(lookup_name) ag...
    • a2b88d7 [4.0.x] Fixed typo in docs/topics/signals.txt.
    • 2b901c1 [4.0.x] Fixed GEOSTest.test_emptyCollections() on GEOS 3.8.0.
    • 4d20d2f [4.0.x] Fixed docs build with sphinxcontrib-spelling 7.5.0+.
    • 8a294ee [4.0.x] Added stub release notes and release date for 4.0.6 and 3.2.14.
    • 1c28443 [4.0.x] Fixed CoveringIndexTests.test_covering_partial_index() when DEFAULT_I...
    • 0f3b250 [4.0.x] Fixed #33789 -- Doc'd changes in quoting table/column names on Oracle...
    • 6661c48 [4.0.x] Updated OWASP Top 10 link in security topic.
    • Additional commits viewable in compare view

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    • @dependabot use these labels will set the current labels as the default for future PRs for this repo and language
    • @dependabot use these reviewers will set the current reviewers as the default for future PRs for this repo and language
    • @dependabot use these assignees will set the current assignees as the default for future PRs for this repo and language
    • @dependabot use this milestone will set the current milestone as the default for future PRs for this repo and language

    You can disable automated security fix PRs for this repo from the Security Alerts page.

    dependencies 
    opened by dependabot[bot] 1
  • ModuleNotFoundError: No module named 'pyotp'

    ModuleNotFoundError: No module named 'pyotp'

    After installing the package, I registered it to my installed apps and imported the class GenerateSOTP to my file; then I got the error "no module named pyotp found".

    bug dependencies 
    opened by aybruhm 0
  • Bump django from 4.0.4 to 4.0.6

    Bump django from 4.0.4 to 4.0.6

    Bumps django from 4.0.4 to 4.0.6.

    Commits
    • caad462 [4.0.x] Bumped version for 4.0.6 release.
    • c732152 [4.0.x] Updated man page for Django 4.0.6.
    • 0dc9c01 [4.0.x] Fixed CVE-2022-34265 -- Protected Trunc(kind)/Extract(lookup_name) ag...
    • a2b88d7 [4.0.x] Fixed typo in docs/topics/signals.txt.
    • 2b901c1 [4.0.x] Fixed GEOSTest.test_emptyCollections() on GEOS 3.8.0.
    • 4d20d2f [4.0.x] Fixed docs build with sphinxcontrib-spelling 7.5.0+.
    • 8a294ee [4.0.x] Added stub release notes and release date for 4.0.6 and 3.2.14.
    • 1c28443 [4.0.x] Fixed CoveringIndexTests.test_covering_partial_index() when DEFAULT_I...
    • 0f3b250 [4.0.x] Fixed #33789 -- Doc'd changes in quoting table/column names on Oracle...
    • 6661c48 [4.0.x] Updated OWASP Top 10 link in security topic.
    • Additional commits viewable in compare view

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    • @dependabot use these labels will set the current labels as the default for future PRs for this repo and language
    • @dependabot use these reviewers will set the current reviewers as the default for future PRs for this repo and language
    • @dependabot use these assignees will set the current assignees as the default for future PRs for this repo and language
    • @dependabot use this milestone will set the current milestone as the default for future PRs for this repo and language

    You can disable automated security fix PRs for this repo from the Security Alerts page.

    dependencies 
    opened by dependabot[bot] 0
  • Add support for HTML email

    Add support for HTML email

    By default, email been sent to the user is plain text. Add support for a custom html email.

    If you can take this up, feel free to comment. So I'd assign it to you.

    enhancement good first issue 
    opened by aybruhm 0
  • Include from_email option to send email to user

    Include from_email option to send email to user

    I noticed that there was no way to change the default from_email to mine. So I fixed that by creating a global variable in the settings.py file and importing it into the send_otp_email method.

    opened by Sophyia7 0
Releases(v1.0.4)
  • v1.0.4(Oct 1, 2022)

    • Implemented unit test
    • Refactored generate sotp method
    • Renamed UserSOTP table name to secured_otps
    • Update documentation

    Full Changelog: https://github.com/israelabraham/django-sotp/compare/v1.0.3...v1.0.4

    Source code(tar.gz)
    Source code(zip)
  • v1.0.3(Jul 23, 2022)

    • Include pyotp to install_requires
    • Bump version from 1.0.2 to 1.0.3
    • Include sotp/helpers folder

    What's Changed

    • Bump django from 4.0.4 to 4.0.6 by @dependabot in https://github.com/israelabraham/django-sotp/pull/5

    New Contributors

    • @dependabot made their first contribution in https://github.com/israelabraham/django-sotp/pull/5

    Full Changelog: https://github.com/israelabraham/django-sotp/compare/v1.0.2...v1.0.3

    Source code(tar.gz)
    Source code(zip)
  • v1.0.2(Jun 8, 2022)

    • Include SOTP_FROM_EMAIL option to change default "from_email" address
    • Bump version from 1.0.1 to 1.0.2
    • Update REAME.md file

    What's Changed

    • Include from_email option to send email to user by @Sophyia7 in https://github.com/israelabraham/django-sotp/pull/1
    • Readme update by @Sophyia7 in https://github.com/israelabraham/django-sotp/pull/3

    New Contributors

    • @Sophyia7 made their first contribution in https://github.com/israelabraham/django-sotp/pull/1

    Full Changelog: https://github.com/israelabraham/django-sotp/compare/v1.0.1...v1.0.2

    Source code(tar.gz)
    Source code(zip)
    django_sotp-1.0.2.tar.gz(12.73 KB)
  • v1.0.1(Jun 7, 2022)

  • v1.0(Jun 7, 2022)

Owner
をブラム (Abram)
Fullstack Python Engineer.
をブラム (Abram)
Fast & minimal implementation of bech32, base64, base32, base16 & base58

micro-base Fast and minimal implementation of bech32, base64, base58, base32 & base16. Matches following specs: Bech32, Bech32m: BIP173, BIP350 Base16

Paul Miller 45 Jan 4, 2023
A Gun DB extension that ships secure* ephemeral messaging between Gun peers using Bugout, secured by Gun's SEA suite

Bugoff A Gun DB extension that ships secure* ephemeral messaging between Gun peers using Bugout, secured by Gun's SEA suite About Bugoff creates an SE

Daniel Raeder 14 Nov 12, 2022
Utility for authorizing user in a connected app, creating JWT to authenticate against it, and perform a sample callout.

Question: What is this for? Answer: When configuring a Salesforce Connected app to use certificates to authenticate you will use JSON Web Tokens to a

null 4 Jun 15, 2022
Download all Moodle files with one click. This is a Chrome extension built to save time and effort from downloading files manually one by one!

Moodle Downloader Extension Moodle downloader extension for Chrome. The extension is tested with both the TUM moodle and the official moodle demo. Not

Zhongpin Wang 8 Nov 15, 2022
Generate a password based off user inputs with speed ⚑

speedy-speedy-password Generate a password based off user inputs with speed ⚑ Install NPM npm i speedy-speedy-password Yarn yarn add speedy-speedy-pa

Brayden 5 Feb 2, 2022
Authenticate your Replit Users without ReplAuth.

Replit Login An unofficial way to authenticate your Replit users Authenticate Replit users in your projects without ReplAuth. This uses the actual Rep

Ray 8 Aug 11, 2022
Save time by managing bills & expenses, invoicing & easy reconciliation all in one app. Generate clear dynamic statements and get your reports, the way you like them

expense-manager-app (Opensource Expense Tracking App built with React) ?? Save time by managing bills & expenses, invoicing & easy reconciliation all

Muhammad Awais 3 Oct 12, 2022
Authenticate users into a web2 database to build a hybrid web2+web3 creator platform!

Creator Platform This project demonstrates how you can connect your web2 backend and integrate it with web3 using sign in with ethereum. Tools: React

thirdweb templates 6 Dec 16, 2022
Generate Password is a generating random and unique passwords.

Generate Password Generate Password is a generating random and unique passwords. Install $ npm install @wcj/generate-password --save Usage import { ge

ε°εΌŸθ°ƒθ°ƒβ„’ 4 Jun 16, 2022
A real time Web-App for one to one chatting.

We-Vibe A real time web-app for one to one chatting. The project is broadly divided into two parts - Server and Public (client). The Socket.io module

Sushmita Kumari 6 Dec 15, 2022
A novel approach for security and user experience of Graphical Password Authentication.

Graphical Password Authentication Alohomora Harry Potter themed (not really) Graphical Password Authentication Flowchart and Architecture Solution Dem

Akshat Shah 10 Dec 15, 2022
Grayce Muthui 8 Jun 16, 2022
More than a Password Protection and Management tool, it secures all your valuable digital assets in your own vault

ZeroPass Client ZeroPass is more than a Password Protection and Management tool, it secures all your valuable digital assets in your own vault, includ

null 6 Aug 22, 2022
⛺️ Tipi is a homeserver for everyone! One command setup, one click installs for your favorites self-hosted apps. ✨

⛺️ Tipi β€” A personal homeserver for everyone ⚠️ Tipi is still at an early stage of development and issues are to be expected. Feel free to open an iss

Nicolas Meienberger 4.9k Jan 4, 2023
Check the strength of your password simply and quickly, and with optional UI indicators

Check the strength of your password simply and quickly, and with optional UI indicators. Lock Steel is lightweight, has no dependencies and is connected with the UI elements. Just pure CSS and VanillaJS.

Keenlabi 1 Sep 15, 2022
Create your own password generator using jQuery, Vanilla JS, and SASS.

Password Generator Create your own password generator using jQuery, Vanilla JS, and SASS. I have been working with JS for my last few projects so I th

The Dev Drawer 1 Jul 12, 2021
A simple interface module that creates password-policy for your application.

This module is a simple alternate to creating complex native Regex, or tidious multidimensional checks on password-string to check required elements.

Snigdh Shourya 3 Oct 27, 2022
Your whole team, changing the world one stroke at a time.

Collanvas β€” Your whole team, changing the world one stroke at a time ?? With an online whiteboard, you can brainstorm ?? , draw art ??️ , and even pla

Eluda 12 Dec 29, 2022