From 43934d425f5512b356c66b24b5cfb75db6bba45c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adolfo=20G=C3=B3mez=20Garc=C3=ADa?= Date: Thu, 23 Jun 2022 15:56:14 +0200 Subject: [PATCH] added timeout value --- server/src/uds/REST/methods/mfas.py | 20 ++++++++++++++----- ...622_2133.py => 0043_auto_20220623_1555.py} | 3 ++- server/src/uds/models/mfa.py | 2 ++ 3 files changed, 19 insertions(+), 6 deletions(-) rename server/src/uds/migrations/{0043_auto_20220622_2133.py => 0043_auto_20220623_1555.py} (91%) diff --git a/server/src/uds/REST/methods/mfas.py b/server/src/uds/REST/methods/mfas.py index e6ee92a71..99d0e9d60 100644 --- a/server/src/uds/REST/methods/mfas.py +++ b/server/src/uds/REST/methods/mfas.py @@ -50,11 +50,7 @@ logger = logging.getLogger(__name__) class Notifiers(ModelHandler): path = 'mfa' model = models.MFA - save_fields = [ - 'name', - 'comments', - 'tags', - ] + save_fields = ['name', 'comments', 'tags', 'cache_device'] table_title = _('Notifiers') table_fields = [ @@ -76,6 +72,20 @@ class Notifiers(ModelHandler): localGui = self.addDefaultFields( mfa.guiDescription(), ['name', 'comments', 'tags'] ) + self.addField( + localGui, + { + 'name': 'cache_device', + 'value': '0', + 'minValue': '0', + 'label': gettext('Device Caching'), + 'tooltip': gettext( + 'Time in hours to cache device so MFA is not required again. User based.' + ), + 'type': gui.InputField.NUMERIC_TYPE, + 'order': 111, + }, + ) return localGui diff --git a/server/src/uds/migrations/0043_auto_20220622_2133.py b/server/src/uds/migrations/0043_auto_20220623_1555.py similarity index 91% rename from server/src/uds/migrations/0043_auto_20220622_2133.py rename to server/src/uds/migrations/0043_auto_20220623_1555.py index acddaaed4..8247d7c01 100644 --- a/server/src/uds/migrations/0043_auto_20220622_2133.py +++ b/server/src/uds/migrations/0043_auto_20220623_1555.py @@ -1,4 +1,4 @@ -# Generated by Django 3.2.10 on 2022-06-22 21:33 +# Generated by Django 3.2.10 on 2022-06-23 15:55 from django.db import migrations, models import django.db.models.deletion @@ -20,6 +20,7 @@ class Migration(migrations.Migration): ('data_type', models.CharField(max_length=128)), ('data', models.TextField(default='')), ('comments', models.CharField(max_length=256)), + ('cache_device', models.IntegerField(default=0)), ('tags', models.ManyToManyField(to='uds.Tag')), ], options={ diff --git a/server/src/uds/models/mfa.py b/server/src/uds/models/mfa.py index 671f4f4f3..0805d0f63 100644 --- a/server/src/uds/models/mfa.py +++ b/server/src/uds/models/mfa.py @@ -55,6 +55,8 @@ class MFA(ManagedObjectModel, TaggingMixin): # type: ignore objects: 'models.BaseManager[MFA]' authenticators: 'models.manager.RelatedManager[Authenticator]' + cache_device = models.IntegerField(default=0) # Time to cache the device MFA in hours + def getInstance( self, values: typing.Optional[typing.Dict[str, str]] = None ) -> 'mfas.MFA':