forked from shaba/openuds
Almost done with web part of new model. Retired java checks from code & pages
This commit is contained in:
parent
c7d3e4022f
commit
c5444f0df2
@ -49,12 +49,11 @@ from uds.core.util.stats import events
|
|||||||
from uds.core.managers.CryptoManager import CryptoManager
|
from uds.core.managers.CryptoManager import CryptoManager
|
||||||
from uds.core.util.State import State
|
from uds.core.util.State import State
|
||||||
from uds.models import User
|
from uds.models import User
|
||||||
from uds.core.util.request import getRequest
|
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
import six
|
import six
|
||||||
|
|
||||||
__updated__ = '2015-03-06'
|
__updated__ = '2015-03-27'
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
authLogger = logging.getLogger('authLog')
|
authLogger = logging.getLogger('authLog')
|
||||||
@ -102,7 +101,7 @@ def getIp(request):
|
|||||||
|
|
||||||
|
|
||||||
# Decorator to make easier protect pages that needs to be logged in
|
# 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
|
Decorator to set protection to access page
|
||||||
Look for samples at uds.core.web.views
|
Look for samples at uds.core.web.views
|
||||||
@ -113,17 +112,7 @@ def webLoginRequired(admin):
|
|||||||
'''
|
'''
|
||||||
Wrapped function for decorator
|
Wrapped function for decorator
|
||||||
'''
|
'''
|
||||||
user = request.session.get(USER_KEY)
|
if request.user is None:
|
||||||
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:
|
|
||||||
url = request.build_absolute_uri(GlobalConfig.LOGIN_URL.get())
|
url = request.build_absolute_uri(GlobalConfig.LOGIN_URL.get())
|
||||||
if GlobalConfig.REDIRECT_TO_HTTPS.getBool() is True:
|
if GlobalConfig.REDIRECT_TO_HTTPS.getBool() is True:
|
||||||
url = url.replace('http://', 'https://')
|
url = url.replace('http://', 'https://')
|
||||||
@ -131,12 +120,9 @@ def webLoginRequired(admin):
|
|||||||
return HttpResponseRedirect(url)
|
return HttpResponseRedirect(url)
|
||||||
|
|
||||||
if admin is True or admin == 'admin':
|
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'))
|
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 view_func(request, *args, **kwargs)
|
||||||
return _wrapped_view
|
return _wrapped_view
|
||||||
return decorator
|
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
|
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
|
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)
|
username = authInstance.transformUsername(username)
|
||||||
logger.debug('Transformed username: {0}'.format(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))
|
return HttpResponseRedirect(request.build_absolute_uri(exit_url))
|
||||||
|
|
||||||
|
|
||||||
def authLogLogin(request, authenticator, userName, java, os, logStr=''):
|
def authLogLogin(request, authenticator, userName, logStr=''):
|
||||||
'''
|
'''
|
||||||
Logs authentication
|
Logs authentication
|
||||||
'''
|
'''
|
||||||
if logStr == '':
|
if logStr == '':
|
||||||
logStr = 'Logged in'
|
logStr = 'Logged in'
|
||||||
|
|
||||||
javaStr = java and 'Java' or 'No Java'
|
authLogger.info('|'.join([authenticator.name, userName, request.ip, request.os['OS'], logStr, request.META.get('HTTP_USER_AGENT', 'Undefined')]))
|
||||||
authLogger.info('|'.join([authenticator.name, userName, request.ip, javaStr, os['OS'], logStr, request.META.get('HTTP_USER_AGENT', 'Undefined')]))
|
|
||||||
level = (logStr == 'Logged in') and log.INFO or log.ERROR
|
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,
|
log.doLog(authenticator, level, 'user {0} has {1} from {2} where os is {3}'.format(userName, logStr,
|
||||||
request.ip, java and 'has' or 'has NOT', os['OS']), log.WEB)
|
request.ip, request.os['OS']), log.WEB)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
user = authenticator.users.get(name=userName)
|
user = authenticator.users.get(name=userName)
|
||||||
log.doLog(user, level,
|
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
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
@ -73,6 +73,12 @@ class UserPrefsManager(object):
|
|||||||
prefs[p.getName()] = p.getDefValue()
|
prefs[p.getName()] = p.getDefValue()
|
||||||
return prefs
|
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):
|
def getHtmlForUserPreferences(self, user):
|
||||||
# First fill data for all preferences
|
# First fill data for all preferences
|
||||||
data = {}
|
data = {}
|
||||||
|
@ -32,11 +32,13 @@
|
|||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
from uds.core.util import OsDetector
|
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 threading
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
__updated__ = '2015-03-18'
|
__updated__ = '2015-03-27'
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
@ -60,6 +62,9 @@ class GlobalRequestMiddleware(object):
|
|||||||
GlobalRequestMiddleware.fillIps(request)
|
GlobalRequestMiddleware.fillIps(request)
|
||||||
# Ensures request contains os
|
# Ensures request contains os
|
||||||
OsDetector.getOsFromRequest(request)
|
OsDetector.getOsFromRequest(request)
|
||||||
|
# Ensures that requests contains the valid user
|
||||||
|
GlobalRequestMiddleware.getUser(request)
|
||||||
|
|
||||||
# Add a counter var, reseted on every request
|
# Add a counter var, reseted on every request
|
||||||
_requests[getIdent()] = request
|
_requests[getIdent()] = request
|
||||||
return None
|
return None
|
||||||
@ -98,3 +103,22 @@ class GlobalRequestMiddleware(object):
|
|||||||
request.ip_proxy = request.ip
|
request.ip_proxy = request.ip
|
||||||
request.is_proxy = False
|
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
|
||||||
|
@ -132,4 +132,4 @@ footer {
|
|||||||
width: 32px;
|
width: 32px;
|
||||||
height: 32px;
|
height: 32px;
|
||||||
margin-top: -8px;
|
margin-top: -8px;
|
||||||
}
|
}
|
||||||
|
File diff suppressed because one or more lines are too long
@ -40,6 +40,7 @@ unblockUI = ->
|
|||||||
isSupported = false
|
isSupported = false
|
||||||
|
|
||||||
result = (url) ->
|
result = (url) ->
|
||||||
|
unblockUI()
|
||||||
if isSupported is false
|
if isSupported is false
|
||||||
location.href = url
|
location.href = url
|
||||||
|
|
||||||
@ -61,6 +62,7 @@ launchIE = (el, url, alt) ->
|
|||||||
#IE10+
|
#IE10+
|
||||||
if navigator.msLaunchUri
|
if navigator.msLaunchUri
|
||||||
navigator.msLaunchUri url, (->
|
navigator.msLaunchUri url, (->
|
||||||
|
unblockUI()
|
||||||
isSupported = true
|
isSupported = true
|
||||||
return
|
return
|
||||||
), ->
|
), ->
|
||||||
@ -79,6 +81,7 @@ launchIE = (el, url, alt) ->
|
|||||||
console.log 'Blur'
|
console.log 'Blur'
|
||||||
window.onblur = null
|
window.onblur = null
|
||||||
isSupported = true
|
isSupported = true
|
||||||
|
result(alt)
|
||||||
return
|
return
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -87,7 +90,7 @@ launchIE = (el, url, alt) ->
|
|||||||
setTimeout (->
|
setTimeout (->
|
||||||
window.onblur = null
|
window.onblur = null
|
||||||
result(alt)
|
result(alt)
|
||||||
), 800
|
), 2800
|
||||||
|
|
||||||
# setTimeout (->
|
# setTimeout (->
|
||||||
# try
|
# try
|
||||||
@ -131,8 +134,8 @@ launchChrome = (el, url, alt) ->
|
|||||||
|
|
||||||
window.onblur = ->
|
window.onblur = ->
|
||||||
isSupported = true
|
isSupported = true
|
||||||
console.log 'onblur called'
|
|
||||||
window.onblur = null
|
window.onblur = null
|
||||||
|
result(alt)
|
||||||
return
|
return
|
||||||
|
|
||||||
#will trigger onblur
|
#will trigger onblur
|
||||||
@ -143,7 +146,7 @@ launchChrome = (el, url, alt) ->
|
|||||||
if isSupported is false
|
if isSupported is false
|
||||||
result(alt)
|
result(alt)
|
||||||
return
|
return
|
||||||
), 800
|
), 2800
|
||||||
return
|
return
|
||||||
|
|
||||||
# Handle safari
|
# Handle safari
|
||||||
@ -156,7 +159,7 @@ launchSafari = (el, url, alt) ->
|
|||||||
|
|
||||||
window.onblur = ->
|
window.onblur = ->
|
||||||
isSupported = true
|
isSupported = true
|
||||||
console.log 'Text Field onblur called'
|
result(alt)
|
||||||
return
|
return
|
||||||
|
|
||||||
iFrame.contentWindow.location.href = url
|
iFrame.contentWindow.location.href = url
|
||||||
@ -164,7 +167,7 @@ launchSafari = (el, url, alt) ->
|
|||||||
setTimeout (->
|
setTimeout (->
|
||||||
window.onblur = null
|
window.onblur = null
|
||||||
result(alt)
|
result(alt)
|
||||||
), 1800
|
), 2800
|
||||||
|
|
||||||
|
|
||||||
uds.launch = (el) ->
|
uds.launch = (el) ->
|
||||||
@ -181,13 +184,13 @@ uds.launch = (el) ->
|
|||||||
type: "GET"
|
type: "GET"
|
||||||
dataType: "json"
|
dataType: "json"
|
||||||
success: (data) ->
|
success: (data) ->
|
||||||
unblockUI()
|
|
||||||
if data.error? and data.error isnt ''
|
if data.error? and data.error isnt ''
|
||||||
alert data.error
|
alert data.error
|
||||||
else
|
else
|
||||||
if bypassPluginDetection is false
|
if bypassPluginDetection is false
|
||||||
uds.doLaunch el, data.url, alt
|
uds.doLaunch el, data.url, alt
|
||||||
else
|
else
|
||||||
|
unblockUI()
|
||||||
window.location = data.url
|
window.location = data.url
|
||||||
return
|
return
|
||||||
|
|
||||||
|
Binary file not shown.
@ -1,40 +0,0 @@
|
|||||||
{% extends "uds/base.html" %}
|
|
||||||
{% load i18n %}
|
|
||||||
{% load static %}
|
|
||||||
|
|
||||||
{% block title %}
|
|
||||||
{% trans "Login redirection" %}
|
|
||||||
{% endblock %}
|
|
||||||
|
|
||||||
{% block script %}
|
|
||||||
<script src="{% get_static_prefix %}js/PluginDetect_Java.js" type="text/javascript" ></script>
|
|
||||||
<script type="text/javascript">
|
|
||||||
function isJavaAvailable() {
|
|
||||||
if( PluginDetect.isMinVersion('Java', '1,6,0,0','{% get_static_prefix %}/other/getJavaInfo.jar') == 1 )
|
|
||||||
return true;
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
$(document).ready(function() {
|
|
||||||
var java = isJavaAvailable() ? "y" : "n";
|
|
||||||
window.location.replace("{% url "uds.web.views.authJava" idAuth=idAuth hasJava='' %}" + java);
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
</script>
|
|
||||||
{% endblock %}
|
|
||||||
|
|
||||||
{% block top %}
|
|
||||||
<div id="lheader">
|
|
||||||
<h1><a href="{% url "uds.web.views.index" %}">U<span>d</span>S</a></h1>
|
|
||||||
</div>
|
|
||||||
{% include "uds/snippets/lang.html" %}
|
|
||||||
{% endblock %}
|
|
||||||
|
|
||||||
{% block content %}
|
|
||||||
|
|
||||||
<!--<div>
|
|
||||||
<a href="<a href="{% url "uds.web.views.index" %}">{% trans "Go to main page" %}
|
|
||||||
</div>-->
|
|
||||||
{% endblock %}
|
|
@ -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 %}
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-md-8 col-md-offset-2 bg-primary">
|
|
||||||
<h3 class="text-center">{% trans 'Download UDS Plugin for' %} {{ os|osName }}</h3>
|
|
||||||
<p>{% trans 'In order to be able to execute UDS services, you need to have uds plugin installed.' %}</p>
|
|
||||||
<p>{% trans 'If for any reason, you have uds plugin already installed but this message persist to appear, you can force the execution by pressing <kbd>ctrl</kbd> when launching the service.' %}</p>
|
|
||||||
|
|
||||||
<p class="text-center"><a href="{{ os|pluginDownloadUrl }}" class="btn btn-success">{% trans 'Download UDS Plugin for' %} {{ os|osName }}</a></p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-md-8 col-md-offset-2 bg-success">
|
|
||||||
<h3>{% trans 'or select another version' %}</h3>
|
|
||||||
{% if os != 'linux' %}
|
|
||||||
<div>
|
|
||||||
<a href="#">{% trans 'Linux UDS plugin' %}</a>
|
|
||||||
</div>
|
|
||||||
{% endif %}
|
|
||||||
{% if os != 'windows' %}
|
|
||||||
<div>
|
|
||||||
<a href="#">{% trans 'Windows UDS plugin' %}</a>
|
|
||||||
</div>
|
|
||||||
{% endif %}
|
|
||||||
{% if os != 'mac' %}
|
|
||||||
<div>
|
|
||||||
<a href="#">{% trans 'Mac OSX (>10.5) UDS plugin' %}</a>
|
|
||||||
</div>
|
|
||||||
{% endif %}
|
|
||||||
<div class="text-center">
|
|
||||||
<a href="{% url 'uds.web.views.index' %}" class="btn btn-info"><i class="fa fa-home"></i> {% trans "Return" %}</a>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
{% endblock %}
|
|
@ -1,29 +0,0 @@
|
|||||||
{% extends "uds/html5/templates/base.html" %}
|
|
||||||
{% load i18n static %}
|
|
||||||
|
|
||||||
{% block title %}{% trans "Login redirection to UDS" %}{% endblock %}
|
|
||||||
|
|
||||||
{% block js %}
|
|
||||||
<script src="{% get_static_prefix %}js/PluginDetect_Java.js" type="text/javascript" ></script>
|
|
||||||
<script type="text/javascript">
|
|
||||||
function isJavaAvailable() {
|
|
||||||
if( PluginDetect.isMinVersion('Java', '1,6,0,0','{% get_static_prefix %}/other/getJavaInfo.jar') == 1 )
|
|
||||||
return true;
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
$(document).ready(function() {
|
|
||||||
var java = isJavaAvailable() ? "y" : "n";
|
|
||||||
window.location.replace("{% url "uds.web.views.authJava" idAuth=idAuth hasJava='' %}" + java);
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
</script>
|
|
||||||
{% endblock %}
|
|
||||||
|
|
||||||
{% block body %}
|
|
||||||
<!--<div>
|
|
||||||
<a href="<a href="{% url "uds.web.views.index" %}">{% trans "Go to main page" %}
|
|
||||||
</div>-->
|
|
||||||
{% endblock %}
|
|
71
server/src/uds/templates/uds/html5/download_client.html
Normal file
71
server/src/uds/templates/uds/html5/download_client.html
Normal file
@ -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 %}
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-8 col-md-offset-2 bg-primary img-rounded">
|
||||||
|
<h3 class="text-center">{% trans 'Download UDS Plugin for' %} {{ os|osName }}</h3>
|
||||||
|
<p>{% trans 'In order to be able to execute UDS services, you need to have uds plugin installed.' %}</p>
|
||||||
|
<p class="text-center"><a href="{{ os|pluginDownloadUrl }}" class="btn btn-success">{% trans 'Download UDS Plugin for' %} {{ os|osName }}</a></p>
|
||||||
|
<h3>{% trans 'Or select another version' %}</h3>
|
||||||
|
<p>
|
||||||
|
{% if os != 'linux' %}
|
||||||
|
<p class="text-center">
|
||||||
|
<a href="#" class="btn btn-warning">{% trans 'Linux UDS plugin' %}</a>
|
||||||
|
</p>
|
||||||
|
{% endif %}
|
||||||
|
{% if os != 'windows' %}
|
||||||
|
<p class="text-center">
|
||||||
|
<a href="#" class="btn btn-warning">{% trans 'Windows UDS plugin' %}</a>
|
||||||
|
</p>
|
||||||
|
{% endif %}
|
||||||
|
{% if os != 'mac' %}
|
||||||
|
<p class="text-center">
|
||||||
|
<a href="#" class="btn btn-warning">{% trans 'Mac OSX (>10.5) UDS plugin' %}</a>
|
||||||
|
</p>
|
||||||
|
{% endif %}
|
||||||
|
</p>
|
||||||
|
|
||||||
|
{% if request.user %}
|
||||||
|
<p>{% trans 'If you already have UDS Plugin installed but this message persists to appear, you can disable it here' %}</p>
|
||||||
|
<p>
|
||||||
|
<form>
|
||||||
|
<select id="plugin" class="selectpicker show-menu-arrow" data-width="100%" data-size="2" style="display: none;">
|
||||||
|
<option value="0">{% trans 'Automatic plugin detection is enabled' %}</option>
|
||||||
|
<option value="1">{% trans 'Automatic plugin detection is disabled' %}</option>
|
||||||
|
</select>
|
||||||
|
</form>
|
||||||
|
</p>
|
||||||
|
<p class="text-center">
|
||||||
|
<a href="{% url 'uds.web.views.index' %}" class="btn btn-info"><i class="fa fa-home"></i> {% trans "Return" %}</a>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block js %}
|
||||||
|
{% if request.user %}
|
||||||
|
<script>
|
||||||
|
$(function(){
|
||||||
|
$("#plugin").on('change', function(){
|
||||||
|
$.ajax({
|
||||||
|
url: {% url 'PluginDetection' '' %} + $(this).val(),
|
||||||
|
type: "GET",
|
||||||
|
success: function(data) {
|
||||||
|
|
||||||
|
},
|
||||||
|
error: function(jqXHR, textStatus, errorThrown) {
|
||||||
|
alert(gettext('Error communicating with UDS: ') + textStatus);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}).val('{% preference _uds.bypassPluginDetection %}');
|
||||||
|
$('.selectpicker').selectpicker('render');
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
{% endif %}
|
||||||
|
{% endblock %}
|
@ -4,17 +4,7 @@
|
|||||||
{% block title %}{% trans 'Welcome to UDS' %}{% endblock %}
|
{% block title %}{% trans 'Welcome to UDS' %}{% endblock %}
|
||||||
|
|
||||||
{% block js %}
|
{% block js %}
|
||||||
<script src="{% get_static_prefix %}js/PluginDetect_Java.js" type="text/javascript" ></script>
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
function isJavaAvailable() {
|
|
||||||
if( PluginDetect.isMinVersion('Java', '1,6,0,0','{% get_static_prefix %}/other/getJavaInfo.jar') == 1 )
|
|
||||||
return true;
|
|
||||||
|
|
||||||
//PluginDetect.getVersion('Java', '{% get_static_prefix %}/other/getJavaInfo.jar')
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
function chkNonStandardAuth(val, nonStandard) {
|
function chkNonStandardAuth(val, nonStandard) {
|
||||||
if( $.inArray(val, nonStandard) >= 0) {
|
if( $.inArray(val, nonStandard) >= 0) {
|
||||||
var vv = val;
|
var vv = val;
|
||||||
@ -28,7 +18,6 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
$('#id_java').val(isJavaAvailable() ? "y" : "n");
|
|
||||||
var nonStandard = $('#id_nonStandard').val();
|
var nonStandard = $('#id_nonStandard').val();
|
||||||
|
|
||||||
if( nonStandard.length == 0 )
|
if( nonStandard.length == 0 )
|
||||||
|
@ -44,6 +44,7 @@
|
|||||||
{% if show_prefs and user.id != rootid %}
|
{% if show_prefs and user.id != rootid %}
|
||||||
<li><a href="{% url "uds.web.views.prefs" %}"><span class="fa fa-edit"></span> {% trans 'Preferences' %}</a></li>
|
<li><a href="{% url "uds.web.views.prefs" %}"><span class="fa fa-edit"></span> {% trans 'Preferences' %}</a></li>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
<li><a href="{% url 'ClientDownload' %}"><span class="fa fa-download"></span> UDS Plugin</a></li>
|
||||||
{% if user.staff_member or user.is_admin %}
|
{% if user.staff_member or user.is_admin %}
|
||||||
<li><a href="{% url "uds.web.views.download" idDownload='' %}"><span class="fa fa-download"></span> {% trans "Downloads" %}</a></li>
|
<li><a href="{% url "uds.web.views.download" idDownload='' %}"><span class="fa fa-download"></span> {% trans "Downloads" %}</a></li>
|
||||||
{% ifbrowser ie<8 %}
|
{% ifbrowser ie<8 %}
|
||||||
|
@ -93,14 +93,13 @@
|
|||||||
<script src="{% get_static_prefix %}js/bootstrap-select.min.js"></script>
|
<script src="{% get_static_prefix %}js/bootstrap-select.min.js"></script>
|
||||||
<script>
|
<script>
|
||||||
var clientRest = "/" + "{% url 'ClientAccessEnabler' 'x' 'x' %}".split("/")[1];
|
var clientRest = "/" + "{% url 'ClientAccessEnabler' 'x' 'x' %}".split("/")[1];
|
||||||
var bypassPluginDetection = {% preference _uds.bypassPluginDetection %} != 0;
|
var bypassPluginDetection = "{% preference _uds.bypassPluginDetection %}" == "1";
|
||||||
</script>
|
</script>
|
||||||
<script type="text/coffeescript" charset="utf-8" src="{% get_static_prefix %}js/uds-client.coffee"></script>
|
<script type="text/coffeescript" charset="utf-8" src="{% get_static_prefix %}js/uds-client.coffee"></script>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
$(function(){
|
$(function(){
|
||||||
$('.selectpicker').selectpicker();
|
$('.selectpicker').selectpicker();
|
||||||
window.uds.onLink();
|
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
{% endcompress %}
|
{% endcompress %}
|
||||||
|
@ -1,3 +0,0 @@
|
|||||||
{% load i18n static html5 %}
|
|
||||||
|
|
||||||
<a class="uds-service-link" data-href-alt="{% url 'uds.web.views.client_downloads' %}" href="x{{ uri }}" tabindex="{% tabindex uds-service-link %}">Link to {{ uri }}</a>
|
|
@ -122,6 +122,9 @@ class Preference(template.Node):
|
|||||||
self.prefName = prefName
|
self.prefName = prefName
|
||||||
|
|
||||||
def render(self, context):
|
def render(self, context):
|
||||||
|
if context.get('user') is None:
|
||||||
|
return ''
|
||||||
|
|
||||||
prefs = context['user'].prefs(self.modName)
|
prefs = context['user'].prefs(self.modName)
|
||||||
return prefs.get(self.prefName)
|
return prefs.get(self.prefName)
|
||||||
|
|
||||||
|
@ -43,7 +43,7 @@ urlpatterns = patterns(
|
|||||||
'uds',
|
'uds',
|
||||||
url(r'^$', 'web.views.index', name='Index'),
|
url(r'^$', 'web.views.index', name='Index'),
|
||||||
(r'^login/$', 'web.views.login'),
|
(r'^login/$', 'web.views.login'),
|
||||||
(r'^login/(?P<smallName>.+)$', 'web.views.login'),
|
(r'^login/(?P<tag>.+)$', 'web.views.login'),
|
||||||
(r'^logout$', 'web.views.logout'),
|
(r'^logout$', 'web.views.logout'),
|
||||||
(r'^service/(?P<idService>.+)/(?P<idTransport>.+)$', 'web.views.service'),
|
(r'^service/(?P<idService>.+)/(?P<idTransport>.+)$', 'web.views.service'),
|
||||||
# Icons
|
# Icons
|
||||||
@ -69,12 +69,12 @@ urlpatterns = patterns(
|
|||||||
# downloads for client
|
# downloads for client
|
||||||
url(r'^down$', 'web.views.client_downloads', name='ClientDownload'),
|
url(r'^down$', 'web.views.client_downloads', name='ClientDownload'),
|
||||||
(r'^down/(?P<os>[a-zA-Z0-9-]*)$', 'web.views.client_downloads'),
|
(r'^down/(?P<os>[a-zA-Z0-9-]*)$', 'web.views.client_downloads'),
|
||||||
|
url(r'^pluginDetection/(?P<detection>[a-zA-Z0-9-]*)$', 'web.views.plugin_detection', name='PluginDetection'),
|
||||||
# Client access enabler
|
# Client access enabler
|
||||||
url(r'^enable/(?P<idService>.+)/(?P<idTransport>.+)$', 'web.views.clientEnabler', name='ClientAccessEnabler'),
|
url(r'^enable/(?P<idService>.+)/(?P<idTransport>.+)$', 'web.views.clientEnabler', name='ClientAccessEnabler'),
|
||||||
|
|
||||||
# Custom authentication callback
|
# Custom authentication callback
|
||||||
(r'^auth/(?P<authName>.+)', 'web.views.authCallback'),
|
(r'^auth/(?P<authName>.+)', 'web.views.authCallback'),
|
||||||
(r'^authJava/(?P<idAuth>.+)/(?P<hasJava>.*)$', 'web.views.authJava'),
|
|
||||||
(r'^authinfo/(?P<authName>.+)', 'web.views.authInfo'),
|
(r'^authinfo/(?P<authName>.+)', 'web.views.authInfo'),
|
||||||
(r'^about', 'web.views.about'),
|
(r'^about', 'web.views.about'),
|
||||||
# Ticket authentication
|
# Ticket authentication
|
||||||
|
@ -42,6 +42,8 @@ import logging
|
|||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
# pylint: disable=no-value-for-parameter, unexpected-keyword-arg
|
||||||
|
|
||||||
|
|
||||||
class CustomSelect(forms.Select):
|
class CustomSelect(forms.Select):
|
||||||
def render(self, name, value, attrs=None):
|
def render(self, name, value, attrs=None):
|
||||||
@ -64,7 +66,7 @@ class BaseForm(forms.Form):
|
|||||||
def add_form_error(self, message):
|
def add_form_error(self, message):
|
||||||
if not self._errors:
|
if not self._errors:
|
||||||
self._errors = ErrorDict()
|
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] = self.error_class()
|
||||||
self._errors[NON_FIELD_ERRORS].append(message)
|
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())
|
user = forms.CharField(label=_('Username'), max_length=64, widget=forms.TextInput())
|
||||||
password = forms.CharField(label=_('Password'), widget=forms.PasswordInput(attrs={'title': _('Password')}), required=False)
|
password = forms.CharField(label=_('Password'), widget=forms.PasswordInput(attrs={'title': _('Password')}), required=False)
|
||||||
authenticator = forms.ChoiceField(label=_('Authenticator'), choices=(), widget=CustomSelect(), 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)
|
standard = forms.CharField(widget=forms.HiddenInput(), required=False)
|
||||||
nonStandard = forms.CharField(widget=forms.HiddenInput(), required=False)
|
nonStandard = forms.CharField(widget=forms.HiddenInput(), required=False)
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
# If an specified login is passed in, retrieve it & remove it from kwargs dict
|
# If an specified login is passed in, retrieve it & remove it from kwargs dict
|
||||||
smallName = kwargs.get('smallName', None)
|
tag = kwargs.get('tag', None)
|
||||||
if kwargs.has_key('smallName'):
|
if 'tag' in kwargs:
|
||||||
del kwargs['smallName']
|
del kwargs['tag']
|
||||||
|
|
||||||
logger.debug('smallName is "{0}"'.format(smallName))
|
logger.debug('tag is "{0}"'.format(tag))
|
||||||
|
|
||||||
super(LoginForm, self).__init__(*args, **kwargs)
|
super(LoginForm, self).__init__(*args, **kwargs)
|
||||||
choices = []
|
choices = []
|
||||||
@ -91,8 +92,8 @@ class LoginForm(BaseForm):
|
|||||||
standard = []
|
standard = []
|
||||||
|
|
||||||
auths = None
|
auths = None
|
||||||
if smallName is not None:
|
if tag is not None:
|
||||||
auths = Authenticator.objects.filter(small_name=smallName).order_by('priority', 'name')
|
auths = Authenticator.objects.filter(small_name=tag).order_by('priority', 'name')
|
||||||
if auths.count() == 0:
|
if auths.count() == 0:
|
||||||
auths = Authenticator.objects.all().order_by('priority', 'name')[0:1]
|
auths = Authenticator.objects.all().order_by('priority', 'name')[0:1]
|
||||||
logger.debug(auths)
|
logger.debug(auths)
|
||||||
@ -103,7 +104,7 @@ class LoginForm(BaseForm):
|
|||||||
for a in auths:
|
for a in auths:
|
||||||
if a.getType() is None:
|
if a.getType() is None:
|
||||||
continue
|
continue
|
||||||
if a.getType().isCustom() and smallName == 'disabled':
|
if a.getType().isCustom() and tag == 'disabled':
|
||||||
continue
|
continue
|
||||||
choices.append((a.id, a.name))
|
choices.append((a.id, a.name))
|
||||||
if a.getType().isCustom():
|
if a.getType().isCustom():
|
||||||
|
@ -30,7 +30,7 @@
|
|||||||
'''
|
'''
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
__updated__ = '2015-03-26'
|
__updated__ = '2015-03-27'
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
@ -40,8 +40,8 @@ from .login import login, logout, customAuth
|
|||||||
from .index import index, about
|
from .index import index, about
|
||||||
from .prefs import prefs
|
from .prefs import prefs
|
||||||
from .service import service, trans, transcomp, sernotify, transportIcon, serviceImage, clientEnabler
|
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 .download import download
|
||||||
from .client_download import client_downloads
|
from .client_download import client_downloads, plugin_detection
|
||||||
from .js import jsCatalog
|
from .js import jsCatalog
|
||||||
from ..errors import error
|
from ..errors import error
|
||||||
|
@ -30,23 +30,19 @@
|
|||||||
'''
|
'''
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
__updated__ = '2015-02-28'
|
__updated__ = '2015-03-27'
|
||||||
|
|
||||||
from django.http import HttpResponse, HttpResponseRedirect, HttpResponsePermanentRedirect
|
from django.http import HttpResponse, HttpResponseRedirect, HttpResponsePermanentRedirect
|
||||||
from django.views.decorators.csrf import csrf_exempt
|
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.utils.translation import ugettext as _
|
||||||
from django.core.urlresolvers import reverse
|
from django.core.urlresolvers import reverse
|
||||||
from django.views.decorators.cache import never_cache
|
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.models import Authenticator, DeployedService, Transport
|
||||||
from uds.core.util import OsDetector
|
from uds.core.util import OsDetector
|
||||||
from uds.core.util.Ticket import Ticket
|
from uds.core.util.Ticket import Ticket
|
||||||
from uds.core.util.State import State
|
from uds.core.util.State import State
|
||||||
from uds.core.ui import theme
|
|
||||||
from uds.core.auths.Exceptions import InvalidUserException
|
from uds.core.auths.Exceptions import InvalidUserException
|
||||||
from uds.core.services.Exceptions import InvalidServiceException, ServiceInMaintenanceMode
|
from uds.core.services.Exceptions import InvalidServiceException, ServiceInMaintenanceMode
|
||||||
|
|
||||||
@ -84,12 +80,10 @@ def authCallback(request, authName):
|
|||||||
os = OsDetector.getOsFromUA(request.META['HTTP_USER_AGENT'])
|
os = OsDetector.getOsFromUA(request.META['HTTP_USER_AGENT'])
|
||||||
|
|
||||||
if user is None:
|
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()
|
raise auths.Exceptions.InvalidUserException()
|
||||||
|
|
||||||
# Redirect to main page through java detection process, so UDS know the availability of java
|
response = HttpResponseRedirect(reverse('Index'))
|
||||||
response = render_to_response(theme.template('detectJava.html'), {'idAuth': authenticator.uuid},
|
|
||||||
context_instance=RequestContext(request))
|
|
||||||
|
|
||||||
webLogin(request, response, user, '') # Password is unavailable in this case
|
webLogin(request, response, user, '') # Password is unavailable in this case
|
||||||
request.session['OS'] = os
|
request.session['OS'] = os
|
||||||
@ -137,19 +131,6 @@ def authInfo(request, authName):
|
|||||||
return HttpResponse(_('Authenticator does not provide information'))
|
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
|
@never_cache
|
||||||
def ticketAuth(request, ticketId):
|
def ticketAuth(request, ticketId):
|
||||||
'''
|
'''
|
||||||
@ -201,8 +182,6 @@ def ticketAuth(request, ticketId):
|
|||||||
# Force cookie generation
|
# Force cookie generation
|
||||||
webLogin(request, None, usr, password)
|
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
|
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
|
# Check if servicePool is part of the ticket
|
||||||
|
@ -30,14 +30,15 @@
|
|||||||
'''
|
'''
|
||||||
from __future__ import unicode_literals
|
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.utils.translation import ugettext_noop
|
||||||
|
|
||||||
from django.shortcuts import render_to_response
|
from django.shortcuts import render_to_response
|
||||||
from django.template import RequestContext
|
from django.template import RequestContext
|
||||||
|
|
||||||
|
from uds.core.managers.UserPrefsManager import UserPrefsManager, CommonPrefs
|
||||||
from uds.core.auths.auth import webLoginRequired
|
from uds.core.auths.auth import webLoginRequired
|
||||||
from uds.core.ui import theme
|
from uds.core.ui import theme
|
||||||
from uds.core.util.OsDetector import desktopOss
|
from uds.core.util.OsDetector import desktopOss
|
||||||
@ -56,15 +57,22 @@ UserPrefsManager.manager().registerPrefs(
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@webLoginRequired(admin=False)
|
|
||||||
def client_downloads(request, os=None):
|
def client_downloads(request, os=None):
|
||||||
'''
|
'''
|
||||||
Downloadables management
|
Download page for UDS plugins
|
||||||
'''
|
'''
|
||||||
if os not in desktopOss:
|
if os not in desktopOss:
|
||||||
os = request.os['OS']
|
os = request.os['OS']
|
||||||
logger.debug('User: {}'.format(request.user))
|
logger.debug('User: {}'.format(request.user))
|
||||||
os = os.lower()
|
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},
|
{'os': os, 'user': request.user},
|
||||||
context_instance=RequestContext(request))
|
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')
|
||||||
|
@ -30,7 +30,7 @@
|
|||||||
'''
|
'''
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
__updated__ = '2015-02-28'
|
__updated__ = '2015-03-27'
|
||||||
|
|
||||||
from django.http import HttpResponse, HttpResponseRedirect
|
from django.http import HttpResponse, HttpResponseRedirect
|
||||||
from django.shortcuts import render_to_response
|
from django.shortcuts import render_to_response
|
||||||
@ -51,11 +51,11 @@ import logging
|
|||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
def login(request, smallName=None):
|
def login(request, tag=None):
|
||||||
'''
|
'''
|
||||||
View responsible of logging in an user
|
View responsible of logging in an user
|
||||||
:param request: http request
|
: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())
|
# request.session.set_expiry(GlobalConfig.USER_SESSION_LENGTH.getInt())
|
||||||
|
|
||||||
@ -64,17 +64,17 @@ def login(request, smallName=None):
|
|||||||
# Get Authenticators limitation
|
# Get Authenticators limitation
|
||||||
logger.debug('Host: {0}'.format(host))
|
logger.debug('Host: {0}'.format(host))
|
||||||
if GlobalConfig.DISALLOW_GLOBAL_LOGIN.getBool(True) is True:
|
if GlobalConfig.DISALLOW_GLOBAL_LOGIN.getBool(True) is True:
|
||||||
if smallName is None:
|
if tag is None:
|
||||||
try:
|
try:
|
||||||
Authenticator.objects.get(small_name=host)
|
Authenticator.objects.get(small_name=host)
|
||||||
smallName = host
|
tag = host
|
||||||
except Exception:
|
except Exception:
|
||||||
try:
|
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.. :-)
|
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)
|
logger.debug(request.method)
|
||||||
if request.method == 'POST':
|
if request.method == 'POST':
|
||||||
@ -82,9 +82,8 @@ def login(request, smallName=None):
|
|||||||
logger.debug('Request does not have uds cookie')
|
logger.debug('Request does not have uds cookie')
|
||||||
return errors.errorView(request, errors.COOKIES_NEEDED) # We need cookies to keep session data
|
return errors.errorView(request, errors.COOKIES_NEEDED) # We need cookies to keep session data
|
||||||
request.session.cycle_key()
|
request.session.cycle_key()
|
||||||
form = LoginForm(request.POST, smallName=smallName)
|
form = LoginForm(request.POST, tag=tag)
|
||||||
if form.is_valid():
|
if form.is_valid():
|
||||||
java = form.cleaned_data['java'] == 'y'
|
|
||||||
os = OsDetector.getOsFromUA(request.META.get('HTTP_USER_AGENT'))
|
os = OsDetector.getOsFromUA(request.META.get('HTTP_USER_AGENT'))
|
||||||
try:
|
try:
|
||||||
authenticator = Authenticator.objects.get(pk=form.cleaned_data['authenticator'])
|
authenticator = Authenticator.objects.get(pk=form.cleaned_data['authenticator'])
|
||||||
@ -99,7 +98,7 @@ def login(request, smallName=None):
|
|||||||
tries = 0
|
tries = 0
|
||||||
if authenticator.getInstance().blockUserOnLoginFailures is True and tries >= GlobalConfig.MAX_LOGIN_TRIES.getInt():
|
if authenticator.getInstance().blockUserOnLoginFailures is True and tries >= GlobalConfig.MAX_LOGIN_TRIES.getInt():
|
||||||
form.add_form_error('Too many authentication errors. User temporarily blocked.')
|
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:
|
else:
|
||||||
user = authenticate(userName, form.cleaned_data['password'], authenticator)
|
user = authenticate(userName, form.cleaned_data['password'], authenticator)
|
||||||
logger.debug('User: {}'.format(user))
|
logger.debug('User: {}'.format(user))
|
||||||
@ -109,20 +108,18 @@ def login(request, smallName=None):
|
|||||||
tries += 1
|
tries += 1
|
||||||
cache.put(cacheKey, tries, GlobalConfig.LOGIN_BLOCK.getInt())
|
cache.put(cacheKey, tries, GlobalConfig.LOGIN_BLOCK.getInt())
|
||||||
form.add_form_error('Invalid credentials')
|
form.add_form_error('Invalid credentials')
|
||||||
authLogLogin(request, authenticator, userName, java, os, 'Invalid credentials')
|
authLogLogin(request, authenticator, userName, 'Invalid credentials')
|
||||||
else:
|
else:
|
||||||
logger.debug('User {} has logged in'.format(userName))
|
logger.debug('User {} has logged in'.format(userName))
|
||||||
cache.remove(cacheKey) # Valid login, remove cached tries
|
cache.remove(cacheKey) # Valid login, remove cached tries
|
||||||
response = HttpResponseRedirect(reverse('uds.web.views.index'))
|
response = HttpResponseRedirect(reverse('uds.web.views.index'))
|
||||||
webLogin(request, response, user, form.cleaned_data['password'])
|
webLogin(request, response, user, form.cleaned_data['password'])
|
||||||
# Add the "java supported" flag to session
|
# Add the "java supported" flag to session
|
||||||
request.session['java'] = java
|
|
||||||
request.session['OS'] = os
|
request.session['OS'] = os
|
||||||
logger.debug('Navigator supports java? {0}'.format(java))
|
authLogLogin(request, authenticator, user.name)
|
||||||
authLogLogin(request, authenticator, user.name, java, os)
|
|
||||||
return response
|
return response
|
||||||
else:
|
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)},
|
response = render_to_response(theme.template('login.html'), {'form': form, 'customHtml': GlobalConfig.CUSTOM_HTML_LOGIN.get(True)},
|
||||||
context_instance=RequestContext(request))
|
context_instance=RequestContext(request))
|
||||||
|
@ -30,7 +30,7 @@
|
|||||||
'''
|
'''
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
__updated__ = '2015-03-26'
|
__updated__ = '2015-03-27'
|
||||||
|
|
||||||
from django.utils.translation import ugettext as _
|
from django.utils.translation import ugettext as _
|
||||||
from django.http import HttpResponse, HttpResponseRedirect
|
from django.http import HttpResponse, HttpResponseRedirect
|
||||||
@ -62,7 +62,7 @@ logger = logging.getLogger(__name__)
|
|||||||
__updated__ = '2015-02-22'
|
__updated__ = '2015-02-22'
|
||||||
|
|
||||||
|
|
||||||
def getService(request, idService, idTransport):
|
def getService(request, idService, idTransport, doTest=True):
|
||||||
kind, idService = idService[0], idService[1:]
|
kind, idService = idService[0], idService[1:]
|
||||||
|
|
||||||
logger.debug('Kind of service: {0}, idService: {1}'.format(kind, idService))
|
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))
|
logger.debug('Found service: {0}'.format(ads))
|
||||||
trans = Transport.objects.get(uuid=idTransport)
|
trans = Transport.objects.get(uuid=idTransport)
|
||||||
|
|
||||||
|
if doTest is False:
|
||||||
|
return (None, ads, None, trans, None)
|
||||||
|
|
||||||
# Test if the service is ready
|
# Test if the service is ready
|
||||||
if ads.isReady():
|
if ads.isReady():
|
||||||
log.doLog(ads, log.INFO, "User {0} from {1} has initiated access".format(request.user.name, request.ip), log.WEB)
|
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 = ''
|
url = ''
|
||||||
error = _('Service not ready. Please, try again in a while.')
|
error = _('Service not ready. Please, try again in a while.')
|
||||||
try:
|
try:
|
||||||
res = getService(request, idService, idTransport)
|
res = getService(request, idService, idTransport, doTest=False)
|
||||||
if res is not None:
|
if res is not None:
|
||||||
|
|
||||||
scrambler = cryptoManager().randomString(32)
|
scrambler = cryptoManager().randomString(32)
|
||||||
password = cryptoManager().xor(webPassword(request), scrambler)
|
password = cryptoManager().xor(webPassword(request), scrambler)
|
||||||
|
|
||||||
ip, ads, iads, trans, itrans = res
|
_x, ads, _x, trans, _x = res
|
||||||
|
|
||||||
data = {
|
data = {
|
||||||
'service': ads.uuid,
|
'service': ads.uuid,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user