Пример #1
0
 def identify(self):
     environ = t.request.environ
     remote_user = environ.get('REMOTE_USER', None)
     if remote_user and not is_ticket_valid(remote_user):
         log.debug('User logged out of CAS Server')
         if (self.CAS_ROOT_PATH is not None):
             url = h.url_for(controller='user', action='logged_out_page')
             logout_path = getattr(
                 t.request.environ['repoze.who.plugins']['friendlyform'],
                 'logout_handler_path')
             h.redirect_to(
                 '{root_path}{logout_path}?came_from={url}'.format(
                     root_path=self.CAS_ROOT_PATH,
                     logout_path=logout_path,
                     url=url))
         url = h.url_for(controller='user', action='logged_out_page')
         h.redirect_to(
             getattr(
                 t.request.environ['repoze.who.plugins']['friendlyform'],
                 'logout_handler_path') + '?came_from=' + url)
     elif not remote_user and not isinstance(environ['pylons.controller'], CASController) \
             and not re.match(r'.*/api(/\d+)?/action/.*', environ['PATH_INFO']) \
             and not re.match(r'.*/dataset/.+/resource/.+/download/.+', environ['PATH_INFO']):
         login_checkup_cookie = t.request.cookies.get(
             self.LOGIN_CHECKUP_COOKIE, None)
         if login_checkup_cookie:
             return
 def identify(self):
     environ = t.request.environ
     remote_user = environ.get('REMOTE_USER', None)
     if remote_user and not is_ticket_valid(remote_user):
         log.debug('User logged out of CAS Server')
         url = h.url_for(controller='user', action='logged_out_page',
                         __ckan_no_root=True)
         h.redirect_to(getattr(t.request.environ['repoze.who.plugins']['friendlyform'],
                               'logout_handler_path') + '?came_from=' + url)
     elif not remote_user and not isinstance(environ['pylons.controller'], CASController) \
             and not re.match(r'.*/api(/\d+)?/action/.*', environ['PATH_INFO']) \
             and not re.match(r'.*/dataset/.+/resource/.+/download/.+', environ['PATH_INFO']):
         login_checkup_cookie = t.request.cookies.get(self.LOGIN_CHECKUP_COOKIE, None)
         if login_checkup_cookie:
             return
         log.debug('Checking if CAS session exists for user')
         url = self._generate_login_url(gateway=True, next=True)
         redirect(url)