mirror of
https://github.com/jwinterm/modoboa.git
synced 2026-12-01 12:03:55 +01:00
First working version of the new 'message filters' plugin. Currently, only the raw edition mode is available. I also include my own MANAGESIEVE client implementation.
see #139
This commit is contained in:
@@ -0,0 +1,6 @@
|
||||
# coding: utf-8
|
||||
from modoboa.lib import parameters
|
||||
from django.utils.translation import ugettext as _
|
||||
|
||||
parameters.register_admin("SECRET_KEY", type="string", deflt="abcdefghijklmnop",
|
||||
help=_("Key used to encrypt/decrypt passwords"))
|
||||
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
# coding: utf-8
|
||||
|
||||
from Crypto.Cipher import AES
|
||||
import base64
|
||||
from modoboa.lib import parameters
|
||||
|
||||
def encrypt(clear):
|
||||
obj = AES.new(parameters.get_admin("SECRET_KEY"),
|
||||
AES.MODE_ECB)
|
||||
if len(clear) % AES.block_size:
|
||||
clear += "\0" * (AES.block_size - len(clear) % AES.block_size)
|
||||
ciph = obj.encrypt(clear)
|
||||
ciph = base64.b64encode(ciph)
|
||||
return ciph
|
||||
|
||||
def decrypt(ciph):
|
||||
obj = AES.new(parameters.get_admin("SECRET_KEY"), AES.MODE_ECB)
|
||||
ciph = base64.b64decode(ciph)
|
||||
clear = obj.decrypt(ciph)
|
||||
return clear.rstrip('\0')
|
||||
|
||||
def get_password(request):
|
||||
return decrypt(request.session["password"])
|
||||
|
||||
@@ -8,6 +8,7 @@ from django.utils.translation import ugettext as _
|
||||
from modoboa.lib import events
|
||||
import modoboa.admin
|
||||
from forms import LoginForm
|
||||
from modoboa.auth.lib import *
|
||||
|
||||
def dologin(request):
|
||||
error = None
|
||||
@@ -19,6 +20,9 @@ def dologin(request):
|
||||
if user.is_active:
|
||||
login(request, user)
|
||||
|
||||
if request.user.id != 1:
|
||||
request.session["password"] = encrypt(request.POST["password"])
|
||||
|
||||
events.raiseEvent("UserLogin", request=request,
|
||||
username=request.POST["username"],
|
||||
password=request.POST["password"])
|
||||
|
||||
Reference in New Issue
Block a user