GithubHelp home page GithubHelp logo

django-hibp-validator's Introduction

Django password validator via Have I Been Pwned

This is a custom Django password validator that can be integrated within your Django app to prevent users from using Pwned passwords.

Why?

  • Pwned Passwords are more than half a billion passwords which have previously been exposed in data breaches.

  • Strong password policies aren't prevalent these days.

  • Credential stuffing is a real concern and this helps prevent users from using compromised passwords.

  • No need to store or maintain a database of compromised passwords.

  • Always Query against the latest list of compromised passwords.

Is this safe?

Recently (05 MARCH 2020), Have I Been Pwned increased its anonymity for checking Pwned passwords on top of their K-anonymity model.

The new anonymity implementation helps consumers of the service to hit the API without worrying about possible inference of queries to hashes via Man-in-the-middle attack or encrypted traffic observation.

This is achieved by padding of response data returned from HIBP as now the response would always consist random number of records between 800 and 1,000.

Thus, API calls to validate pwned passwords is pretty safe and attackers sniffing traffic cannot reasonably determine which hash prefix was searched for by observing the response size.

How to implement ?

To integrate this within your Django app, simply add the contents of django-validator.py into your validator.py. If your project doesn't have a validator.py you can create one within your primary Django project directory. Next, add your recently added validator within your Django settings.py like this:

# Password validation
# https://docs.djangoproject.com/en/2.1/ref/settings/#auth-password-validators

AUTH_PASSWORD_VALIDATORS = [
    {
        'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
    },
    {
        'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
    },
    {
        'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
    },
    {
        'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
    },
    {
        'NAME': '<project_path>.validator.HIBPCheck',
    },
]

In the above example, replace <project_path> with your path of the validator.py within your Django app.

More on Pwned password check can be found at: https://haveibeenpwned.com/API/v3#PwnedPasswords

django-hibp-validator's People

Contributors

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