diff --git a/apps/authentication/api/connection_token.py b/apps/authentication/api/connection_token.py index b8690ba28..fbeacb96b 100644 --- a/apps/authentication/api/connection_token.py +++ b/apps/authentication/api/connection_token.py @@ -223,12 +223,17 @@ class ExtraActionApiMixin(RDPFileClientProtocolURLMixin): validate_exchange_token: callable @action(methods=['POST', 'GET'], detail=True, url_path='rdp-file') - def get_rdp_file(self, *args, **kwargs): + def get_rdp_file(self, request, *args, **kwargs): token = self.get_object() token.is_valid() filename, content = self.get_rdp_file_info(token) - filename = '{}.rdp'.format(filename) response = HttpResponse(content, content_type='application/octet-stream') + + if is_true(request.query_params.get('reusable')): + token.set_reusable(True) + filename = '{}-{}'.format(filename, token.date_expired.strftime('%Y%m%d_%H%M%S')) + + filename += '.rdp' response['Content-Disposition'] = 'attachment; filename*=UTF-8\'\'%s' % filename return response diff --git a/apps/authentication/models/connection_token.py b/apps/authentication/models/connection_token.py index 2ef28eab1..f07874a2a 100644 --- a/apps/authentication/models/connection_token.py +++ b/apps/authentication/models/connection_token.py @@ -82,12 +82,15 @@ class ConnectionToken(JMSOrgBaseModel): self.save(update_fields=['date_expired']) def set_reusable(self, is_reusable): + if not settings.CONNECTION_TOKEN_REUSABLE: + return self.is_reusable = is_reusable if self.is_reusable: seconds = settings.CONNECTION_TOKEN_REUSABLE_EXPIRATION else: seconds = settings.CONNECTION_TOKEN_ONETIME_EXPIRATION - self.date_expired = timezone.now() + timedelta(seconds=seconds) + + self.date_expired = self.date_created + timedelta(seconds=seconds) self.save(update_fields=['is_reusable', 'date_expired']) def renewal(self): diff --git a/apps/terminal/connect_methods.py b/apps/terminal/connect_methods.py index 72007112d..0294ccab1 100644 --- a/apps/terminal/connect_methods.py +++ b/apps/terminal/connect_methods.py @@ -34,6 +34,7 @@ class NativeClient(TextChoices): db_client = 'db_client', _('DB Client') # Razor mstsc = 'mstsc', _('Remote Desktop') + rdp_guide = 'rdp_guide', _('RDP Guide') @classmethod def get_native_clients(cls):