removed unusefull "loginurl" config parameter

This commit is contained in:
Adolfo Gómez García 2020-06-16 14:47:27 +02:00
parent e3cb1ffaf1
commit 062b02a409
4 changed files with 15 additions and 12 deletions

View File

@ -41,7 +41,7 @@ logger = logging.getLogger(__name__)
# Pair of section/value removed from current UDS version
REMOVED = {
'UDS': ('allowPreferencesAccess', 'customHtmlLogin', 'UDS Theme', 'UDS Theme Enhaced', 'css', 'allowPreferencesAccess'),
'UDS': ('allowPreferencesAccess', 'customHtmlLogin', 'UDS Theme', 'UDS Theme Enhaced', 'css', 'allowPreferencesAccess', 'loginUrl'),
'Cluster': ('Destination CPU Load', 'Migration CPU Load', 'Migration Free Memory'),
'IPAUTH': ('autoLogin',),
'VMWare': ('minUsableDatastoreGB', 'maxRetriesOnError'),

View File

@ -112,11 +112,11 @@ def webLoginRequired(admin: typing.Union[bool, str] = False) -> typing.Callable[
Wrapped function for decorator
"""
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://')
logger.debug('No user found, redirecting to %s', url)
return HttpResponseRedirect(url)
# url = request.build_absolute_uri(GlobalConfig.LOGIN_URL.get())
# if GlobalConfig.REDIRECT_TO_HTTPS.getBool() is True:
# url = url.replace('http://', 'https://')
# logger.debug('No user found, redirecting to %s', url)
return HttpResponseRedirect(reverse('page.login'))
if admin is True or admin == 'admin':
if request.user.isStaff() is False or (admin == 'admin' and request.user.is_admin is False):
@ -330,9 +330,10 @@ def webLogout(request: HttpRequest, exit_url: typing.Optional[str] = None) -> Ht
request.session.clear()
if exit_url is None:
exit_url = GlobalConfig.LOGIN_URL.get()
if GlobalConfig.REDIRECT_TO_HTTPS.getBool() is True:
exit_url = exit_url.replace('http://', 'https://')
exit_url = reverse('page.logout')
# exit_url = GlobalConfig.LOGIN_URL.get()
# if GlobalConfig.REDIRECT_TO_HTTPS.getBool() is True:
# exit_url = exit_url.replace('http://', 'https://')
# Try to delete session
response = HttpResponseRedirect(request.build_absolute_uri(exit_url))

View File

@ -251,8 +251,8 @@ class GlobalConfig:
USER_SERVICE_CLEAN_NUMBER: Config.Value = Config.section(GLOBAL_SECTION).value('userServiceCleanNumber', '3', type=Config.NUMERIC_FIELD) # Defaults to 3 per wun
# Removal Check time for cache, publications and deployed services
REMOVAL_CHECK: Config.Value = Config.section(GLOBAL_SECTION).value('removalCheck', '31', type=Config.NUMERIC_FIELD) # Defaults to 30 seconds
# Login URL
LOGIN_URL: Config.Value = Config.section(GLOBAL_SECTION).value('loginUrl', '/login', type=Config.TEXT_FIELD) # Defaults to /login
# Login URL: deprecated & not used anymore
# LOGIN_URL: Config.Value = Config.section(GLOBAL_SECTION).value('loginUrl', '/uds/page/login', type=Config.TEXT_FIELD) # Defaults to /login
# Session duration
USER_SESSION_LENGTH: Config.Value = Config.section(SECURITY_SECTION).value('userSessionLength', '14400', type=Config.NUMERIC_FIELD) # Defaults to 4 hours
# Superuser (do not need to be at database!!!)

View File

@ -27,6 +27,7 @@
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
import logging
from django.urls import reverse
from django.http import HttpResponseRedirect
from uds.core.util.config import GlobalConfig
@ -69,7 +70,8 @@ class RedirectMiddleware:
if redirect and request.is_secure() is False and GlobalConfig.REDIRECT_TO_HTTPS.getBool():
if request.method == 'POST':
url = request.build_absolute_uri(GlobalConfig.LOGIN_URL.get())
# url = request.build_absolute_uri(GlobalConfig.LOGIN_URL.get())
url = reverse('page.login')
else:
url = request.build_absolute_uri(full_path)
url = url.replace('http://', 'https://')