Commit 193dfb67 authored by Hugo LEVY-FALK's avatar Hugo LEVY-FALK

Cache le mot de passe de paiement comnpay

parent 2aaf83d3
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
# Copyright © 2017 Goulven Kermarec # Copyright © 2017 Goulven Kermarec
# Copyright © 2017 Augustin Lemesle # Copyright © 2017 Augustin Lemesle
# Copyright © 2018 Maël Kervella # Copyright © 2018 Maël Kervella
# Copyright © 2018 Hugo Levy-Falk
# #
# This program is free software; you can redistribute it and/or modify # This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by # it under the terms of the GNU General Public License as published by
...@@ -22,10 +23,7 @@ ...@@ -22,10 +23,7 @@
# with this program; if not, write to the Free Software Foundation, Inc., # with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
# App de gestion des machines pour re2o """
# Gabriel Détraz, Augustin Lemesle
# Gplv2
"""preferences.aes_field
Module defining a AESEncryptedField object that can be used in forms Module defining a AESEncryptedField object that can be used in forms
to handle the use of properly encrypting and decrypting AES keys to handle the use of properly encrypting and decrypting AES keys
""" """
...@@ -36,6 +34,7 @@ from random import choice ...@@ -36,6 +34,7 @@ from random import choice
from Crypto.Cipher import AES from Crypto.Cipher import AES
from django.db import models from django.db import models
from django import forms
from django.conf import settings from django.conf import settings
EOD = '`%EofD%`' # This should be something that will not occur in strings EOD = '`%EofD%`' # This should be something that will not occur in strings
...@@ -66,6 +65,10 @@ def decrypt(key, s): ...@@ -66,6 +65,10 @@ def decrypt(key, s):
return ss.split(bytes(EOD, 'utf-8'))[0] return ss.split(bytes(EOD, 'utf-8'))[0]
class AESEncryptedFormField(forms.CharField):
widget = forms.PasswordInput(render_value=True)
class AESEncryptedField(models.CharField): class AESEncryptedField(models.CharField):
""" A Field that can be used in forms for adding the support """ A Field that can be used in forms for adding the support
of AES ecnrypted fields """ of AES ecnrypted fields """
...@@ -92,3 +95,8 @@ class AESEncryptedField(models.CharField): ...@@ -92,3 +95,8 @@ class AESEncryptedField(models.CharField):
settings.AES_KEY, settings.AES_KEY,
value value
)) ))
def formfield(self, **kwargs):
defaults = {'form_class': AESEncryptedFormField}
defaults.update(kwargs)
return super().formfield(**defaults)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment