From c5444f0df2c8860b07981e1d39926b98bdf3a72b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adolfo=20G=C3=B3mez=20Garc=C3=ADa?= Date: Fri, 27 Mar 2015 07:41:42 +0100 Subject: [PATCH] Almost done with web part of new model. Retired java checks from code & pages --- server/src/uds/core/auths/auth.py | 37 +++------ .../src/uds/core/managers/UserPrefsManager.py | 6 ++ server/src/uds/core/util/request.py | 26 ++++++- server/src/uds/static/css/uds-html5.css | 2 +- server/src/uds/static/js/PluginDetect_Java.js | 8 -- server/src/uds/static/js/uds-client.coffee | 15 ++-- server/src/uds/static/other/getJavaInfo.jar | Bin 858 -> 0 bytes server/src/uds/templates/uds/detectJava.html | 40 ---------- .../uds/html5/client/download_client.html | 45 ----------- .../uds/templates/uds/html5/detectJava.html | 29 ------- .../templates/uds/html5/download_client.html | 71 ++++++++++++++++++ server/src/uds/templates/uds/html5/login.html | 11 --- .../templates/uds/html5/snippets/navbar.html | 1 + .../templates/uds/html5/templates/base.html | 3 +- .../uds/templates/uds/transport/udslink.html | 3 - server/src/uds/templatetags/html5.py | 3 + server/src/uds/urls.py | 4 +- server/src/uds/web/forms/LoginForm.py | 19 ++--- server/src/uds/web/views/__init__.py | 6 +- server/src/uds/web/views/auth.py | 29 +------ server/src/uds/web/views/client_download.py | 18 +++-- server/src/uds/web/views/login.py | 29 ++++--- server/src/uds/web/views/service.py | 12 ++- 23 files changed, 182 insertions(+), 235 deletions(-) delete mode 100644 server/src/uds/static/js/PluginDetect_Java.js delete mode 100644 server/src/uds/static/other/getJavaInfo.jar delete mode 100644 server/src/uds/templates/uds/detectJava.html delete mode 100644 server/src/uds/templates/uds/html5/client/download_client.html delete mode 100644 server/src/uds/templates/uds/html5/detectJava.html create mode 100644 server/src/uds/templates/uds/html5/download_client.html delete mode 100644 server/src/uds/templates/uds/transport/udslink.html diff --git a/server/src/uds/core/auths/auth.py b/server/src/uds/core/auths/auth.py index 59626f09..69037ccf 100644 --- a/server/src/uds/core/auths/auth.py +++ b/server/src/uds/core/auths/auth.py @@ -49,12 +49,11 @@ from uds.core.util.stats import events from uds.core.managers.CryptoManager import CryptoManager from uds.core.util.State import State from uds.models import User -from uds.core.util.request import getRequest import logging import six -__updated__ = '2015-03-06' +__updated__ = '2015-03-27' logger = logging.getLogger(__name__) authLogger = logging.getLogger('authLog') @@ -102,7 +101,7 @@ def getIp(request): # Decorator to make easier protect pages that needs to be logged in -def webLoginRequired(admin): +def webLoginRequired(admin=False): ''' Decorator to set protection to access page Look for samples at uds.core.web.views @@ -113,17 +112,7 @@ def webLoginRequired(admin): ''' Wrapped function for decorator ''' - user = request.session.get(USER_KEY) - if user is not None: - try: - if user == ROOT_ID: - user = getRootUser() - else: - user = User.objects.get(pk=user) - except User.DoesNotExist: - user = None - - if user is None: + if request.user is None: url = request.build_absolute_uri(GlobalConfig.LOGIN_URL.get()) if GlobalConfig.REDIRECT_TO_HTTPS.getBool() is True: url = url.replace('http://', 'https://') @@ -131,12 +120,9 @@ def webLoginRequired(admin): return HttpResponseRedirect(url) if admin is True or admin == 'admin': - if user.isStaff() is False or (admin == 'admin' and user.is_admin is False): + if request.user.isStaff() is False or (admin == 'admin' and request.user.is_admin is False): return HttpResponseForbidden(_('Forbidden')) - # Refresh session duration - # request.session.set_expiry(GlobalConfig.USER_SESSION_LENGTH.getInt()) - request.user = user return view_func(request, *args, **kwargs) return _wrapped_view return decorator @@ -166,6 +152,8 @@ def __registerUser(authenticator, authInstance, username): This will work correctly with both internal or externals cause we first authenticate the user, if internal and user do not exists in database authenticate will return false, if external and return true, will create a reference in database ''' + from uds.core.util.request import getRequest + username = authInstance.transformUsername(username) logger.debug('Transformed username: {0}'.format(username)) @@ -325,25 +313,24 @@ def webLogout(request, exit_url=None): return HttpResponseRedirect(request.build_absolute_uri(exit_url)) -def authLogLogin(request, authenticator, userName, java, os, logStr=''): +def authLogLogin(request, authenticator, userName, logStr=''): ''' Logs authentication ''' if logStr == '': logStr = 'Logged in' - javaStr = java and 'Java' or 'No Java' - authLogger.info('|'.join([authenticator.name, userName, request.ip, javaStr, os['OS'], logStr, request.META.get('HTTP_USER_AGENT', 'Undefined')])) + authLogger.info('|'.join([authenticator.name, userName, request.ip, request.os['OS'], logStr, request.META.get('HTTP_USER_AGENT', 'Undefined')])) level = (logStr == 'Logged in') and log.INFO or log.ERROR - log.doLog(authenticator, level, 'user {0} has {1} from {2} {3} java and os is {4}'.format(userName, logStr, - request.ip, java and 'has' or 'has NOT', os['OS']), log.WEB) + log.doLog(authenticator, level, 'user {0} has {1} from {2} where os is {3}'.format(userName, logStr, + request.ip, request.os['OS']), log.WEB) try: user = authenticator.users.get(name=userName) log.doLog(user, level, - '{0} from {1} {2} java and os is {3}'.format(logStr, request.ip, java and 'has' or 'has NOT', os['OS']), log.WEB + '{0} from {1} where os is {3}'.format(logStr, request.ip, request.os['OS']), log.WEB ) - except: + except Exception: pass diff --git a/server/src/uds/core/managers/UserPrefsManager.py b/server/src/uds/core/managers/UserPrefsManager.py index 246a2ee2..1266ab34 100644 --- a/server/src/uds/core/managers/UserPrefsManager.py +++ b/server/src/uds/core/managers/UserPrefsManager.py @@ -73,6 +73,12 @@ class UserPrefsManager(object): prefs[p.getName()] = p.getDefValue() return prefs + def setPreferenceForUser(self, user, modName, prefName, value): + try: + user.preferences.create(module=modName, name=prefName, value=value) + except Exception: + user.preferences.filter(module=modName, name=prefName).update(value=value) + def getHtmlForUserPreferences(self, user): # First fill data for all preferences data = {} diff --git a/server/src/uds/core/util/request.py b/server/src/uds/core/util/request.py index c52e1cf3..2858d882 100644 --- a/server/src/uds/core/util/request.py +++ b/server/src/uds/core/util/request.py @@ -32,11 +32,13 @@ from __future__ import unicode_literals from uds.core.util import OsDetector +from uds.core.auths.auth import ROOT_ID, USER_KEY, getRootUser +from uds.models import User import threading import logging -__updated__ = '2015-03-18' +__updated__ = '2015-03-27' logger = logging.getLogger(__name__) @@ -60,6 +62,9 @@ class GlobalRequestMiddleware(object): GlobalRequestMiddleware.fillIps(request) # Ensures request contains os OsDetector.getOsFromRequest(request) + # Ensures that requests contains the valid user + GlobalRequestMiddleware.getUser(request) + # Add a counter var, reseted on every request _requests[getIdent()] = request return None @@ -98,3 +103,22 @@ class GlobalRequestMiddleware(object): request.ip_proxy = request.ip request.is_proxy = False + @staticmethod + def getUser(request): + ''' + Ensures request user is the correct user + ''' + user = request.session.get(USER_KEY) + if user is not None: + try: + if user == ROOT_ID: + user = getRootUser() + else: + user = User.objects.get(pk=user) + except User.DoesNotExist: + user = None + + if user is not None: + request.user = user + else: + request.user = None diff --git a/server/src/uds/static/css/uds-html5.css b/server/src/uds/static/css/uds-html5.css index 15346280..d7f7bf68 100644 --- a/server/src/uds/static/css/uds-html5.css +++ b/server/src/uds/static/css/uds-html5.css @@ -132,4 +132,4 @@ footer { width: 32px; height: 32px; margin-top: -8px; -} \ No newline at end of file +} diff --git a/server/src/uds/static/js/PluginDetect_Java.js b/server/src/uds/static/js/PluginDetect_Java.js deleted file mode 100644 index 6fc0a2dc..00000000 --- a/server/src/uds/static/js/PluginDetect_Java.js +++ /dev/null @@ -1,8 +0,0 @@ -/* -PluginDetect v0.8.8 -www.pinlady.net/PluginDetect/license/ -[ Java ] -[ isMinVersion getVersion hasMimeType getInfo onDetectionDone ] -[ ] -*/ -(function(){var a={version:"0.8.8",name:"PluginDetect",addPlugin:function(b,c){b&&a.isString(b)&&c&&a.isFunc(c.getVersion)&&(b=b.replace(/\s/g,"").toLowerCase(),a.Plugins[b]=c,a.isDefined(c.getVersionDone)||(c.installed=null,c.version=null,c.version0=null,c.getVersionDone=null,c.pluginName=b))},openTag:"<",hasOwnProperty:{}.constructor.prototype.hasOwnProperty,hasOwn:function(b,c){var d;try{d=a.hasOwnProperty.call(b,c)}catch(e){}return!!d},rgx:{str:/string/i,num:/number/i,fun:/function/i,arr:/array/i},toString:{}.constructor.prototype.toString,isDefined:function(a){return"undefined"!=typeof a},isArray:function(b){return a.rgx.arr.test(a.toString.call(b))},isString:function(b){return a.rgx.str.test(a.toString.call(b))},isNum:function(b){return a.rgx.num.test(a.toString.call(b))},isStrNum:function(b){return a.isString(b)&&/\d/.test(b)},isFunc:function(b){return a.rgx.fun.test(a.toString.call(b))},getNumRegx:/[\d][\d\.\_,\-]*/,splitNumRegx:/[\.\_,\-]/g,getNum:function(b,c){var d=a.isStrNum(b)?(a.isDefined(c)?RegExp(c):a.getNumRegx).exec(b):null;return d?d[0]:null},compareNums:function(b,c,d){var e=parseInt;if(a.isStrNum(b)&&a.isStrNum(c)){if(a.isDefined(d)&&d.compareNums)return d.compareNums(b,c);b=b.split(a.splitNumRegx);c=c.split(a.splitNumRegx);for(d=0;de(c[d],10))return 1;if(e(b[d],10)d;d++)if(/^(0+)(.+)$/.test(e[d])&&(e[d]=RegExp.$2),d>c||!/\d/.test(e[d]))e[d]="0";return e.slice(0,4).join(",")},pd:{getPROP:function(b,c,d){try{b&&(d=b[c])}catch(e){}return d},findNavPlugin:function(b){if(b.dbug)return b.dbug;if(window.navigator){var c={Find:a.isString(b.find)?RegExp(b.find,"i"):b.find,Find2:a.isString(b.find2)?RegExp(b.find2,"i"):b.find2,Avoid:b.avoid?a.isString(b.avoid)?RegExp(b.avoid,"i"):b.avoid:0,Num:b.num?/\d/:0},d,e,f,g=navigator.mimeTypes,h=navigator.plugins,l=null;if(b.mimes&&g)for(f=a.isArray(b.mimes)?[].concat(b.mimes):a.isString(b.mimes)?[b.mimes]:[],d=0;df.status)return f.status;f=f.plugin;c=a.formatNum(a.isNum(c)?c.toString():a.isStrNum(c)?a.getNum(c):"0");1!=f.getVersionDone&&(f.getVersion(c,d,e),null===f.getVersionDone&&(f.getVersionDone=1));null!==f.installed&&(g=0.5>=f.installed?f.installed:0.7==f.installed?1:null===f.version?0:0<=a.compareNums(f.version,c,f)?1:-0.1);return g},getVersion:function(b,c,d){var e=a.pd.findPlugin(b);if(0>e.status)return null;e=e.plugin;1!=e.getVersionDone&&(e.getVersion(null,c,d),null===e.getVersionDone&&(e.getVersionDone=1));e=(e=e.version||e.version0)?e.replace(a.splitNumRegx,a.pd.getVersionDelimiter):e;return e},hasMimeType:function(b){if(b&&window.navigator&&navigator.mimeTypes){var c,d,e,f=navigator.mimeTypes,g=a.isArray(b)?[].concat(b):a.isString(b)?[b]:[];e=g.length;for(d=0;df.status)return e;f=f.plugin;a.isFunc(f.getInfo)&&(null===f.getVersionDone&&(a.getVersion?a.getVersion(b,c,d):a.isMinVersion(b,"0",c,d)),e=f.getInfo());return e},onDetectionDone:function(b,c,d,e){var f=a.pd.findPlugin(b);if(-3==f.status)return-1;f=f.plugin;a.isArray(f.DoneHndlrs)||(f.DoneHndlrs=[]);1!=f.getVersionDone&&(a.getVersion?a.getVersion(b,d,e):a.isMinVersion(b,"0",d,e));if(-0.5!=f.installed&&0.5!=f.installed)return a.ev.call(c),1;a.ev.fPush(c,f.DoneHndlrs);return 0},codebase:{isDisabled:function(){return a.browser.ActiveXEnabled&&a.isDefined(a.pd.getPROP(document.createElement("object"),"object"))?0:1},pluginMayBeHanging:function(b){return!this.isDisabled()&&b&&a.isDefined(a.pd.getPROP(b,"readyState"))&&a.pd.getPROP(b.firstChild,"object")&&(b=a.pd.getPROP(b.firstChild,"readyState"),a.isNum(b)&&4!=b)?(1):0},emptyNode:function(a){try{a.innerHTML=""}catch(c){}},emptyGarbage:function(){var b,c=this.HTML,d=0;if(c.length){for(b=c.length-1;b>=this.len;b--)c[b]&&c[b].span&&this.pluginMayBeHanging(c[b].span)&&(this.emptyNode(c[b].span),c[b].span=null,d=1);this.len=c.length;if(d){try{window.CollectGarbage()}catch(e){}}}},HTML:[],len:0,onDone:function(a,c){var d,e=c.HTML;for(d=0;d'+a.openTag+"/object>";for(c=0;c=a.compareNums(c,b.min))return 1;if(b.max&&0<=a.compareNums(c,b.max))return 0;f.innerHTML=b.tagA+c+b.tagB;a.pd.getPROP(f.firstChild,"object")&&(d=1);d?(b.min=c,this.HTML.push({span:f})):(b.max=c,f.innerHTML="");return d},convert_:function(b,c,d,e){return(b=b.convert[c])?a.isFunc(b)?a.formatNum(b(d.split(a.splitNumRegx),e).join(",")):d:b},convert:function(b,c,d){var e,f,g;c=a.formatNum(c);f={v:c,x:-1};if(c)for(e=0;ea.compareNums(c,d?this.convert_(b,e,b.Upper[e]):b.Upper[e]))){f.v=this.convert_(b,e,c,d);f.x=e;break}return f},isMin:function(b,c){var d,e=0;if(!a.isStrNum(c)||this.isDisabled())return e;this.init(b);if(!b.L)for(b.L={},d=0;d=a.compareNums(c,b.L.v))?1:-1));return e},search:function(b){var c=this,d=b.$$,e=0,f;f=b.searchHasRun||c.isDisabled()?1:0;b.searchHasRun=1;if(f)return b.version||null;c.init(b);var g,h=function(d,f){var g=[].concat(m);g[d]=f;g=c.isActiveXObject(b,g.join(","));g?(e=1,m[d]=f):k[d]=f;return g},l=b.DIGITMAX,n,p,m=[0,0,0,0],k=[0,0,0,0];for(f=0;fk[f]&&0<=a.compareNums(p,b.Lower[g])&&0>a.compareNums(n,b.Upper[g])&&(k[f]=Math.floor(l[g][f])));for(g=0;30>g;g++){if(16>=k[f]-m[f]){for(g=k[f];g>=m[f]+(f?1:0)&&!h(f,g);g--);break}h(f,Math.round((k[f]+m[f])/2))}if(!e)break;k[f]=m[f];}e&&(b.version=c.convert(b,m.join(",")).v);return b.version||null}},win:{loaded:!1,hasRun:0,init:function(){this.hasRun||(this.hasRun=1,this.addEvent("load",this.onLoad),this.addEvent("unload",this.onUnload))},addEvent:function(b,c){var d=window;a.isFunc(c)&&(d.addEventListener?d.addEventListener(b,c,!1):d.attachEvent?d.attachEvent("on"+b,c):d["on"+b]=this.concatFn(c,d["on"+b]))},concatFn:function(a,c){return function(){a();"function"==typeof c&&c()}},loadPrvtHndlrs:[],loadPblcHndlrs:[],unloadHndlrs:[],onUnload:function(){if(a&&a.win){a.ev.callArray(a.win.unloadHndlrs);for(var b in a)a[b]=0;a=0}},count:0,countMax:1,intervalLength:10,onLoad:function(){if(a&&a.win&&!a.win.loaded){var b=a.win;b.counth||0>m||c<=this.pluginSize)return 0;g&&!b.pi&&a.isDefined(n)&&a.browser.isIE&&b.tagName==k.tagName&&b.time<=k.time&&h===m&&0===l&&0!==d&&(b.pi=1);if(m=c&&(!b.winLoaded&&a.win.loaded||a.isNum(f)&&(a.isNum(b.count2)||(b.count2=f),0.'+a.openTag+"/div>"),d=e.getElementById("pd33993399")}catch(g){}if(f=e.getElementsByTagName("body")[0]||e.body)f.insertBefore(b,f.firstChild),d&&f.removeChild(d)},insert:function(b,c,d,e,f,g,h){var l,k=document.createElement("span");a.isDefined(e)||(e="");if(a.isString(b)&&/[^\s]/.test(b)){b=b.toLowerCase().replace(/\s/g,"");l=a.openTag+b+" ";l+='style="'+this.getStyle.plugin(g)+'" ';var p=1,m=1;for(g=0;g');l+=e+a.openTag+"/"+b+">"}else b="",l=e;h||this.initDiv();c=h||this.getDiv();b={span:null,winLoaded:a.win.loaded,tagName:b,outerHTML:l,DOM:this,time:(new Date).getTime(),width:this.width,obj:this.obj,readyState:this.readyState,objectProperty:this.objectProperty};if(c&&c.parentNode){this.setStyle(k,this.getStyle.span());c.appendChild(k);try{k.innerHTML=l}catch(q){}b.span=k;b.winLoaded=a.win.loaded}return b}},file:{any:"fileStorageAny999",valid:"fileStorageValid999",save:function(b,c,d){b&&a.isDefined(d)&&(b[this.any]||(b[this.any]=[]),b[this.valid]||(b[this.valid]=[]),b[this.any].push(d),(c=this.split(c,d))&&b[this.valid].push(c))},getValidLength:function(a){return a&&a[this.valid]?a[this.valid].length:0},getAnyLength:function(a){return a&&a[this.any]?a[this.any].length:0},getValid:function(a,c){return a&&a[this.valid]?this.get(a[this.valid],c):null},getAny:function(a,c){return a&&a[this.any]?this.get(a[this.any],c):null},get:function(b,c){var d=b.length-1,e=a.isNum(c)?c:d;return 0>e||e>d?null:b[e]},split:function(b,c){var d=null,e;b=b?b.replace(".","\\."):"";e=RegExp("^(.*[^\\/])("+b+"\\s*)$");a.isString(c)&&e.test(c)&&(e=RegExp.$1.split("/"),d={name:e[e.length-1],ext:RegExp.$2,full:c},e[e.length-1]="",d.path=e.join("/"));return d}},Plugins:{}};window[a.name]=a;a.INIT();var k={mimeType:["application/x-java-applet","application/x-java-vm","application/x-java-bean"],mimeType_dummy:"application/dummymimejavaapplet",classID:"clsid:8AD9C840-044E-11D1-B3E9-00805F499D93",classID_dummy:"clsid:8AD9C840-044E-11D1-B3E9-BA9876543210",navigator:{init:function(){var b=k;try{this.a=window.navigator.javaEnabled()}catch(c){}if(this.mimeObj=a.hasMimeType(b.mimeType))this.pluginObj=this.mimeObj.enabledPlugin},a:!0,javaEnabled:function(){return this.a},mimeObj:0,pluginObj:0},OTF:null,info:{Plugin2Status:0,setPlugin2Status:function(b){a.isNum(b)&&(this.Plugin2Status=b);},getPlugin2Status:function(){var b=k.navigator,c,d,e;0===this.Plugin2Status&&(c=/Next.*Generation.*Java.*Plug-?in|Java.*Plug-?in\s*2\s/i,d=/Classic.*Java.*Plug-?in/i,e=b.pluginObj?b.pluginObj.description||"":"",b=b.pluginObj?b.pluginObj.name||"":"",c.test(e)||c.test(b)?(this.setPlugin2Status(1)):d.test(e)||d.test(b)?(this.setPlugin2Status(-1)):a.browser.isIE&&/Sun|Oracle/i.test(this.getVendor())&&(c=this.isMinJre4Plugin2(),0c&&(this.setPlugin2Status(-1))));return this.Plugin2Status},isMinJre4Plugin2:function(b){var c=k,d="",e=c.applet.codebase,f=c.applet.getResult()[0],d=1==a.OS?"1,6,0,10":2==a.OS?"1,6,0,12":"1,6,0,10";b||(b=(f&&!c.applet.isRange(f)?f:0)||c.version||(e.min&&d?0a.compareNums(b.verGecko,"1,9,0,0")||b.isOpera&&0>a.compareNums(b.verOpera,"10,50,0,0")?1:0},BrowserRequiresPlugin2:function(){var b=a.browser;return 20<=a.OS?0:b.isGecko&&0<=a.compareNums(b.verGecko,"1,9,2,0")||b.isChrome||1==a.OS&&b.isOpera&&0<=a.compareNums(b.verOpera,"10,60,0,0")?1:0},VENDORS:["Sun Microsystems Inc.","Apple Computer, Inc.","Oracle Corporation"],OracleMin:"1,7,0,0",OracleOrSun:function(b){return this.VENDORS[0>a.compareNums(a.formatNum(b),this.OracleMin)?0:2]},OracleOrApple:function(b){return this.VENDORS[0>a.compareNums(a.formatNum(b),this.OracleMin)?1:2]},getVendor:function(){var b=k,c=b.vendor||b.applet.getResult()[1]||"",d=b.applet.codebase;if(!c)if(d=b.DTK.version||d.version||(d.min?0=d||(2==d?a=1:-2!=d&&(e&&0<=d&&0=d&&0>g||(e?a=1:f||(0d||0>g||(a=0))))));return a},result:{getDeploymentToolkitObj:function(){var a=k,c=a.info,a=a.DTK;a.query(1);c.updateResult();return a.status&&a.HTML?a.HTML.obj():a.status}},updateResult:function(){var b=k,c=b.applet,d,e=b.installed;d=b.DTK;var f=c.results,g=this.result;g.DeployTK_versions=[].concat(a.isArray(d.VERSIONS)?d.VERSIONS:[]);g.vendor=this.getVendor();g.isPlugin2=this.isPlugin2InstalledEnabled();g.OTF=3>b.OTF?0:3==b.OTF?1:2;g.JavaAppletObj=null;for(d=0;dc.active[d]||3==d&&/Microsoft/i.test(g.vendor))&&(h[d]=-1)):3==d&&f[0][0]?h[d]=0:c.isDisabled.single(d)&&(h[d]=-1);g.objectTag=h[1];g.appletTag=h[2];g.objectTagActiveX=h[3];g.name="";g.description="";if(c=b.navMime.query().pluginObj||b.navigator.pluginObj||0)g.name=c.name||"",g.description=c.description||"";g.All_versions=[].concat(g.DeployTK_versions.length?g.DeployTK_versions:a.isString(b.version)?[b.version]:[]);b=g.All_versions;for(d=0;dthis.OTF&&(this.installed=g?0this.OTF?0:this.applet.can_Insert_Query_Any()?0:1);a.codebase.emptyGarbage();},DTK:{hasRun:0,status:null,VERSIONS:[],version:"",HTML:null,Plugin2Status:null,classID:["clsid:CAFEEFAC-DEC7-0000-0001-ABCDEFFEDCBA","clsid:CAFEEFAC-DEC7-0000-0000-ABCDEFFEDCBA"],mimeType:["application/java-deployment-toolkit","application/npruntime-scriptable-plugin;DeploymentToolkit"],isDisabled:function(b){return this.HTML?1:b||a.dbug?0:this.hasRun||!a.DOM.isEnabled.objectTagUsingActiveX()?1:0},query:function(b){var c=k,d,e,f=a.DOM.altHTML,g,h=null,l=null;b=this.isDisabled(b);this.hasRun=1;if(b)return this;this.status=0;if(a.DOM.isEnabled.objectTagUsingActiveX())for(d=0;dMath.abs(c.info.getPlugin2Status())&&(this.Plugin2Status=h.isPlugin2())}catch(n){}null!==this.Plugin2Status&&(this.Plugin2Status?c.info.setPlugin2Status(2):(a.DOM.isEnabled.objectTagUsingActiveX()||0>=c.info.getPlugin2Status())&&c.info.setPlugin2Status(-2));try{if(g=a.pd.getPROP(h,"jvms"))if(l=g.getLength(),a.isNum(l))for(this.status=0a.compareNums(d,a.formatNum("1,3"))||0<=a.compareNums(d,a.formatNum("2")))&&(d=0);return d},query:function(){var b=k,c=0,b=this.hasRun||!b.navigator.mimeObj;this.hasRun=1;if(b)return this;(!c||a.dbug)&&(b=this.getPlatformNum())&&(c=b);(!c||a.dbug)&&(b=this.getPluginNum())&&(c=b);c&&(this.version=a.formatNum(c));return this}},applet:{codebase:{isMin:function(b){this.$$=k;return a.codebase.isMin(this,b)},search:function(){this.$$=k;return a.codebase.search(this)},DIGITMAX:[[15,128],[6,0,512],0,[1,5,2,256],0,[1,4,1,1],[1,4,0,64],[1,3,2,32]],DIGITMIN:[1,0,0,0],Upper:"999 10 5,0,20 1,5,0,20 1,4,1,20 1,4,1,2 1,4,1 1,4".split(" "),Lower:"10 5,0,20 1,5,0,20 1,4,1,20 1,4,1,2 1,4,1 1,4 0".split(" "),convert:[function(a,c){return c?[1c-1&&a.isNum(b[c-1])&&(0>b[c-1]&&(b[c-1]=0),3a.compareNums(c.verOpera,"13,0,0,0")&&!b.javaEnabled()||this.AppletTag()&&!a.DOM.isEnabled.objectTag()||!b.mimeObj&&!c.isIE?1:0,this.all_=b);return this.all_},AppletTag:function(){var b=k.navigator;return a.browser.isIE?!b.javaEnabled():0},VerifyTagsDefault_1:function(){var b=a.browser;return b.isIE&&(9>b.verIE||!b.ActiveXEnabled)||b.verGecko&&0>a.compareNums(b.verGecko,a.formatNum("2"))||b.isSafari&&(!b.verSafari||0>a.compareNums(b.verSafari,a.formatNum("4")))||b.isOpera&&0>a.compareNums(b.verOpera,a.formatNum("11"))?0:1}},can_Insert_Query:function(a){var c=this.results[0][0],d=this.getResult()[0];return this.HTML[a]||0==a&&null!==c&&!this.isRange(c)||0==a&&d&&!this.isRange(d)?0:!this.isDisabled.single(a)},can_Insert_Query_Any:function(){var a;for(a=0;ac.OTF)){c=h.obj();g=h.readyState();try{d=a.getNum(c.getVersion()+""),e=c.getVendor()+"",c.statusbar(" ")}catch(l){}d&&a.isStrNum(d)&&(f[b]=[d,e],this.active[b]=2);}},isRange:function(a){return/^[<>]/.test(a||"")?">"==a.charAt(0)?1:-1:0},setRange:function(b,c){return(b?0":"<":"")+(a.isString(c)?c:"")},insertJavaTag:function(b,c,d,e,f){var g=k,h=a.file.getValid(g),l=h.path,h=["archive",h.name+h.ext,"code","A.class"];e=(e?["width",e]:[]).concat(f?["height",f]:[]);f=["mayscript","true"];var n=["scriptable","true","codebase_lookup","false"].concat(f),p=g.navigator,p=!a.browser.isIE&&p.mimeObj&&p.mimeObj.type?p.mimeObj.type:g.mimeType[0];if(1==b)return a.DOM.insert("object",["type",p].concat(e),["codebase",l].concat(h).concat(n),d,g,0,c);if(2==b)return a.browser.isIE?a.DOM.insert("applet",["alt",d].concat(f).concat(h).concat(e),["codebase",l].concat(n),d,g,0,c):a.DOM.insert("applet",["codebase",l,"alt",d].concat(f).concat(h).concat(e),[].concat(n),d,g,0,c);if(3==b)return a.browser.isIE?a.DOM.insert("object",["classid",g.classID].concat(e),["codebase",l].concat(h).concat(n),d,g,0,c):a.DOM.insert();if(4==b)return a.DOM.insert("embed",["codebase",l].concat(h).concat(["type",p]).concat(n).concat(e),[],d,g,0,c)},insert_Query_Any:function(b){var c=k,d=this.results,e=this.HTML,f=a.DOM.altHTML,g,h=a.file.getValid(c);this.should_Insert_Query(0)&&(2>c.OTF&&(c.OTF=2),d[0]=[0,0],(g=b?this.codebase.isMin(b):this.codebase.search())&&(d[0][0]=b?this.setRange(g,b):g),this.active[0]=g?1.5:-1);if(!h)return this.getResult();this.DummySpanTagHTML||(this.DummySpanTagHTML=a.DOM.insert("",[],[],f));this.should_Insert_Query(1)&&(2>c.OTF&&(c.OTF=2),e[1]=this.insertJavaTag(1,0,f),d[1]=[0,0],this.query(1));this.should_Insert_Query(2)&&(2>c.OTF&&(c.OTF=2),e[2]=this.insertJavaTag(2,0,f),d[2]=[0,0],this.query(2));this.should_Insert_Query(3)&&(2>c.OTF&&(c.OTF=2),e[3]=this.insertJavaTag(3,0,f),d[3]=[0,0],this.query(3));a.DOM.isEnabled.objectTag()&&(this.DummyObjTagHTML||!e[1]&&!e[2]||(this.DummyObjTagHTML=a.DOM.insert("object",["type",c.mimeType_dummy],[],f)),!this.DummyObjTagHTML2&&e[3]&&(this.DummyObjTagHTML2=a.DOM.insert("object",["classid",c.classID_dummy],[],f)));c.NOTF.init();return this.getResult()}},NOTF:{count:0,countMax:25,intervalLength:250,init:function(){var b=k;3>b.OTF&&this.shouldContinueQuery()&&(b.OTF=3,this.onIntervalQuery=a.ev.handler(this.$$onIntervalQuery,this),a.win.loaded||a.win.loadPrvtHndlrs.push([this.onWinLoadQuery,this]),setTimeout(this.onIntervalQuery,this.intervalLength))},shouldContinueQuery:function(){var b=k.applet,c,d=0;if(a.win.loaded&&this.count>this.countMax)return 0;for(c=0;cthis.countMax&&a.codebase.pluginMayBeHanging(b.HTML[c].span)&&(d=1,b.HTML[c].DELETE=1),!d&&!b.results[c][0]&&(2<=b.allowed[c]||1==b.allowed[c]&&!b.getResult()[0])&&0<=this.isAppletActive(c)))return 1;return 0},isJavaActive:function(a){var c=k,d,e,f=-9;for(d=0;df&&(f=e);return f},isAppletActive:function(b,c){var d=k,e=d.navigator,f=d.applet,g=f.HTML[b],h=f.active,l=0,n;n=h[b];if(c||1.5<=n||!g||!g.span)return n;n=a.DOM.getTagStatus(g,f.DummySpanTagHTML,f.DummyObjTagHTML,f.DummyObjTagHTML2,this.count);for(f=0;f isSupported = false result = (url) -> + unblockUI() if isSupported is false location.href = url @@ -61,6 +62,7 @@ launchIE = (el, url, alt) -> #IE10+ if navigator.msLaunchUri navigator.msLaunchUri url, (-> + unblockUI() isSupported = true return ), -> @@ -79,6 +81,7 @@ launchIE = (el, url, alt) -> console.log 'Blur' window.onblur = null isSupported = true + result(alt) return ) @@ -87,7 +90,7 @@ launchIE = (el, url, alt) -> setTimeout (-> window.onblur = null result(alt) - ), 800 + ), 2800 # setTimeout (-> # try @@ -131,8 +134,8 @@ launchChrome = (el, url, alt) -> window.onblur = -> isSupported = true - console.log 'onblur called' window.onblur = null + result(alt) return #will trigger onblur @@ -143,7 +146,7 @@ launchChrome = (el, url, alt) -> if isSupported is false result(alt) return - ), 800 + ), 2800 return # Handle safari @@ -156,7 +159,7 @@ launchSafari = (el, url, alt) -> window.onblur = -> isSupported = true - console.log 'Text Field onblur called' + result(alt) return iFrame.contentWindow.location.href = url @@ -164,7 +167,7 @@ launchSafari = (el, url, alt) -> setTimeout (-> window.onblur = null result(alt) - ), 1800 + ), 2800 uds.launch = (el) -> @@ -181,13 +184,13 @@ uds.launch = (el) -> type: "GET" dataType: "json" success: (data) -> - unblockUI() if data.error? and data.error isnt '' alert data.error else if bypassPluginDetection is false uds.doLaunch el, data.url, alt else + unblockUI() window.location = data.url return diff --git a/server/src/uds/static/other/getJavaInfo.jar b/server/src/uds/static/other/getJavaInfo.jar deleted file mode 100644 index 50bd83e6d70b042ebd8c2ecd1f3f6e53c6d75365..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 858 zcmWIWW@Zs#-~hs=-t|rlNPwMzg~3rTIVZ8W_}?i8hTh=V;L8C5w$rDnwS1V$q|^~| z@Roj5AmdMg9KnDbLEYxV7FLtDEe!F#V;K9tI0E#MU4#4?#_5mS=TEkTjO?%$f6&O3A;@qI71 zG}1lTE6KTehkBCVkv$EpoZUP06FiR?J+~DQd_Gf{DU8J?<%5pcm!_>p9&oXgOWe_R z^Gkl=DOQrZxoE=0Gr6Y0Do4&{^2Ao2?V9doJu6aA!pgZ`VMfhjxm6n%t$LoEd0OYi zPgb_ZjOb;7Ngvq%^=`kTba7hMExzCG=OxwFo}QK!dP;KYHRiROCgy17hMZZmE$l&% z?MDsulM=@|8bT$rBg8*=981nID7npfMOk}Vh;h`!#0{3oi#Bav9=P!xFV_#g>{-uh zjpiw6Cd=5ho$KglijhCA?x1$`tic~9vs9a-Vx=WkR!14y?mgpTns>6I?={c8?hCJW zuL;}q=J9EnUaP68F^|vqu|IZAUGgwJp^$B9*_@!2DB-paaZ6I+me}4eI+W= zA6tKwNn2`2?ppTQTQ57z>FmCm*WPpZ>~^o1U-W8)#i#i2nAciUMRXUpnS@=} zotoB{9a=oaD;$*P=!X>YDtmA1=CyQe$FUkGc}F5&zB&hl3I`3He5 zT1NszWuJ(w-1bf-ytSrnoz|}Sm?!U+E$7pjJi%hwM1>L_yXD6^l#eg{GRLGdQr+A5 zp}^xOcb~9Nxfk+-{g<61Pkrm8Up(K_p0qUSeQ{{K?z!;BlUS#Cp?_T;u8T;nzb@-M zJJy9m^KU4R$@O!S=4QCcQ){{mjKbo05vrUx0 z(B0p1Z^?f%mOADDZ+4DNPapeUVq#!WU}azk@MdHZVL)UCWI0e~Km|xyBfy)L4J643 MgqA>>n;FCd0K-dfT>t<8 diff --git a/server/src/uds/templates/uds/detectJava.html b/server/src/uds/templates/uds/detectJava.html deleted file mode 100644 index b893917d..00000000 --- a/server/src/uds/templates/uds/detectJava.html +++ /dev/null @@ -1,40 +0,0 @@ -{% extends "uds/base.html" %} -{% load i18n %} -{% load static %} - -{% block title %} -{% trans "Login redirection" %} -{% endblock %} - -{% block script %} - - -{% endblock %} - -{% block top %} - - {% include "uds/snippets/lang.html" %} -{% endblock %} - -{% block content %} - - -{% endblock %} \ No newline at end of file diff --git a/server/src/uds/templates/uds/html5/client/download_client.html b/server/src/uds/templates/uds/html5/client/download_client.html deleted file mode 100644 index 851d075a..00000000 --- a/server/src/uds/templates/uds/html5/client/download_client.html +++ /dev/null @@ -1,45 +0,0 @@ -{% extends "uds/html5/templates/base.html" %} -{% load i18n html5 static %} - -{% block title %} -{% trans 'Download UDS plugin for' %} {{ os|osName }} -{% endblock %} - -{% block body %} -
-
-

{% trans 'Download UDS Plugin for' %} {{ os|osName }}

-

{% trans 'In order to be able to execute UDS services, you need to have uds plugin installed.' %}

-

{% trans 'If for any reason, you have uds plugin already installed but this message persist to appear, you can force the execution by pressing ctrl when launching the service.' %}

- -

{% trans 'Download UDS Plugin for' %} {{ os|osName }}

-
-
- -
-
-

{% trans 'or select another version' %}

- {% if os != 'linux' %} - - {% endif %} - {% if os != 'windows' %} - - {% endif %} - {% if os != 'mac' %} - - {% endif %} - -
-
- - - -{% endblock %} diff --git a/server/src/uds/templates/uds/html5/detectJava.html b/server/src/uds/templates/uds/html5/detectJava.html deleted file mode 100644 index e4aff816..00000000 --- a/server/src/uds/templates/uds/html5/detectJava.html +++ /dev/null @@ -1,29 +0,0 @@ -{% extends "uds/html5/templates/base.html" %} -{% load i18n static %} - -{% block title %}{% trans "Login redirection to UDS" %}{% endblock %} - -{% block js %} - - -{% endblock %} - -{% block body %} - -{% endblock %} diff --git a/server/src/uds/templates/uds/html5/download_client.html b/server/src/uds/templates/uds/html5/download_client.html new file mode 100644 index 00000000..65225ec5 --- /dev/null +++ b/server/src/uds/templates/uds/html5/download_client.html @@ -0,0 +1,71 @@ +{% extends "uds/html5/templates/base.html" %} +{% load i18n html5 static %} + +{% block title %} +{% trans 'Download UDS plugin for' %} {{ os|osName }} +{% endblock %} + +{% block body %} +
+
+

