Skip to main content

A simple django application provides function to encrypt password value with rsa public key before form submit and decrypt at the backend.

Project description

django-secure-password-input

A simple django application provides function to encrypt password value with rsa public key before form submit and decrypt at the backend.

Install

pip install django-secure-password-input

Usage

pro/settings.py

INSTALLED_APPS = [
    ...
    'django_secure_password_input',
    ...
]

DJANGO_SECURE_PASSWORD_INPUT_RSA_PRIVATE_KEY = """-----BEGIN RSA PRIVATE KEY-----
......
-----END RSA PRIVATE KEY-----
"""

DJANGO_SECURE_PASSWORD_INPUT_ENCRYPTED_VALUE_PREFIX = "rsa-encrypted:"

Note:

  1. Add your own DJANGO_SECURE_PASSWORD_INPUT_RSA_PRIVATE_KEY and keep it secret. You can generate rsa private key with rsa module in ipython. Copy all things between "BEGIN RSA PRIVATE KEY" and "END RSA PRIVATE KEY" and must include "BEGIN RSA PRIVATE KEY" and "END RSA PRIVATE KEY" lines. It will work if you not provide your own private key, it will use the django_secure_password_input's default private key, and it's not safe for you.

    In [3]: import rsa
    
    In [4]: pk, sk = rsa.newkeys(1024)
    
    In [5]: print(sk.save_pkcs1().decode())
    -----BEGIN RSA PRIVATE KEY-----
    MIICXwIBAAKBgQCluABEZpoy8lIL8oZNBB7xsc8sh5LOBrT1aLW0F1BpguimwUn4
    K7XDgCP95WWzbp/cHDxl16bKlc15u7TZANOt7iCfdS7BsqXykIh7tts4bl2j95bD
    bwTcpf5kTr0QuqCtPk//nlHWxexeXerSuFzgiYC8vlwrVX+AvuMBVcDqIQIDAQAB
    AoGABcH32GiMMPr0WM/rVJ+xB4q6/PwU4K2g+enSblhlBdVzid+rV0EFhq5cEcU3
    nF1aloYwnwU4GU/NHM6luOL0gbchyksyLKorkNkpElohi1Ek05CCvno7inZ2F4H4
    iffnGp85TczkUa7NHcHPZwCSz/AWbyPYFtLJebjTorFDxRUCRQDm3kRetWgUYdyJ
    bn8nwJhR2rg3Cqu/PbSlx7Q7NirYCwr8Zb8HnDEsRuC8ew7p1MEUYLiAAT6gP9yZ
    b+08eY9AWIQsxwI9ALfCLWo/UbCVbmsFlZjay2Mva4A44ME5vBn4Zky7hR9FxZvC
    zzdV2d5v+3iygQVfzr8hJQ9Xr96LfAE51wJFAKZ/ZY9oBMeuS/5RUiK5IyDlPDV1
    3KbvOXjVrYWGax+j1yhvuHUkj9H+y9Uian74kMbBek3Wl/O6Gr4NmmoiwM0HCUvB
    AjtkfcxYTkheSVoZLPSiowSXOVeQx4oiIXC8wxsu213xvDZU+DRaDpkXDCZ52ySz
    y7FE1NtviISlL6KhCQJEYI1y9vkvSl+aSj+ayyg6cELqfa/m7XDqsxMId5RTdfcS
    MIUYyH+SOGlp2QEpJqEWABa8aTw0PD68vftmdichTVQue9w=
    -----END RSA PRIVATE KEY-----
    

app/admin.py

from django.contrib import admin
from django import forms
from django_secure_password_input.fields import DjangoSecurePasswordInput
from .models import Account


class AccountForm(forms.ModelForm):
    password = DjangoSecurePasswordInput()

    class Meta:
        model = Account
        exclude = []

class AccountAdmin(admin.ModelAdmin):
    form = AccountForm
    list_display = ["username", "password"]

admin.site.register(Account, AccountAdmin)

Note:

  1. Create a form, and override password field using type DjangoSecurePasswordInput.

Release

v0.1.2 2020/09/24

  • Fix doc.
  • Add License file.

v0.1.1 2020/09/01

  • No depends on django-static-jquery3.

v0.1.0 2020/03/07

  • First release.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-secure-password-input-0.1.2.tar.gz (62.0 kB view details)

Uploaded Source

File details

Details for the file django-secure-password-input-0.1.2.tar.gz.

File metadata

  • Download URL: django-secure-password-input-0.1.2.tar.gz
  • Upload date:
  • Size: 62.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.24.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.7.7

File hashes

Hashes for django-secure-password-input-0.1.2.tar.gz
Algorithm Hash digest
SHA256 6cf972b84f67156615e61d2430a02c6d88a0fcc858751f89a6efc975b1bb8478
MD5 ed3aa780fb6327bf0fe987379d293f40
BLAKE2b-256 3abd2304afdf9f872a0a56404fa202a414be4f23871e1456d8a135341b35ab05

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page