forked from shaba/openuds
* Added min height to panel tables
* Added uds to cookies if not found on login * Fixed html5 so if request is not in context, simply set user_agent to "Unknown" * Updated auth/views to use new cookie "syntax"
This commit is contained in:
parent
14a2e0a02d
commit
2108353d1e
@ -253,6 +253,9 @@ encoding//src/uds/services/Xen/xen_client/__init__.py=utf-8
|
|||||||
encoding//src/uds/services/__init__.py=utf-8
|
encoding//src/uds/services/__init__.py=utf-8
|
||||||
encoding//src/uds/templatetags/REST.py=utf-8
|
encoding//src/uds/templatetags/REST.py=utf-8
|
||||||
encoding//src/uds/templatetags/html5.py=utf-8
|
encoding//src/uds/templatetags/html5.py=utf-8
|
||||||
|
encoding//src/uds/tests/__init__.py=utf-8
|
||||||
|
encoding//src/uds/tests/web/__init__.py=utf-8
|
||||||
|
encoding//src/uds/tests/web/auth/__init__.py=utf-8
|
||||||
encoding//src/uds/transports/HTML5RDP/HTML5RDP.py=utf-8
|
encoding//src/uds/transports/HTML5RDP/HTML5RDP.py=utf-8
|
||||||
encoding//src/uds/transports/HTML5RDP/__init__.py=utf-8
|
encoding//src/uds/transports/HTML5RDP/__init__.py=utf-8
|
||||||
encoding//src/uds/transports/NX/NXTransport.py=utf-8
|
encoding//src/uds/transports/NX/NXTransport.py=utf-8
|
||||||
|
@ -49,7 +49,7 @@ from uds.models import User
|
|||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
__updated__ = '2014-02-19'
|
__updated__ = '2014-05-29'
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
authLogger = logging.getLogger('authLog')
|
authLogger = logging.getLogger('authLog')
|
||||||
@ -58,6 +58,16 @@ USER_KEY = 'uk'
|
|||||||
PASS_KEY = 'pk'
|
PASS_KEY = 'pk'
|
||||||
ROOT_ID = -20091204 # Any negative number will do the trick
|
ROOT_ID = -20091204 # Any negative number will do the trick
|
||||||
|
|
||||||
|
def getUDSCookie(request, response):
|
||||||
|
if 'uds' not in request.COOKIES:
|
||||||
|
import random
|
||||||
|
import string
|
||||||
|
cookie = ''.join(random.choice(string.letters + string.digits) for _ in xrange(32))
|
||||||
|
response.set_cookie('uds', cookie)
|
||||||
|
else:
|
||||||
|
cookie = request.COOKIES['uds']
|
||||||
|
|
||||||
|
return cookie
|
||||||
|
|
||||||
def getRootUser():
|
def getRootUser():
|
||||||
from uds.models import Authenticator
|
from uds.models import Authenticator
|
||||||
@ -256,10 +266,14 @@ def webLogin(request, response, user, password):
|
|||||||
manager_id = user.manager.id
|
manager_id = user.manager.id
|
||||||
else:
|
else:
|
||||||
manager_id = -1
|
manager_id = -1
|
||||||
|
|
||||||
|
# If for any reason the "uds" cookie is removed, recreated it
|
||||||
|
cookie = getUDSCookie(request, response)
|
||||||
|
|
||||||
user.updateLastAccess()
|
user.updateLastAccess()
|
||||||
request.session.clear()
|
request.session.clear()
|
||||||
request.session[USER_KEY] = user.id
|
request.session[USER_KEY] = user.id
|
||||||
request.session[PASS_KEY] = CryptoManager.manager().xor(password.encode('utf-8'), request.COOKIES['uds'])
|
request.session[PASS_KEY] = CryptoManager.manager().xor(password.encode('utf-8'), cookie)
|
||||||
# Ensures that this user will have access througt REST api if logged in through web interface
|
# Ensures that this user will have access througt REST api if logged in through web interface
|
||||||
REST.Handler.storeSessionAuthdata(request.session, manager_id, user.name, get_language(), user.is_admin, user.staff_member)
|
REST.Handler.storeSessionAuthdata(request.session, manager_id, user.name, get_language(), user.is_admin, user.staff_member)
|
||||||
return True
|
return True
|
||||||
|
@ -83,6 +83,7 @@ body {
|
|||||||
/* Tables "styling" */
|
/* Tables "styling" */
|
||||||
.dataTables_wrapper {
|
.dataTables_wrapper {
|
||||||
overflow-x: hidden;
|
overflow-x: hidden;
|
||||||
|
min-height: 300px;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* States */
|
/* States */
|
||||||
|
@ -61,7 +61,10 @@ class IfBrowser(template.Node):
|
|||||||
self._browsers = browsers
|
self._browsers = browsers
|
||||||
|
|
||||||
def render(self, context):
|
def render(self, context):
|
||||||
user_agent = context['request'].META.get('HTTP_USER_AGENT', 'Unknown')
|
if 'request' in context:
|
||||||
|
user_agent = context['request'].META.get('HTTP_USER_AGENT', 'Unknown')
|
||||||
|
else:
|
||||||
|
user_agent = 'Unknown'
|
||||||
for b in self._browsers:
|
for b in self._browsers:
|
||||||
if html.checkBrowser(user_agent, b):
|
if html.checkBrowser(user_agent, b):
|
||||||
return self._nodelistTrue.render(context)
|
return self._nodelistTrue.render(context)
|
||||||
|
@ -42,7 +42,7 @@ from django.utils import timezone
|
|||||||
from django.views.decorators.http import last_modified
|
from django.views.decorators.http import last_modified
|
||||||
from django.views.i18n import javascript_catalog
|
from django.views.i18n import javascript_catalog
|
||||||
|
|
||||||
from uds.core.auths.auth import getIp, webLogin, webLogout, webLoginRequired, authenticate, webPassword, authenticateViaCallback, authLogLogin, authLogLogout
|
from uds.core.auths.auth import getIp, webLogin, webLogout, webLoginRequired, authenticate, webPassword, authenticateViaCallback, authLogLogin, authLogLogout, getUDSCookie
|
||||||
from uds.models import Authenticator, DeployedService, Transport, UserService, Network
|
from uds.models import Authenticator, DeployedService, Transport, UserService, Network
|
||||||
from uds.web.forms.LoginForm import LoginForm
|
from uds.web.forms.LoginForm import LoginForm
|
||||||
from uds.core.managers.UserServiceManager import UserServiceManager
|
from uds.core.managers.UserServiceManager import UserServiceManager
|
||||||
@ -132,8 +132,9 @@ def login(request, smallName=None):
|
|||||||
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))
|
||||||
|
|
||||||
if 'uds' not in request.COOKIES:
|
|
||||||
response.set_cookie('uds', ''.join(random.choice(string.letters + string.digits) for _ in xrange(32)))
|
getUDSCookie(request, response)
|
||||||
|
|
||||||
return response
|
return response
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user