{% trans 'Download UDS Plugin for' %} {{ os|osName }}

+

{% trans 'In order to be able to execute UDS services, you need to have uds plugin installed.' %}

+

{% trans 'Download UDS Plugin for' %} {{ os|osName }}

+

{% trans 'Or select another version' %}

+

+ {% if os != 'linux' %} +

+ {% trans 'Linux UDS plugin' %} +

+ {% endif %} + {% if os != 'windows' %} +

+ {% trans 'Windows UDS plugin' %} +

+ {% endif %} + {% if os != 'mac' %} +

+ {% trans 'Mac OSX (>10.5) UDS plugin' %} +

+ {% endif %} +

+ + {% if request.user %} +

{% trans 'If you already have UDS Plugin installed but this message persists to appear, you can disable it here' %}

+

+

+ +
+

+

+ {% trans "Return" %} +

+ {% endif %} +
+ +{% endblock %} + +{% block js %} +{% if request.user %} + +{% endif %} +{% endblock %} diff --git a/server/src/uds/templates/uds/html5/login.html b/server/src/uds/templates/uds/html5/login.html index 4f7ce901..90f9e7ba 100644 --- a/server/src/uds/templates/uds/html5/login.html +++ b/server/src/uds/templates/uds/html5/login.html @@ -4,17 +4,7 @@ {% block title %}{% trans 'Welcome to UDS' %}{% endblock %} {% block js %} - {% endcompress %} diff --git a/server/src/uds/templates/uds/transport/udslink.html b/server/src/uds/templates/uds/transport/udslink.html deleted file mode 100644 index 8d61bfa2..00000000 --- a/server/src/uds/templates/uds/transport/udslink.html +++ /dev/null @@ -1,3 +0,0 @@ -{% load i18n static html5 %} - -Link to {{ uri }} diff --git a/server/src/uds/templatetags/html5.py b/server/src/uds/templatetags/html5.py index d1bedf33..ff036e6b 100644 --- a/server/src/uds/templatetags/html5.py +++ b/server/src/uds/templatetags/html5.py @@ -122,6 +122,9 @@ class Preference(template.Node): self.prefName = prefName def render(self, context): + if context.get('user') is None: + return '' + prefs = context['user'].prefs(self.modName) return prefs.get(self.prefName) diff --git a/server/src/uds/urls.py b/server/src/uds/urls.py index 09e6c2b8..59a25916 100644 --- a/server/src/uds/urls.py +++ b/server/src/uds/urls.py @@ -43,7 +43,7 @@ urlpatterns = patterns( 'uds', url(r'^$', 'web.views.index', name='Index'), (r'^login/$', 'web.views.login'), - (r'^login/(?P.+)$', 'web.views.login'), + (r'^login/(?P.+)$', 'web.views.login'), (r'^logout$', 'web.views.logout'), (r'^service/(?P.+)/(?P.+)$', 'web.views.service'), # Icons @@ -69,12 +69,12 @@ urlpatterns = patterns( # downloads for client url(r'^down$', 'web.views.client_downloads', name='ClientDownload'), (r'^down/(?P[a-zA-Z0-9-]*)$', 'web.views.client_downloads'), + url(r'^pluginDetection/(?P[a-zA-Z0-9-]*)$', 'web.views.plugin_detection', name='PluginDetection'), # Client access enabler url(r'^enable/(?P.+)/(?P.+)$', 'web.views.clientEnabler', name='ClientAccessEnabler'), # Custom authentication callback (r'^auth/(?P.+)', 'web.views.authCallback'), - (r'^authJava/(?P.+)/(?P.*)$', 'web.views.authJava'), (r'^authinfo/(?P.+)', 'web.views.authInfo'), (r'^about', 'web.views.about'), # Ticket authentication diff --git a/server/src/uds/web/forms/LoginForm.py b/server/src/uds/web/forms/LoginForm.py index 8079c579..6762e897 100644 --- a/server/src/uds/web/forms/LoginForm.py +++ b/server/src/uds/web/forms/LoginForm.py @@ -42,6 +42,8 @@ import logging logger = logging.getLogger(__name__) +# pylint: disable=no-value-for-parameter, unexpected-keyword-arg + class CustomSelect(forms.Select): def render(self, name, value, attrs=None): @@ -64,7 +66,7 @@ class BaseForm(forms.Form): def add_form_error(self, message): if not self._errors: self._errors = ErrorDict() - if not NON_FIELD_ERRORS in self._errors: + if NON_FIELD_ERRORS not in self._errors: self._errors[NON_FIELD_ERRORS] = self.error_class() self._errors[NON_FIELD_ERRORS].append(message) @@ -73,17 +75,16 @@ class LoginForm(BaseForm): user = forms.CharField(label=_('Username'), max_length=64, widget=forms.TextInput()) password = forms.CharField(label=_('Password'), widget=forms.PasswordInput(attrs={'title': _('Password')}), required=False) authenticator = forms.ChoiceField(label=_('Authenticator'), choices=(), widget=CustomSelect(), required=False) - java = forms.CharField(widget=forms.HiddenInput()) standard = forms.CharField(widget=forms.HiddenInput(), required=False) nonStandard = forms.CharField(widget=forms.HiddenInput(), required=False) def __init__(self, *args, **kwargs): # If an specified login is passed in, retrieve it & remove it from kwargs dict - smallName = kwargs.get('smallName', None) - if kwargs.has_key('smallName'): - del kwargs['smallName'] + tag = kwargs.get('tag', None) + if 'tag' in kwargs: + del kwargs['tag'] - logger.debug('smallName is "{0}"'.format(smallName)) + logger.debug('tag is "{0}"'.format(tag)) super(LoginForm, self).__init__(*args, **kwargs) choices = [] @@ -91,8 +92,8 @@ class LoginForm(BaseForm): standard = [] auths = None - if smallName is not None: - auths = Authenticator.objects.filter(small_name=smallName).order_by('priority', 'name') + if tag is not None: + auths = Authenticator.objects.filter(small_name=tag).order_by('priority', 'name') if auths.count() == 0: auths = Authenticator.objects.all().order_by('priority', 'name')[0:1] logger.debug(auths) @@ -103,7 +104,7 @@ class LoginForm(BaseForm): for a in auths: if a.getType() is None: continue - if a.getType().isCustom() and smallName == 'disabled': + if a.getType().isCustom() and tag == 'disabled': continue choices.append((a.id, a.name)) if a.getType().isCustom(): diff --git a/server/src/uds/web/views/__init__.py b/server/src/uds/web/views/__init__.py index 19025f2f..22ed8121 100644 --- a/server/src/uds/web/views/__init__.py +++ b/server/src/uds/web/views/__init__.py @@ -30,7 +30,7 @@ ''' from __future__ import unicode_literals -__updated__ = '2015-03-26' +__updated__ = '2015-03-27' import logging @@ -40,8 +40,8 @@ from .login import login, logout, customAuth from .index import index, about from .prefs import prefs from .service import service, trans, transcomp, sernotify, transportIcon, serviceImage, clientEnabler -from .auth import authCallback, authInfo, authJava, ticketAuth +from .auth import authCallback, authInfo, ticketAuth from .download import download -from .client_download import client_downloads +from .client_download import client_downloads, plugin_detection from .js import jsCatalog from ..errors import error diff --git a/server/src/uds/web/views/auth.py b/server/src/uds/web/views/auth.py index 6068bfae..da1067b0 100644 --- a/server/src/uds/web/views/auth.py +++ b/server/src/uds/web/views/auth.py @@ -30,23 +30,19 @@ ''' from __future__ import unicode_literals -__updated__ = '2015-02-28' +__updated__ = '2015-03-27' from django.http import HttpResponse, HttpResponseRedirect, HttpResponsePermanentRedirect from django.views.decorators.csrf import csrf_exempt -from django.shortcuts import render_to_response -from django.shortcuts import redirect -from django.template import RequestContext from django.utils.translation import ugettext as _ from django.core.urlresolvers import reverse from django.views.decorators.cache import never_cache -from uds.core.auths.auth import webLogin, webLogout, webLoginRequired, authenticateViaCallback, authLogLogin, getUDSCookie +from uds.core.auths.auth import webLogin, webLogout, authenticateViaCallback, authLogLogin, getUDSCookie from uds.models import Authenticator, DeployedService, Transport from uds.core.util import OsDetector from uds.core.util.Ticket import Ticket from uds.core.util.State import State -from uds.core.ui import theme from uds.core.auths.Exceptions import InvalidUserException from uds.core.services.Exceptions import InvalidServiceException, ServiceInMaintenanceMode @@ -84,12 +80,10 @@ def authCallback(request, authName): os = OsDetector.getOsFromUA(request.META['HTTP_USER_AGENT']) if user is None: - authLogLogin(request, authenticator, '{0}'.format(params), False, os, 'Invalid at auth callback') + authLogLogin(request, authenticator, '{0}'.format(params), 'Invalid at auth callback') raise auths.Exceptions.InvalidUserException() - # Redirect to main page through java detection process, so UDS know the availability of java - response = render_to_response(theme.template('detectJava.html'), {'idAuth': authenticator.uuid}, - context_instance=RequestContext(request)) + response = HttpResponseRedirect(reverse('Index')) webLogin(request, response, user, '') # Password is unavailable in this case request.session['OS'] = os @@ -137,19 +131,6 @@ def authInfo(request, authName): return HttpResponse(_('Authenticator does not provide information')) -@webLoginRequired(admin=False) -def authJava(request, idAuth, hasJava): - request.session['java'] = hasJava == 'y' - try: - authenticator = Authenticator.objects.get(uuid=idAuth) - os = OsDetector.getOsFromRequest(request) - authLogLogin(request, authenticator, request.user.name, request.session['java'], os) - return redirect('uds.web.views.index') - - except Exception as e: - return errors.exceptionView(request, e) - - @never_cache def ticketAuth(request, ticketId): ''' @@ -201,8 +182,6 @@ def ticketAuth(request, ticketId): # Force cookie generation webLogin(request, None, usr, password) - request.session['java'] = True - request.session['OS'] = OsDetector.getOsFromUA(request.META.get('HTTP_USER_AGENT')) request.user = usr # Temporarily store this user as "authenticated" user, next requests will be done using session # Check if servicePool is part of the ticket diff --git a/server/src/uds/web/views/client_download.py b/server/src/uds/web/views/client_download.py index 44c49b85..2412d027 100644 --- a/server/src/uds/web/views/client_download.py +++ b/server/src/uds/web/views/client_download.py @@ -30,14 +30,15 @@ ''' from __future__ import unicode_literals -__updated__ = '2015-03-26' +__updated__ = '2015-03-27' -from uds.core.managers.UserPrefsManager import UserPrefsManager, CommonPrefs +from django.http import HttpResponse from django.utils.translation import ugettext_noop from django.shortcuts import render_to_response from django.template import RequestContext +from uds.core.managers.UserPrefsManager import UserPrefsManager, CommonPrefs from uds.core.auths.auth import webLoginRequired from uds.core.ui import theme from uds.core.util.OsDetector import desktopOss @@ -56,15 +57,22 @@ UserPrefsManager.manager().registerPrefs( ) -@webLoginRequired(admin=False) def client_downloads(request, os=None): ''' - Downloadables management + Download page for UDS plugins ''' if os not in desktopOss: os = request.os['OS'] logger.debug('User: {}'.format(request.user)) os = os.lower() - return render_to_response(theme.template('client/download_client.html'), + return render_to_response(theme.template('download_client.html'), {'os': os, 'user': request.user}, context_instance=RequestContext(request)) + + +@webLoginRequired(admin=False) +def plugin_detection(request, detection): + if detection != '0': + detection = '1' + UserPrefsManager.manager().setPreferenceForUser(request.user, '_uds', CommonPrefs.BYPASS_PREF, detection) + return HttpResponse(content='', content_type='text/plain') diff --git a/server/src/uds/web/views/login.py b/server/src/uds/web/views/login.py index 80983a96..55fecfa1 100644 --- a/server/src/uds/web/views/login.py +++ b/server/src/uds/web/views/login.py @@ -30,7 +30,7 @@ ''' from __future__ import unicode_literals -__updated__ = '2015-02-28' +__updated__ = '2015-03-27' from django.http import HttpResponse, HttpResponseRedirect from django.shortcuts import render_to_response @@ -51,11 +51,11 @@ import logging logger = logging.getLogger(__name__) -def login(request, smallName=None): +def login(request, tag=None): ''' View responsible of logging in an user :param request: http request - :param smallName: smallName of login auth + :param tag: tag of login auth ''' # request.session.set_expiry(GlobalConfig.USER_SESSION_LENGTH.getInt()) @@ -64,17 +64,17 @@ def login(request, smallName=None): # Get Authenticators limitation logger.debug('Host: {0}'.format(host)) if GlobalConfig.DISALLOW_GLOBAL_LOGIN.getBool(True) is True: - if smallName is None: + if tag is None: try: Authenticator.objects.get(small_name=host) - smallName = host + tag = host except Exception: try: - smallName = Authenticator.objects.order_by('priority')[0].small_name + tag = Authenticator.objects.order_by('priority')[0].small_name except Exception: # There is no authenticators yet, simply allow global login to nowhere.. :-) - smallName = None + tag = None - logger.debug('Tag: {0}'.format(smallName)) + logger.debug('Tag: {0}'.format(tag)) logger.debug(request.method) if request.method == 'POST': @@ -82,9 +82,8 @@ def login(request, smallName=None): logger.debug('Request does not have uds cookie') return errors.errorView(request, errors.COOKIES_NEEDED) # We need cookies to keep session data request.session.cycle_key() - form = LoginForm(request.POST, smallName=smallName) + form = LoginForm(request.POST, tag=tag) if form.is_valid(): - java = form.cleaned_data['java'] == 'y' os = OsDetector.getOsFromUA(request.META.get('HTTP_USER_AGENT')) try: authenticator = Authenticator.objects.get(pk=form.cleaned_data['authenticator']) @@ -99,7 +98,7 @@ def login(request, smallName=None): tries = 0 if authenticator.getInstance().blockUserOnLoginFailures is True and tries >= GlobalConfig.MAX_LOGIN_TRIES.getInt(): form.add_form_error('Too many authentication errors. User temporarily blocked.') - authLogLogin(request, authenticator, userName, java, os, 'Temporarily blocked') + authLogLogin(request, authenticator, userName, 'Temporarily blocked') else: user = authenticate(userName, form.cleaned_data['password'], authenticator) logger.debug('User: {}'.format(user)) @@ -109,20 +108,18 @@ def login(request, smallName=None): tries += 1 cache.put(cacheKey, tries, GlobalConfig.LOGIN_BLOCK.getInt()) form.add_form_error('Invalid credentials') - authLogLogin(request, authenticator, userName, java, os, 'Invalid credentials') + authLogLogin(request, authenticator, userName, 'Invalid credentials') else: logger.debug('User {} has logged in'.format(userName)) cache.remove(cacheKey) # Valid login, remove cached tries response = HttpResponseRedirect(reverse('uds.web.views.index')) webLogin(request, response, user, form.cleaned_data['password']) # Add the "java supported" flag to session - request.session['java'] = java request.session['OS'] = os - logger.debug('Navigator supports java? {0}'.format(java)) - authLogLogin(request, authenticator, user.name, java, os) + authLogLogin(request, authenticator, user.name) return response else: - form = LoginForm(smallName=smallName) + form = LoginForm(tag=tag) response = render_to_response(theme.template('login.html'), {'form': form, 'customHtml': GlobalConfig.CUSTOM_HTML_LOGIN.get(True)}, context_instance=RequestContext(request)) diff --git a/server/src/uds/web/views/service.py b/server/src/uds/web/views/service.py index 4546d824..40682e12 100644 --- a/server/src/uds/web/views/service.py +++ b/server/src/uds/web/views/service.py @@ -30,7 +30,7 @@ ''' from __future__ import unicode_literals -__updated__ = '2015-03-26' +__updated__ = '2015-03-27' from django.utils.translation import ugettext as _ from django.http import HttpResponse, HttpResponseRedirect @@ -62,7 +62,7 @@ logger = logging.getLogger(__name__) __updated__ = '2015-02-22' -def getService(request, idService, idTransport): +def getService(request, idService, idTransport, doTest=True): kind, idService = idService[0], idService[1:] logger.debug('Kind of service: {0}, idService: {1}'.format(kind, idService)) @@ -82,6 +82,10 @@ def getService(request, idService, idTransport): logger.debug('Found service: {0}'.format(ads)) trans = Transport.objects.get(uuid=idTransport) + + if doTest is False: + return (None, ads, None, trans, None) + # Test if the service is ready if ads.isReady(): log.doLog(ads, log.INFO, "User {0} from {1} has initiated access".format(request.user.name, request.ip), log.WEB) @@ -213,13 +217,13 @@ def clientEnabler(request, idService, idTransport): url = '' error = _('Service not ready. Please, try again in a while.') try: - res = getService(request, idService, idTransport) + res = getService(request, idService, idTransport, doTest=False) if res is not None: scrambler = cryptoManager().randomString(32) password = cryptoManager().xor(webPassword(request), scrambler) - ip, ads, iads, trans, itrans = res + _x, ads, _x, trans, _x = res data = { 'service': ads.uuid,