From aedc44b0d594f759a92f05654f9934657df22263 Mon Sep 17 00:00:00 2001 From: Nate Coraor Date: Fri, 19 Dec 2008 15:17:38 -0500 Subject: [PATCH] When require_login is set and an anonymous user accesses display_as, allow it through if it's the Genome Browser. Dataset actions still apply --- lib/galaxy/web/framework/__init__.py | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/lib/galaxy/web/framework/__init__.py b/lib/galaxy/web/framework/__init__.py index c75989305df..05fc0231cf5 100644 --- a/lib/galaxy/web/framework/__init__.py +++ b/lib/galaxy/web/framework/__init__.py @@ -4,7 +4,7 @@ Galaxy web application framework import pkg_resources -import os, sys, time +import os, sys, time, socket pkg_resources.require( "Cheetah" ) from Cheetah.Template import Template import base @@ -32,6 +32,17 @@ log = logging.getLogger( __name__ ) url_for = base.routes.url_for +UCSC_SERVERS = ( + 'hgw1.cse.ucsc.edu', + 'hgw2.cse.ucsc.edu', + 'hgw3.cse.ucsc.edu', + 'hgw4.cse.ucsc.edu', + 'hgw5.cse.ucsc.edu', + 'hgw6.cse.ucsc.edu', + 'hgw7.cse.ucsc.edu', + 'hgw8.cse.ucsc.edu', +) + def expose( func ): """ Decorator: mark a function as 'exposed' and thus web accessible @@ -273,8 +284,17 @@ class UniverseWebTransaction( base.DefaultWebTransaction ): url_for( controller='user', action='reset_password' ), url_for( controller='library', action='browse' ) ) - if self.galaxy_session.user is None and self.request.path not in allowed_paths: - self.response.send_redirect( url_for( controller='root', action='index' ) ) + display_as = url_for( controller='root', action='display_as' ) + if self.galaxy_session.user is None: + if self.app.config.ucsc_display_sites and self.request.path == display_as: + try: + host = socket.gethostbyaddr( self.environ[ 'REMOTE_ADDR' ] )[0] + except( socket.error, socket.herror, socket.gaierror, socket.timeout ): + host = None + if host in UCSC_SERVERS: + return + if self.request.path not in allowed_paths: + self.response.send_redirect( url_for( controller='root', action='index' ) ) def __create_new_session( self, prev_galaxy_session=None, user_for_new_session=None ): """ Create a new GalaxySession for this request, possibly with a connection