Skip to content

Commit

Permalink
[FIX] Solucionar error TOO_MANY_REDIRECTS SSO
Browse files Browse the repository at this point in the history
  • Loading branch information
pmarinas committed Mar 7, 2025
1 parent 5e33b6d commit 9309ba4
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions src/genweb6/core/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,19 +198,19 @@ def remove_quotes_from_var_scss(text):
# return genweb_config()


#@ram.cache(lambda *args: time() // (24 * 60 * 60))
# @ram.cache(lambda *args: time() // (24 * 60 * 60))
def genwebCintilloConfig():
registry = queryUtility(IRegistry)
return registry.forInterface(ICintilloSettings)


#@ram.cache(lambda *args: time() // (24 * 60 * 60))
# @ram.cache(lambda *args: time() // (24 * 60 * 60))
def genwebHeaderConfig():
registry = queryUtility(IRegistry)
return registry.forInterface(IHeaderSettings)


#@ram.cache(lambda *args: time() // (24 * 60 * 60))
# @ram.cache(lambda *args: time() // (24 * 60 * 60))
def genwebFooterConfig():
registry = queryUtility(IRegistry)
return registry.forInterface(IFooterSettings)
Expand All @@ -222,7 +222,7 @@ def genwebLoginConfig():
return registry.forInterface(ILoginSettings)


#@ram.cache(lambda *args: time() // (24 * 60 * 60))
# @ram.cache(lambda *args: time() // (24 * 60 * 60))
def genwebResourcesConfig():
registry = queryUtility(IRegistry)
return registry.forInterface(IResourcesSettings)
Expand All @@ -235,6 +235,14 @@ def cas_settings(self):

def cas_login_URL(self):
login_url = login_URL(self.context, self.request)

# Si tiene el ticket en la url, quiere decir que es un usuario válido pero no tiene permisos.
# Por tanto, redirigimos a la página de error para evitar el bucle infinito del SSO
# En el log vemos Unauthorized(m) - zExceptions.unauthorized.Unauthorized: You are not authorized to access this resource.
if 'ticket' in getattr(self.request, 'came_from', ''):
return self.request.response.redirect(
self.context.absolute_url + '/insufficient-privileges')

url = self.context.absolute_url()
if any(x in url for x in ['localhost', 'fepre.upc.edu', '.pre.upc.edu']):
return login_url
Expand Down Expand Up @@ -386,7 +394,8 @@ def isEditor(self):
return False

current = api.user.get_current().id
return api.user.has_permission('Modify portal content', username=current, obj=self.context)
return api.user.has_permission(
'Modify portal content', username=current, obj=self.context)

def link_redirect_blank(self, item, isObject=False):
ptool = api.portal.get_tool(name='portal_properties')
Expand Down Expand Up @@ -418,7 +427,8 @@ def _url_uses_scheme(self, schemes, url=None):
'caldav:'
])

return redirect_links and not can_edit and getattr(item, 'open_link_in_new_window', False)
return redirect_links and not can_edit and getattr(
item, 'open_link_in_new_window', False)

def localized_time(self, date):
local_date = DateTime(date)
Expand Down

0 comments on commit 9309ba4

Please sign in to comment.