forked from shaba/openuds
Bug fix in LDAP & Regldap related to unicode literals
Fixes in new admin interface
This commit is contained in:
parent
b64928f1e6
commit
4565f00174
@ -43,7 +43,7 @@ import ldap
|
|||||||
import re
|
import re
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
__updated__ = '2014-02-19'
|
__updated__ = '2014-03-19'
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
@ -188,7 +188,7 @@ class RegexLdap(auths.Authenticator):
|
|||||||
self._userNameAttr)
|
self._userNameAttr)
|
||||||
|
|
||||||
def marshal(self):
|
def marshal(self):
|
||||||
return str.join('\t', [
|
return '\t'.join([
|
||||||
'v2',
|
'v2',
|
||||||
self._host, self._port, gui.boolToStr(self._ssl), self._username, self._password, self._timeout,
|
self._host, self._port, gui.boolToStr(self._ssl), self._username, self._password, self._timeout,
|
||||||
self._ldapBase, self._userClass, self._userIdAttr, self._groupNameAttr, self._userNameAttr
|
self._ldapBase, self._userClass, self._userIdAttr, self._groupNameAttr, self._userNameAttr
|
||||||
|
@ -42,7 +42,7 @@ from uds.core.auths.Exceptions import AuthenticatorException
|
|||||||
import ldap
|
import ldap
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
__updated__ = '2014-02-19'
|
__updated__ = '2014-03-19'
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
@ -128,7 +128,7 @@ class SimpleLDAPAuthenticator(Authenticator):
|
|||||||
self._userNameAttr)
|
self._userNameAttr)
|
||||||
|
|
||||||
def marshal(self):
|
def marshal(self):
|
||||||
return str.join('\t', ['v1',
|
return '\t'.join(['v1',
|
||||||
self._host, self._port, gui.boolToStr(self._ssl), self._username, self._password, self._timeout,
|
self._host, self._port, gui.boolToStr(self._ssl), self._username, self._password, self._timeout,
|
||||||
self._ldapBase, self._userClass, self._groupClass, self._userIdAttr, self._groupIdAttr, self._memberAttr, self._userNameAttr])
|
self._ldapBase, self._userClass, self._groupClass, self._userIdAttr, self._groupIdAttr, self._memberAttr, self._userNameAttr])
|
||||||
|
|
||||||
|
@ -97,7 +97,9 @@ class gui(object):
|
|||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def convertToList(vals):
|
def convertToList(vals):
|
||||||
return [unicode(v) for v in vals]
|
if vals is not None:
|
||||||
|
return [unicode(v) for v in vals]
|
||||||
|
return []
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def choiceItem(id_, text):
|
def choiceItem(id_, text):
|
||||||
|
@ -4,27 +4,27 @@
|
|||||||
# Copyright (c) 2012 Virtual Cable S.L.
|
# Copyright (c) 2012 Virtual Cable S.L.
|
||||||
# All rights reserved.
|
# All rights reserved.
|
||||||
#
|
#
|
||||||
# Redistribution and use in source and binary forms, with or without modification,
|
# Redistribution and use in source and binary forms, with or without modification,
|
||||||
# are permitted provided that the following conditions are met:
|
# are permitted provided that the following conditions are met:
|
||||||
#
|
#
|
||||||
# * Redistributions of source code must retain the above copyright notice,
|
# * Redistributions of source code must retain the above copyright notice,
|
||||||
# this list of conditions and the following disclaimer.
|
# this list of conditions and the following disclaimer.
|
||||||
# * Redistributions in binary form must reproduce the above copyright notice,
|
# * Redistributions in binary form must reproduce the above copyright notice,
|
||||||
# this list of conditions and the following disclaimer in the documentation
|
# this list of conditions and the following disclaimer in the documentation
|
||||||
# and/or other materials provided with the distribution.
|
# and/or other materials provided with the distribution.
|
||||||
# * Neither the name of Virtual Cable S.L. nor the names of its contributors
|
# * Neither the name of Virtual Cable S.L. nor the names of its contributors
|
||||||
# may be used to endorse or promote products derived from this software
|
# may be used to endorse or promote products derived from this software
|
||||||
# without specific prior written permission.
|
# without specific prior written permission.
|
||||||
#
|
#
|
||||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||||
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||||
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||||
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||||
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
'''
|
'''
|
||||||
@ -36,51 +36,51 @@ from uds.core import services
|
|||||||
from uds.core.util.AutoAttributes import AutoAttributes
|
from uds.core.util.AutoAttributes import AutoAttributes
|
||||||
from uds.core.ui.UserInterface import gui
|
from uds.core.ui.UserInterface import gui
|
||||||
from IPMachineDeployed import IPMachineDeployed
|
from IPMachineDeployed import IPMachineDeployed
|
||||||
import logging, cPickle
|
import logging
|
||||||
|
import cPickle
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class IPMachinesService(services.Service):
|
class IPMachinesService(services.Service):
|
||||||
|
|
||||||
# Gui
|
# Gui
|
||||||
ipList = gui.EditableList(label=_('List of IPS'))
|
ipList = gui.EditableList(label=_('List of IPS'))
|
||||||
|
|
||||||
# Description of service
|
# Description of service
|
||||||
typeName = _('Physical machines accesed by ip')
|
typeName = _('Physical machines accesed by ip')
|
||||||
typeType = 'IPMachinesService'
|
typeType = 'IPMachinesService'
|
||||||
typeDescription = _('This service provides access to POWERED-ON Machines by ip')
|
typeDescription = _('This service provides access to POWERED-ON Machines by ip')
|
||||||
iconFile = 'machine.png'
|
iconFile = 'machine.png'
|
||||||
|
|
||||||
# Characteristics of service
|
# Characteristics of service
|
||||||
maxDeployed = -1 # If the service provides more than 1 "provided service" (-1 = no limit, 0 = ???? (do not use it!!!), N = max number to deploy
|
maxDeployed = -1 # If the service provides more than 1 "provided service" (-1 = no limit, 0 = ???? (do not use it!!!), N = max number to deploy
|
||||||
usesCache = False # Cache are running machine awaiting to be assigned
|
usesCache = False # Cache are running machine awaiting to be assigned
|
||||||
usesCache_L2 = False # L2 Cache are running machines in suspended state
|
usesCache_L2 = False # L2 Cache are running machines in suspended state
|
||||||
needsManager = False # If the service needs a s.o. manager (managers are related to agents provided by services itselfs, i.e. virtual machines with agent)
|
needsManager = False # If the service needs a s.o. manager (managers are related to agents provided by services itselfs, i.e. virtual machines with agent)
|
||||||
mustAssignManually = False # If true, the system can't do an automatic assignation of a deployed user service from this service
|
mustAssignManually = False # If true, the system can't do an automatic assignation of a deployed user service from this service
|
||||||
|
|
||||||
deployedType = IPMachineDeployed
|
deployedType = IPMachineDeployed
|
||||||
|
|
||||||
def __init__(self, environment, parent, values = None):
|
def __init__(self, environment, parent, values=None):
|
||||||
super(IPMachinesService, self).__init__(environment, parent, values)
|
super(IPMachinesService, self).__init__(environment, parent, values)
|
||||||
if values is None:
|
if values is None or values.get('ipList', None) is None:
|
||||||
self._ips = []
|
self._ips = []
|
||||||
else:
|
else:
|
||||||
self._ips = list(set(values['ipList'])) # Avoid duplicates :-)
|
self._ips = list(set(values['ipList'])) # Avoid duplicates :-)
|
||||||
self._ips.sort()
|
self._ips.sort()
|
||||||
|
|
||||||
|
|
||||||
def valuesDict(self):
|
def valuesDict(self):
|
||||||
return { 'ipList' : gui.convertToList(self._ips) }
|
return {'ipList': gui.convertToList(self._ips)}
|
||||||
|
|
||||||
def marshal(self):
|
def marshal(self):
|
||||||
self.storage().saveData('ips', cPickle.dumps(self._ips))
|
self.storage().saveData('ips', cPickle.dumps(self._ips))
|
||||||
return 'v1'
|
return 'v1'
|
||||||
|
|
||||||
def unmarshal(self, vals):
|
def unmarshal(self, vals):
|
||||||
if vals == 'v1':
|
if vals == 'v1':
|
||||||
self._ips = cPickle.loads( self.storage().readData('ips') )
|
self._ips = cPickle.loads(self.storage().readData('ips'))
|
||||||
|
|
||||||
|
|
||||||
def getUnassignedMachine(self):
|
def getUnassignedMachine(self):
|
||||||
# Search first unassigned machine
|
# Search first unassigned machine
|
||||||
try:
|
try:
|
||||||
@ -95,7 +95,7 @@ class IPMachinesService(services.Service):
|
|||||||
return None
|
return None
|
||||||
finally:
|
finally:
|
||||||
self.storage().unlock()
|
self.storage().unlock()
|
||||||
|
|
||||||
def unassignMachine(self, ip):
|
def unassignMachine(self, ip):
|
||||||
try:
|
try:
|
||||||
self.storage().lock()
|
self.storage().lock()
|
||||||
|
@ -87,7 +87,7 @@
|
|||||||
<script src="{% get_static_prefix %}js/jquery.cookie.js"></script>
|
<script src="{% get_static_prefix %}js/jquery.cookie.js"></script>
|
||||||
<script src="{% get_static_prefix %}js/bootstrap.min.js"></script>
|
<script src="{% get_static_prefix %}js/bootstrap.min.js"></script>
|
||||||
<script src="{% get_static_prefix %}js/bootstrap-switch.min.js"></script>
|
<script src="{% get_static_prefix %}js/bootstrap-switch.min.js"></script>
|
||||||
<script src="{% get_static_prefix %}js/bootstrap-select.min.js"></script>
|
<script src="{% get_static_prefix %}js/bootstrap-select.min.js"></script>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
$(function(){
|
$(function(){
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
from django.utils.safestring import mark_safe
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Copyright (c) 2012 Virtual Cable S.L.
|
# Copyright (c) 2012 Virtual Cable S.L.
|
||||||
@ -31,9 +30,11 @@ from django.utils.safestring import mark_safe
|
|||||||
'''
|
'''
|
||||||
@author: Adolfo Gómez, dkmaster at dkmon dot com
|
@author: Adolfo Gómez, dkmaster at dkmon dot com
|
||||||
'''
|
'''
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
from django.utils.translation import ugettext_lazy as _, ugettext
|
from django.utils.translation import ugettext_lazy as _, ugettext
|
||||||
from django import forms
|
from django import forms
|
||||||
|
from django.utils.safestring import mark_safe
|
||||||
from django.forms.forms import NON_FIELD_ERRORS
|
from django.forms.forms import NON_FIELD_ERRORS
|
||||||
from django.forms.util import ErrorDict
|
from django.forms.util import ErrorDict
|
||||||
from uds.models import Authenticator
|
from uds.models import Authenticator
|
||||||
@ -41,18 +42,20 @@ import logging
|
|||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class CustomSelect(forms.Select):
|
class CustomSelect(forms.Select):
|
||||||
def render(self, name, value, attrs=None):
|
def render(self, name, value, attrs=None):
|
||||||
if len(self.choices) < 2:
|
if len(self.choices) < 2:
|
||||||
visible = ' style="display: none;"'
|
visible = ' style="display: none;"'
|
||||||
else:
|
else:
|
||||||
visible = '';
|
visible = ''
|
||||||
res = '<select id="id_{0}" name="{0}" class="selectpicker show-menu-arrow" data-header="{1}" data-size="8" data-width="100%" >'.format(name, ugettext('Select authenticator'))
|
res = '<select id="id_{0}" name="{0}" class="selectpicker show-menu-arrow" data-header="{1}" data-size="8" data-width="100%" >'.format(name, ugettext('Select authenticator'))
|
||||||
for choice in self.choices:
|
for choice in self.choices:
|
||||||
res += '<option value="{0}">{1}</option>'.format(choice[0], choice[1])
|
res += '<option value="{0}">{1}</option>'.format(choice[0], choice[1])
|
||||||
res += '</select>'
|
res += '</select>'
|
||||||
return mark_safe('<div class="form-group"{0}><label>'.format(visible) + unicode(_('authenticator')) + '</label>' + res + '</div>')
|
return mark_safe('<div class="form-group"{0}><label>'.format(visible) + unicode(_('authenticator')) + '</label>' + res + '</div>')
|
||||||
|
|
||||||
|
|
||||||
class BaseForm(forms.Form):
|
class BaseForm(forms.Form):
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
@ -65,6 +68,7 @@ class BaseForm(forms.Form):
|
|||||||
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)
|
||||||
|
|
||||||
|
|
||||||
class LoginForm(BaseForm):
|
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)
|
||||||
@ -99,6 +103,8 @@ 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':
|
||||||
|
continue
|
||||||
choices.append((a.id, a.name))
|
choices.append((a.id, a.name))
|
||||||
if a.getType().isCustom():
|
if a.getType().isCustom():
|
||||||
nonStandard.append(str(a.id))
|
nonStandard.append(str(a.id))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user