8
0
Fork 0
mirror of https://gitlab2.federez.net/re2o/re2o synced 2024-12-25 00:13:45 +00:00

Cache le mot de passe de paiement comnpay

This commit is contained in:
Hugo LEVY-FALK 2018-07-04 18:03:23 +02:00
parent b64823f274
commit 9005161f33

View file

@ -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 @@
# 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
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):
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):
settings.AES_KEY, settings.AES_KEY,
value value
)) ))
def formfield(self, **kwargs):
defaults = {'form_class': AESEncryptedFormField}
defaults.update(kwargs)
return super().formfield(**defaults)