Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
R
re2o
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Nounous
re2o
Commits
193dfb67
Commit
193dfb67
authored
Jul 04, 2018
by
Hugo LEVY-FALK
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cache le mot de passe de paiement comnpay
parent
2aaf83d3
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
4 deletions
+12
-4
cotisations/payment_methods/comnpay/aes_field.py
cotisations/payment_methods/comnpay/aes_field.py
+12
-4
No files found.
cotisations/payment_methods/comnpay/aes_field.py
View file @
193dfb67
...
...
@@ -7,6 +7,7 @@
# Copyright © 2017 Goulven Kermarec
# Copyright © 2017 Augustin Lemesle
# Copyright © 2018 Maël Kervella
# Copyright © 2018 Hugo Levy-Falk
#
# 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
...
...
@@ -22,10 +23,7 @@
# with this program; if not, write to the Free Software Foundation, Inc.,
# 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
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
django.db
import
models
from
django
import
forms
from
django.conf
import
settings
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
]
class
AESEncryptedFormField
(
forms
.
CharField
):
widget
=
forms
.
PasswordInput
(
render_value
=
True
)
class
AESEncryptedField
(
models
.
CharField
):
""" A Field that can be used in forms for adding the support
of AES ecnrypted fields """
...
...
@@ -92,3 +95,8 @@ class AESEncryptedField(models.CharField):
settings
.
AES_KEY
,
value
))
def
formfield
(
self
,
**
kwargs
):
defaults
=
{
'form_class'
:
AESEncryptedFormField
}
defaults
.
update
(
kwargs
)
return
super
().
formfield
(
**
defaults
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment