|
@@ -14,6 +14,8 @@ from django.conf import settings
|
|
|
|
|
|
from ipaddress import ip_network
|
|
|
from urllib.parse import quote
|
|
|
+from hashlib import sha256
|
|
|
+from base64 import urlsafe_b64encode
|
|
|
|
|
|
from djadhere.utils import get_active_filter, is_overlapping
|
|
|
from adhesions.models import Adhesion
|
|
@@ -119,6 +121,11 @@ class IPResource(models.Model):
|
|
|
else:
|
|
|
return None
|
|
|
|
|
|
+ def password(self):
|
|
|
+ data = sha256((settings.MASTER_PASSWORD + self.ip).encode('utf-8')).digest();
|
|
|
+ return urlsafe_b64encode(data).decode('utf-8')[:8]
|
|
|
+ password.short_description = 'Mot de passe'
|
|
|
+
|
|
|
class Meta:
|
|
|
ordering = ['ip']
|
|
|
verbose_name = 'IP'
|