diff --git a/VERSION b/VERSION index 437459cd9..4a36342fc 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -2.5.0 +3.0.0 diff --git a/server/.pydevproject b/server/.pydevproject index d9ba589d2..05db2ee1c 100644 --- a/server/.pydevproject +++ b/server/.pydevproject @@ -1,7 +1,7 @@ -Default -python 2.7 +python3.5 +python 3.0 DJANGO_MANAGE_LOCATION src/manage.py diff --git a/server/src/uds/REST/methods/client.py b/server/src/uds/REST/methods/client.py index 113eaf24b..05600077c 100644 --- a/server/src/uds/REST/methods/client.py +++ b/server/src/uds/REST/methods/client.py @@ -34,7 +34,7 @@ from __future__ import unicode_literals from django.utils.translation import ugettext as _ -from django.core.urlresolvers import reverse +from django.urls import reverse from uds.REST import Handler from uds.REST import RequestError from uds.models import TicketStore diff --git a/server/src/uds/core/__init__.py b/server/src/uds/core/__init__.py index 430278be6..4a75720c4 100644 --- a/server/src/uds/core/__init__.py +++ b/server/src/uds/core/__init__.py @@ -41,5 +41,5 @@ from uds.core.BaseModule import Module import time -VERSION = '2.x.x-DEVEL' +VERSION = '3.x.x-DEVEL' VERSION_STAMP = '{}-DEVEL'.format(time.strftime("%Y%m%d")) diff --git a/server/src/uds/core/auths/BaseAuthenticator.py b/server/src/uds/core/auths/BaseAuthenticator.py index b518bc4fd..c640fb442 100644 --- a/server/src/uds/core/auths/BaseAuthenticator.py +++ b/server/src/uds/core/auths/BaseAuthenticator.py @@ -39,7 +39,7 @@ from uds.core.auths.GroupsManager import GroupsManager from uds.core.auths.Exceptions import InvalidUserException import logging -__updated__ = '2018-01-16' +__updated__ = '2018-02-12' logger = logging.getLogger(__name__) @@ -200,7 +200,7 @@ class Authenticator(Module): if self.isExternalSource: groupsManager = GroupsManager(self._dbAuth) self.getGroups(user.name, groupsManager) - user.groups = [g.dbGroup() for g in groupsManager.getValidGroups()] + user.groups.set([g.dbGroup() for g in groupsManager.getValidGroups()]) def callbackUrl(self): """ diff --git a/server/src/uds/core/util/Cache.py b/server/src/uds/core/util/Cache.py index 27cfff229..11abc9282 100644 --- a/server/src/uds/core/util/Cache.py +++ b/server/src/uds/core/util/Cache.py @@ -63,7 +63,7 @@ class Cache(object): def get(self, skey, defValue=None): now = getSqlDatetime() - # logger.debug('Requesting key "%s" for cache "%s"' % (skey, self._owner,)) + logger.debug('Requesting key "%s" for cache "%s"' % (skey, self._owner,)) try: key = self.__getKey(skey) c = uds.models.Cache.objects.get(pk=key) # @UndefinedVariable @@ -71,8 +71,10 @@ class Cache(object): if expired: return defValue try: + logger.debug('value: {} ----- {}'.format(c.value, encoders.decode(c.value, 'base64'))) val = pickle.loads(encoders.decode(c.value, 'base64')) - except ValueError: + except Exception: # If invalid, simple do no tuse it + logger.exception('Invalid pickle from cache') c.delete() return defValue Cache.hits += 1 diff --git a/server/src/uds/core/util/FileStorage.py b/server/src/uds/core/util/FileStorage.py index aa1a13b19..c1320311d 100644 --- a/server/src/uds/core/util/FileStorage.py +++ b/server/src/uds/core/util/FileStorage.py @@ -77,6 +77,9 @@ class FileStorage(Storage): Storage.__init__(self, *args, **kwargs) def get_valid_name(self, name): + logger.debug('Name in get_valid_name: {}'.format(name)) + if name is None: + return name return name.replace('\\', os.path.sep) def _getKey(self, name): @@ -88,6 +91,7 @@ class FileStorage(Storage): return 'fstor' + six.text_type(hash(self.get_valid_name(name))) def _dbFileForReadOnly(self, name): + logger.debug('Name in _dbFileForReadOnly: {}'.format(name)) # If we have a cache, & the cache contains the object if self.cache is not None: dbf = self.cache.get(self._getKey(name)) @@ -97,6 +101,7 @@ class FileStorage(Storage): return self._dbFileForReadWrite(name) def _dbFileForReadWrite(self, name): + logger.debug('Name in _dbFileForReadWrite: {}'.format(name)) f = DBFile.objects.get(name=self.get_valid_name(name)) self._storeInCache(f) return f @@ -114,6 +119,7 @@ class FileStorage(Storage): 'modified': f.modified }) + logger.debug('Name in _dbFileForReadWrite: {}'.format(f.name)) self.cache.set(self._getKey(f.name), dbf, 3600) # Cache defaults to one hour def _removeFromCache(self, name): @@ -162,7 +168,7 @@ class FileStorage(Storage): def exists(self, name): logger.debug('Called exists for {}'.format(name)) try: - _ = self._dbFileForReadOnly(name).uuid # Tries to access uuid + _ = self._dbFileForReadOnly(name).uuid # Tries to access uuid return True except DBFile.DoesNotExist: return False diff --git a/server/src/uds/migrations/0001_initial.py b/server/src/uds/migrations/0001_initial.py index 0a7f60a14..46bf4b7bd 100644 --- a/server/src/uds/migrations/0001_initial.py +++ b/server/src/uds/migrations/0001_initial.py @@ -99,7 +99,7 @@ class Migration(migrations.Migration): ('state', models.CharField(default='P', max_length=1, db_index=True)), ('state_date', models.DateTimeField()), ('revision', models.PositiveIntegerField(default=1)), - ('deployed_service', models.ForeignKey(related_name='publications', to='uds.DeployedService')), + ('deployed_service', models.ForeignKey(related_name='publications', to='uds.DeployedService', on_delete=models.CASCADE)), ], options={ 'ordering': ('publish_date',), @@ -116,7 +116,7 @@ class Migration(migrations.Migration): ('comments', models.CharField(default='', max_length=256)), ('is_meta', models.BooleanField(default=False, db_index=True)), ('groups', models.ManyToManyField(to='uds.Group')), - ('manager', models.ForeignKey(related_name='groups', to='uds.Authenticator')), + ('manager', models.ForeignKey(related_name='groups', to='uds.Authenticator', on_delete=models.CASCADE)), ], options={ 'ordering': ('name',), @@ -203,7 +203,7 @@ class Migration(migrations.Migration): ('data_type', models.CharField(max_length=128)), ('data', models.TextField(default='')), ('comments', models.CharField(max_length=256)), - ('provider', models.ForeignKey(related_name='services', to='uds.Provider')), + ('provider', models.ForeignKey(related_name='services', to='uds.Provider', on_delete=models.CASCADE)), ], options={ 'ordering': ('name',), @@ -295,7 +295,7 @@ class Migration(migrations.Migration): ('is_admin', models.BooleanField(default=False)), ('last_access', models.DateTimeField(default=datetime.datetime(1972, 7, 1, 0, 0))), ('parent', models.IntegerField(default=-1)), - ('manager', models.ForeignKey(related_name='users', to='uds.Authenticator')), + ('manager', models.ForeignKey(related_name='users', to='uds.Authenticator', on_delete=models.CASCADE)), ], options={ 'ordering': ('name',), @@ -309,7 +309,7 @@ class Migration(migrations.Migration): ('module', models.CharField(max_length=32, db_index=True)), ('name', models.CharField(max_length=32, db_index=True)), ('value', models.CharField(max_length=128, db_index=True)), - ('user', models.ForeignKey(related_name='preferences', to='uds.User')), + ('user', models.ForeignKey(related_name='preferences', to='uds.User', on_delete=models.CASCADE)), ], options={ }, @@ -332,9 +332,9 @@ class Migration(migrations.Migration): ('src_hostname', models.CharField(default='', max_length=64)), ('src_ip', models.CharField(default='', max_length=15)), ('cluster_node', models.CharField(default=None, max_length=128, null=True, db_index=True, blank=True)), - ('deployed_service', models.ForeignKey(related_name='userServices', to='uds.DeployedService')), - ('publication', models.ForeignKey(related_name='userServices', blank=True, to='uds.DeployedServicePublication', null=True)), - ('user', models.ForeignKey(related_name='userServices', default=None, blank=True, to='uds.User', null=True)), + ('deployed_service', models.ForeignKey(related_name='userServices', to='uds.DeployedService', on_delete=models.CASCADE)), + ('publication', models.ForeignKey(related_name='userServices', blank=True, to='uds.DeployedServicePublication', null=True, on_delete=models.CASCADE)), + ('user', models.ForeignKey(related_name='userServices', default=None, blank=True, to='uds.User', null=True, on_delete=models.CASCADE)), ], options={ 'ordering': ('creation_date',), @@ -379,13 +379,13 @@ class Migration(migrations.Migration): migrations.AddField( model_name='deployedservice', name='osmanager', - field=models.ForeignKey(related_name='deployedServices', blank=True, to='uds.OSManager', null=True), + field=models.ForeignKey(related_name='deployedServices', blank=True, to='uds.OSManager', null=True, on_delete=models.CASCADE), preserve_default=True, ), migrations.AddField( model_name='deployedservice', name='service', - field=models.ForeignKey(related_name='deployedServices', blank=True, to='uds.Service', null=True), + field=models.ForeignKey(related_name='deployedServices', blank=True, to='uds.Service', null=True, on_delete=models.CASCADE), preserve_default=True, ), migrations.AddField( diff --git a/server/src/uds/migrations/0007_image.py b/server/src/uds/migrations/0007_image.py index f63f468dc..f00e7c146 100644 --- a/server/src/uds/migrations/0007_image.py +++ b/server/src/uds/migrations/0007_image.py @@ -31,7 +31,7 @@ class Migration(migrations.Migration): migrations.AddField( model_name='deployedservice', name='image', - field=models.ForeignKey(related_name='deployedServices', blank=True, to='uds.Image', null=True), + field=models.ForeignKey(related_name='deployedServices', blank=True, to='uds.Image', null=True, on_delete=models.CASCADE), preserve_default=True, ), ] diff --git a/server/src/uds/migrations/0008_userserviceproperty.py b/server/src/uds/migrations/0008_userserviceproperty.py index 1dd05fe8f..1cb8a5e6b 100644 --- a/server/src/uds/migrations/0008_userserviceproperty.py +++ b/server/src/uds/migrations/0008_userserviceproperty.py @@ -17,7 +17,7 @@ class Migration(migrations.Migration): ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)), ('name', models.CharField(max_length=128, db_index=True)), ('value', models.TextField(default='')), - ('user_service', models.ForeignKey(related_name='properties', to='uds.UserService')), + ('user_service', models.ForeignKey(related_name='properties', to='uds.UserService', on_delete=models.CASCADE)), ], options={ 'db_table': 'uds__user_service_property', diff --git a/server/src/uds/migrations/0014_permissions.py b/server/src/uds/migrations/0014_permissions.py index 020bdb203..c60a25865 100644 --- a/server/src/uds/migrations/0014_permissions.py +++ b/server/src/uds/migrations/0014_permissions.py @@ -21,8 +21,8 @@ class Migration(migrations.Migration): ('object_type', models.SmallIntegerField(default=-1, db_index=True)), ('object_id', models.IntegerField(default=None, null=True, db_index=True, blank=True)), ('permission', models.SmallIntegerField(default=0, db_index=True)), - ('group', models.ForeignKey(related_name='permissions', default=None, blank=True, to='uds.Group', null=True)), - ('user', models.ForeignKey(related_name='permissions', default=None, blank=True, to='uds.User', null=True)), + ('group', models.ForeignKey(related_name='permissions', default=None, blank=True, to='uds.Group', null=True, on_delete=models.CASCADE)), + ('user', models.ForeignKey(related_name='permissions', default=None, blank=True, to='uds.User', null=True, on_delete=models.CASCADE)), ], options={ 'abstract': False, diff --git a/server/src/uds/migrations/0016_auto_20150617_0741.py b/server/src/uds/migrations/0016_auto_20150617_0741.py index 77b844951..db909a5b3 100644 --- a/server/src/uds/migrations/0016_auto_20150617_0741.py +++ b/server/src/uds/migrations/0016_auto_20150617_0741.py @@ -44,16 +44,16 @@ class Migration(migrations.Migration): migrations.AlterField( model_name='group', name='manager', - field=uds.models.Util.UnsavedForeignKey(related_name='groups', to='uds.Authenticator'), + field=uds.models.Util.UnsavedForeignKey(related_name='groups', to='uds.Authenticator', on_delete=models.CASCADE), ), migrations.AlterField( model_name='user', name='manager', - field=uds.models.Util.UnsavedForeignKey(related_name='users', to='uds.Authenticator'), + field=uds.models.Util.UnsavedForeignKey(related_name='users', to='uds.Authenticator', on_delete=models.CASCADE), ), migrations.AddField( model_name='deployedservicepublicationchangelog', name='publication', - field=models.ForeignKey(related_name='changelog', to='uds.DeployedService'), + field=models.ForeignKey(related_name='changelog', to='uds.DeployedService', on_delete=models.CASCADE), ), ] diff --git a/server/src/uds/migrations/0017_calendar_calendarrule.py b/server/src/uds/migrations/0017_calendar_calendarrule.py index 5ceaac741..150df83f8 100644 --- a/server/src/uds/migrations/0017_calendar_calendarrule.py +++ b/server/src/uds/migrations/0017_calendar_calendarrule.py @@ -37,7 +37,7 @@ class Migration(migrations.Migration): ('interval', models.IntegerField(default=1)), ('duration', models.IntegerField(default=0)), ('duration_unit', models.CharField(default='MINUTES', max_length=32, choices=[('MINUTES', 'Minutes'), ('HOURS', 'Hours'), ('DAYS', 'Days'), ('WEEKS', 'Weeks')])), - ('calendar', models.ForeignKey(related_name='rules', to='uds.Calendar')), + ('calendar', models.ForeignKey(related_name='rules', to='uds.Calendar', on_delete=models.CASCADE)), ], options={ 'db_table': 'uds_calendar_rules', diff --git a/server/src/uds/models/AccountUsage.py b/server/src/uds/models/AccountUsage.py index 38ed06ad0..5873c06f5 100644 --- a/server/src/uds/models/AccountUsage.py +++ b/server/src/uds/models/AccountUsage.py @@ -60,7 +60,7 @@ class AccountUsage(UUIDModel): end = models.DateTimeField(default=NEVER) user_service = models.OneToOneField(UserService, null=True, blank=True, related_name='accounting', on_delete=models.SET_NULL) - account = models.ForeignKey(Account, related_name='usages') + account = models.ForeignKey(Account, related_name='usages', on_delete=models.CASCADE) class Meta: """ diff --git a/server/src/uds/models/CalendarRule.py b/server/src/uds/models/CalendarRule.py index cb2754f2c..198294eab 100644 --- a/server/src/uds/models/CalendarRule.py +++ b/server/src/uds/models/CalendarRule.py @@ -103,7 +103,7 @@ class CalendarRule(UUIDModel): duration = models.IntegerField(default=0) # Duration in minutes duration_unit = models.CharField(choices=dunits, default='MINUTES', max_length=32) - calendar = models.ForeignKey(Calendar, related_name='rules') + calendar = models.ForeignKey(Calendar, related_name='rules', on_delete=models.CASCADE) class Meta: ''' diff --git a/server/src/uds/models/DBFile.py b/server/src/uds/models/DBFile.py index f986cc540..d78086a4a 100644 --- a/server/src/uds/models/DBFile.py +++ b/server/src/uds/models/DBFile.py @@ -59,9 +59,11 @@ class DBFile(UUIDModel): try: return encoders.decode(encoders.decode(self.content, 'base64'), 'zip') except Exception: + logger.exception('Getting data') logger.error('DBFile {} has errors and cannot be used'.format(self.name)) try: - self.delete() # Autodelete, invalid... + # self.delete() # Autodelete, invalid... + pass except: logger.error('Could not even delete {}!!'.format(self.name)) @@ -69,8 +71,11 @@ class DBFile(UUIDModel): @data.setter def data(self, value): + logger.debug('Encoding value: {}'.format(value)) self.size = len(value) - self.content = encoders.encode(encoders.encode(value, 'zip'), 'base64') + content = encoders.encode(encoders.encode(value, 'zip'), 'base64', asText=True) + logger.debug('Content is {}'.format(type(content))) + self.content = content def __str__(self): return 'File: {} {} {} {}'.format(self.name, self.size, self.created, self.modified) diff --git a/server/src/uds/models/Service.py b/server/src/uds/models/Service.py index e13543608..437f3197c 100644 --- a/server/src/uds/models/Service.py +++ b/server/src/uds/models/Service.py @@ -64,10 +64,10 @@ class Service(ManagedObjectModel, TaggingMixin): or a Terminal Server configuration). """ # pylint: disable=model-missing-unicode - provider = models.ForeignKey(Provider, related_name='services') + provider = models.ForeignKey(Provider, related_name='services', on_delete=models.CASCADE) # Proxy for this service - proxy = models.ForeignKey(Proxy, null=True, blank=True, related_name='services') + proxy = models.ForeignKey(Proxy, null=True, blank=True, related_name='services', on_delete=models.CASCADE) class Meta(ManagedObjectModel.Meta): diff --git a/server/src/uds/models/ServicesPool.py b/server/src/uds/models/ServicesPool.py index e1a736785..10e7a0e6e 100644 --- a/server/src/uds/models/ServicesPool.py +++ b/server/src/uds/models/ServicesPool.py @@ -76,8 +76,8 @@ class DeployedService(UUIDModel, TaggingMixin): name = models.CharField(max_length=128, default='') short_name = models.CharField(max_length=32, default='') comments = models.CharField(max_length=256, default='') - service = models.ForeignKey(Service, null=True, blank=True, related_name='deployedServices') - osmanager = models.ForeignKey(OSManager, null=True, blank=True, related_name='deployedServices') + service = models.ForeignKey(Service, null=True, blank=True, related_name='deployedServices', on_delete=models.CASCADE) + osmanager = models.ForeignKey(OSManager, null=True, blank=True, related_name='deployedServices', on_delete=models.CASCADE) transports = models.ManyToManyField(Transport, related_name='deployedServices', db_table='uds__ds_trans') assignedGroups = models.ManyToManyField(Group, related_name='deployedServices', db_table='uds__ds_grps') state = models.CharField(max_length=1, default=states.servicePool.ACTIVE, db_index=True) @@ -96,7 +96,7 @@ class DeployedService(UUIDModel, TaggingMixin): actionsCalendars = models.ManyToManyField(Calendar, related_name='actionsSP', through='CalendarAction') # Usage accounting - account = models.ForeignKey(Account, null=True, blank=True, related_name='servicesPools') + account = models.ForeignKey(Account, null=True, blank=True, related_name='servicesPools', on_delete=models.CASCADE) initial_srvs = models.PositiveIntegerField(default=0) cache_l1_srvs = models.PositiveIntegerField(default=0) diff --git a/server/src/uds/templatetags/html5.py b/server/src/uds/templatetags/html5.py index f61baca6b..488294141 100644 --- a/server/src/uds/templatetags/html5.py +++ b/server/src/uds/templatetags/html5.py @@ -63,12 +63,13 @@ def country(lang): # Config related -@register.assignment_tag +@register.simple_tag def get_theme(): return GlobalConfig.UDS_THEME.get() class EnhacedVisual(template.Node): + def __init__(self, nodelistTrue, nodelistFalse): self._nodelistTrue = nodelistTrue self._nodelistFalse = nodelistFalse @@ -98,6 +99,7 @@ def enhaced_visual(parser, token): class TabIndex(template.Node): + def __init__(self, tabIndexName): self.tabIndexIname = tabIndexName @@ -121,6 +123,7 @@ def tabindex(parser, token): class Preference(template.Node): + def __init__(self, modName, prefName): self.modName = modName self.prefName = prefName @@ -147,26 +150,27 @@ def preference(parser, token): return Preference(modName, prefName) -@register.assignment_tag +@register.simple_tag def preferences_allowed(): return GlobalConfig.PREFERENCES_ALLOWED.getBool(True) -@register.assignment_tag +@register.simple_tag def pageReloadTime(): return GlobalConfig.RELOAD_TIME.getInt(True) -@register.assignment_tag +@register.simple_tag def root_id(): return ROOT_ID -@register.assignment_tag +@register.simple_tag def image_size(): return Image.MAX_IMAGE_SIZE -@register.assignment_tag + +@register.simple_tag def calendar_denied_msg(): text = GlobalConfig.LIMITED_BY_CALENDAR_TEXT.get().strip() if text == '': @@ -174,8 +178,10 @@ def calendar_denied_msg(): return text + # Browser related class IfBrowser(template.Node): + def __init__(self, nodelistTrue, nodelistFalse, browsers): self._nodelistTrue = nodelistTrue self._nodelistFalse = nodelistFalse diff --git a/server/src/uds/transports/HTML5RDP/HTML5RDP.py b/server/src/uds/transports/HTML5RDP/HTML5RDP.py index df6afdf1a..b2de5068e 100644 --- a/server/src/uds/transports/HTML5RDP/HTML5RDP.py +++ b/server/src/uds/transports/HTML5RDP/HTML5RDP.py @@ -34,7 +34,7 @@ from __future__ import unicode_literals from django.utils.translation import ugettext_noop as _ -from django.core.urlresolvers import reverse +from django.urls import reverse from django.http import HttpResponseRedirect from uds.core.ui.UserInterface import gui diff --git a/server/src/uds/urls.py b/server/src/uds/urls.py index 3abed3528..32cab6a41 100644 --- a/server/src/uds/urls.py +++ b/server/src/uds/urls.py @@ -30,9 +30,10 @@ @author: Adolfo Gómez, dkmaster at dkmon dot com """ -from django.conf.urls import include, url +from django.urls import re_path +from django.conf.urls import include from uds.core.util.modfinder import loadModulesUrls -from django.views.i18n import javascript_catalog +from django.views.i18n import JavaScriptCatalog from uds import REST import uds.web.views @@ -42,56 +43,56 @@ js_info_dict = { } urlpatterns = [ - url(r'^$', uds.web.views.index, name='uds.web.views.index'), - url(r'^login/$', uds.web.views.login, name='uds.web.views.login'), - url(r'^login/(?P.+)$', uds.web.views.login, name='uds.web.views.login'), - url(r'^logout$', uds.web.views.logout, name='uds.web.views.logout'), + re_path(r'^$', uds.web.views.index, name='uds.web.views.index'), + re_path(r'^login/$', uds.web.views.login, name='uds.web.views.login'), + re_path(r'^login/(?P.+)$', uds.web.views.login, name='uds.web.views.login'), + re_path(r'^logout$', uds.web.views.logout, name='uds.web.views.logout'), # Icons - url(r'^transicon/(?P.+)$', uds.web.views.transportIcon, name='uds.web.views.transportIcon'), + re_path(r'^transicon/(?P.+)$', uds.web.views.transportIcon, name='uds.web.views.transportIcon'), # Images - url(r'^srvimg/(?P.+)$', uds.web.views.serviceImage, name='uds.web.views.serviceImage'), - url(r'^galimg/(?P.+)$', uds.web.views.image, name='galleryImage'), + re_path(r'^srvimg/(?P.+)$', uds.web.views.serviceImage, name='uds.web.views.serviceImage'), + re_path(r'^galimg/(?P.+)$', uds.web.views.image, name='galleryImage'), # Error URL - url(r'^error/(?P.+)$', uds.web.views.error, name='uds.web.views.error'), + re_path(r'^error/(?P.+)$', uds.web.views.error, name='uds.web.views.error'), # Transport own link processor - url(r'^trans/(?P.+)/(?P.+)$', uds.web.views.transportOwnLink, name='TransportOwnLink'), + re_path(r'^trans/(?P.+)/(?P.+)$', uds.web.views.transportOwnLink, name='TransportOwnLink'), # Authenticators custom html - url(r'^customAuth/(?P.*)$', uds.web.views.customAuth, name='uds.web.views.customAuth'), + re_path(r'^customAuth/(?P.*)$', uds.web.views.customAuth, name='uds.web.views.customAuth'), # Preferences - url(r'^prefs$', uds.web.views.prefs, name='uds.web.views.prefs'), + re_path(r'^prefs$', uds.web.views.prefs, name='uds.web.views.prefs'), # Change Language - url(r'^i18n/', include('django.conf.urls.i18n')), + re_path(r'^i18n/', include('django.conf.urls.i18n')), # Downloads - url(r'^idown/(?P[a-zA-Z0-9-]*)$', uds.web.views.download, name='uds.web.views.download'), + re_path(r'^idown/(?P[a-zA-Z0-9-]*)$', uds.web.views.download, name='uds.web.views.download'), # downloads for client - url(r'^down$', uds.web.views.client_downloads, name='uds.web.views.client_downloads'), - url(r'^down/(?P[a-zA-Z0-9-]*)$', uds.web.views.client_downloads, name='uds.web.views.client_downloads'), - url(r'^pluginDetection/(?P[a-zA-Z0-9-]*)$', uds.web.views.plugin_detection, name='PluginDetection'), + re_path(r'^down$', uds.web.views.client_downloads, name='uds.web.views.client_downloads'), + re_path(r'^down/(?P[a-zA-Z0-9-]*)$', uds.web.views.client_downloads, name='uds.web.views.client_downloads'), + re_path(r'^pluginDetection/(?P[a-zA-Z0-9-]*)$', uds.web.views.plugin_detection, name='PluginDetection'), # Client access enabler - url(r'^enable/(?P.+)/(?P.+)$', uds.web.views.clientEnabler, name='ClientAccessEnabler'), + re_path(r'^enable/(?P.+)/(?P.+)$', uds.web.views.clientEnabler, name='ClientAccessEnabler'), # Releaser - url(r'^release/(?P.+)$', uds.web.views.release, name='Releaser'), + re_path(r'^release/(?P.+)$', uds.web.views.release, name='Releaser'), # Custom authentication callback - url(r'^auth/(?P.+)', uds.web.views.authCallback, name='uds.web.views.authCallback'), - url(r'^authinfo/(?P.+)', uds.web.views.authInfo, name='uds.web.views.authInfo'), - url(r'^about', uds.web.views.about, name='uds.web.views.about'), + re_path(r'^auth/(?P.+)', uds.web.views.authCallback, name='uds.web.views.authCallback'), + re_path(r'^authinfo/(?P.+)', uds.web.views.authInfo, name='uds.web.views.authInfo'), + re_path(r'^about', uds.web.views.about, name='uds.web.views.about'), # Ticket authentication - url(r'^tkauth/(?P.+)$', uds.web.views.ticketAuth, name='TicketAuth'), + re_path(r'^tkauth/(?P.+)$', uds.web.views.ticketAuth, name='TicketAuth'), # REST Api - url(r'^rest/(?P.*)$', REST.Dispatcher.as_view(), name="REST"), + re_path(r'^rest/(?P.*)$', REST.Dispatcher.as_view(), name="REST"), # Web admin GUI - url(r'^adm/', include('uds.admin.urls')), + re_path(r'^adm/', include('uds.admin.urls')), # Files - url(r'^files/(?P.+)', uds.web.views.file_storage, name='uds.web.views.file_storage'), + re_path(r'^files/(?P.+)', uds.web.views.file_storage, name='uds.web.views.file_storage'), # Internacionalization in javascript - # Javascript catalog - url(r'^jsi18n/(?P[a-z]*)$', javascript_catalog, js_info_dict, name='uds.web.views.jsCatalog'), + # Javascript catalog. In fact, lang is not used, but it is maintanied for "backward" user templates compatibility + re_path(r'^jsi18n/(?P[a-z]*)$', JavaScriptCatalog.as_view(), name='uds.web.views.jsCatalog'), ] # Append urls from special dispatchers diff --git a/server/src/uds/web/errors.py b/server/src/uds/web/errors.py index 0ffdee013..aed80b929 100644 --- a/server/src/uds/web/errors.py +++ b/server/src/uds/web/errors.py @@ -37,7 +37,7 @@ from django.shortcuts import render from django.template import RequestContext from django.http import HttpResponseRedirect -from django.core.urlresolvers import reverse +from django.urls import reverse from .transformers import scrambleId, transformId from uds.models import DeployedService, Transport, UserService, Authenticator diff --git a/server/src/uds/web/views/auth.py b/server/src/uds/web/views/auth.py index a64e812df..f530aca41 100644 --- a/server/src/uds/web/views/auth.py +++ b/server/src/uds/web/views/auth.py @@ -32,7 +32,7 @@ from __future__ import unicode_literals import logging -from django.core.urlresolvers import reverse +from django.urls import reverse from django.http import HttpResponse, HttpResponseRedirect, HttpResponsePermanentRedirect from django.shortcuts import render from django.utils.translation import ugettext as _ @@ -53,8 +53,7 @@ from uds.models import TicketStore logger = logging.getLogger(__name__) - -__updated__ = '2017-02-14' +__updated__ = '2018-02-12' @csrf_exempt diff --git a/server/src/uds/web/views/file_storage.py b/server/src/uds/web/views/file_storage.py index 5c9cdb73e..3c563d251 100644 --- a/server/src/uds/web/views/file_storage.py +++ b/server/src/uds/web/views/file_storage.py @@ -39,10 +39,12 @@ import logging logger = logging.getLogger(__name__) -__updated__ = '2016-04-05' +__updated__ = '2018-02-12' + @cache_page(3600, key_prefix='file', cache='memory') def file_storage(request, uuid): + logger.debug('Getting {} from DB'.format(uuid)) f = DBFile.objects.get(uuid=uuid) content_type, encoding = mimetypes.guess_type(f.name) diff --git a/server/src/uds/web/views/index.py b/server/src/uds/web/views/index.py index 485a67760..9ab7d4589 100644 --- a/server/src/uds/web/views/index.py +++ b/server/src/uds/web/views/index.py @@ -31,7 +31,7 @@ from __future__ import unicode_literals from django.shortcuts import render -from django.core.urlresolvers import reverse +from django.urls import reverse from django.utils.translation import ugettext from django.utils import formats @@ -51,7 +51,7 @@ import logging logger = logging.getLogger(__name__) -__updated__ = '2017-11-10' +__updated__ = '2018-02-12' def about(request): diff --git a/server/src/uds/web/views/login.py b/server/src/uds/web/views/login.py index 53f5acc4e..633d2f683 100644 --- a/server/src/uds/web/views/login.py +++ b/server/src/uds/web/views/login.py @@ -32,7 +32,7 @@ from __future__ import unicode_literals from django.http import HttpResponse, HttpResponseRedirect from django.shortcuts import render -from django.core.urlresolvers import reverse +from django.urls import reverse from django.utils.translation import ugettext from uds.core.auths.auth import webLogin, authenticate, authLogLogin, authLogLogout, getUDSCookie, webLoginRequired, webLogout @@ -48,7 +48,8 @@ import uds.web.errors as errors import logging logger = logging.getLogger(__name__) -__updated__ = '2017-06-01' +__updated__ = '2018-02-12' + # Allow cross-domain login # @csrf_exempt