Commit 1ed4161a authored by Élie Bouttier's avatar Élie Bouttier

Mot de passe pseudo aléatoire par IP public

parent 7e22c0ae
......@@ -397,6 +397,8 @@ class IPResourceAdmin(admin.ModelAdmin):
fields += ['last_use']
if obj and obj.last_time_up and obj.last_check:
fields += ['last_time_up', 'last_check']
if obj.category == IPResource.CATEGORY_PUBLIC:
fields += ['password']
if obj and obj.checkmk_label:
fields += ['checkmk']
if obj and obj.notes:
......
......@@ -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'
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment