diff --git a/account/forms.py b/account/forms.py index 8d0ca58..c2df4a8 100755 --- a/account/forms.py +++ b/account/forms.py @@ -5,7 +5,7 @@ import re from django import forms from django.contrib.auth import authenticate -from django.utils.translation import ugettext as _ +from django.utils.translation import gettext as _ class UsernameField(forms.CharField): diff --git a/account/password_encryption.py b/account/password_encryption.py index 6cfe8d0..370fd3f 100644 --- a/account/password_encryption.py +++ b/account/password_encryption.py @@ -2,6 +2,7 @@ # -*- coding: utf-8 -*- import base64 +import os from Crypto import Random from Crypto.Cipher import AES @@ -19,10 +20,11 @@ def encrypt_ldap_password(cleartext_pw): """ # 16 bytes of key => AES-128 random = Random.new() - key = random.read(16) + key = os.urandom(16) # random.read(16) + # initialization vector - iv = random.read(16) + iv = os.urandom(16) # random.read(16) # do the encryption aes = AES.new(key, AES.MODE_CFB, iv) diff --git a/account/templates/base.html b/account/templates/base.html index d59cf41..eac4491 100644 --- a/account/templates/base.html +++ b/account/templates/base.html @@ -156,7 +156,7 @@ {% endblock container %}
- Copyright © 2013 by c-base e.V. + Copyright © 2022 by c-base e.V.
{% endblock body %} diff --git a/account/urls.py b/account/urls.py index a5f919e..2b05715 100644 --- a/account/urls.py +++ b/account/urls.py @@ -1,21 +1,21 @@ from account.views import (admin, auth_login, auth_logout, clabpin, gastropin, groups_list, home, memberstatus, nrf24, password, preferred_email, rfid, sippin, wlan_presence) -from django.conf.urls import url +from django.urls import re_path urlpatterns = [ - url(r'^login/$', auth_login, name="cbase_auth_login"), - url(r'^logout/$', auth_logout, name="auth_logout"), - url(r'^gastropin/$', gastropin, name='gastropin'), - url(r'^wlan_presence/$', wlan_presence, name='wlan_presence'), - url(r'^rfid/$', rfid, name='rfid'), - url(r'^nrf24/$', nrf24, name='nrf24'), - url(r'^password/$', password, name='password'), - url(r'^sippin/$', sippin, name='sippin'), - url(r'^clabpin/$', clabpin, name='clabpin'), - url(r'^preferred_email/$', preferred_email, name='preferred_email'), - url(r'^admin/$', admin, name='admin'), - url(r'^memberstatus/$', memberstatus, name='memberstatus'), - url(r'^$', home, name="home"), - url(r'^groups/(?P[^/]+)/', groups_list), + re_path(r'^login/$', auth_login, name="cbase_auth_login"), + re_path(r'^logout/$', auth_logout, name="auth_logout"), + re_path(r'^gastropin/$', gastropin, name='gastropin'), + re_path(r'^wlan_presence/$', wlan_presence, name='wlan_presence'), + re_path(r'^rfid/$', rfid, name='rfid'), + re_path(r'^nrf24/$', nrf24, name='nrf24'), + re_path(r'^password/$', password, name='password'), + re_path(r'^sippin/$', sippin, name='sippin'), + re_path(r'^clabpin/$', clabpin, name='clabpin'), + re_path(r'^preferred_email/$', preferred_email, name='preferred_email'), + re_path(r'^admin/$', admin, name='admin'), + re_path(r'^memberstatus/$', memberstatus, name='memberstatus'), + re_path(r'^$', home, name="home"), + re_path(r'^groups/(?P[^/]+)/', groups_list), ] diff --git a/account/views.py b/account/views.py index 4d41236..43aed10 100755 --- a/account/views.py +++ b/account/views.py @@ -15,7 +15,8 @@ from django.http import HttpResponse, HttpResponseRedirect from django.shortcuts import get_object_or_404 from django.shortcuts import render from django.shortcuts import render -from django.utils.translation import ugettext as _ +# from django.utils.translation import ugettext as _ +from django.utils.translation import gettext as _ import smbpasswd from account.cbase_members import retrieve_member, MemberValues diff --git a/cbapi_ldap/urls.py b/cbapi_ldap/urls.py index f515de9..a99f908 100644 --- a/cbapi_ldap/urls.py +++ b/cbapi_ldap/urls.py @@ -1,6 +1,4 @@ -from django.conf.urls import url -# from jsonrpc import jsonrpc_site -# from jsonrpc.views import browse +from django.urls import re_path from cbapi_ldap import views diff --git a/cbmi/urls.py b/cbmi/urls.py index d0b2516..35668d7 100644 --- a/cbmi/urls.py +++ b/cbmi/urls.py @@ -1,4 +1,4 @@ -from django.conf.urls import include, url +from django.urls import include, re_path from django.contrib import admin from account.views import hammertime, landingpage @@ -6,13 +6,13 @@ admin.autodiscover() urlpatterns = [ - url(r'^stop/hammertime/$', hammertime, name="hammertime"), - url(r'^admin/doc/', include('django.contrib.admindocs.urls')), - url(r'^admin/', admin.site.urls), - url(r'^cbapi/', include("cbapi_ldap.urls")), + re_path(r'^stop/hammertime/$', hammertime, name="hammertime"), + re_path(r'^admin/doc/', include('django.contrib.admindocs.urls')), + re_path(r'^admin/', admin.site.urls), + re_path(r'^cbapi/', include("cbapi_ldap.urls")), - url(r'account/', include('account.urls')), + re_path(r'account/', include('account.urls')), - url(r'^$', landingpage, name="landingpage"), + re_path(r'^$', landingpage, name="landingpage"), ] diff --git a/pop_members.py b/pop_members.py index 32e29d8..d8a464c 100644 --- a/pop_members.py +++ b/pop_members.py @@ -55,7 +55,7 @@ def all_members(): def populate_members(): """fetch all members, sort them and populate the Django database""" for m in sorted(all_members()): - member = LDAPBackend().populate_user(m) + member = LDAPBackend().populate_user(m.decode()) if member: print('Populated: %s' % member) else: diff --git a/requirements.txt b/requirements.txt index 6cbdecf..6f56794 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,8 +1,45 @@ -Django==3.2.8 -django-auth-ldap==3.0.0 -# django-json-rpc>=0.7.2 -django-crispy-forms>=1.13.0 -gunicorn>=20.1.0 -pycrypto>=2.6.1 -passlib -requests>=2.26.0 +# +# This file is autogenerated by pip-compile with python 3.9 +# To update, run: +# +# pip-compile +# +asgiref==3.5.2 + # via django +certifi==2022.5.18.1 + # via requests +charset-normalizer==2.0.12 + # via requests +django==4.0.5 + # via + # -r requirements.in + # django-auth-ldap +django-auth-ldap==4.1.0 + # via -r requirements.in +django-crispy-forms==1.14.0 + # via -r requirements.in +gunicorn==20.1.0 + # via -r requirements.in +idna==3.3 + # via requests +passlib==1.7.4 + # via -r requirements.in +pyasn1==0.4.8 + # via + # pyasn1-modules + # python-ldap +pyasn1-modules==0.2.8 + # via python-ldap +pycrypto==2.6.1 + # via -r requirements.in +python-ldap==3.4.0 + # via django-auth-ldap +requests==2.28.0 + # via -r requirements.in +sqlparse==0.4.2 + # via django +urllib3==1.26.9 + # via requests + +# The following packages are considered to be unsafe in a requirements file: +# setuptools