@@ -380,6 +380,7 @@ def handle_xmlrpc(self):
380380 self .determine_language ()
381381 # Open the database as the correct user.
382382 self .determine_user ()
383+ self .check_web_access ()
383384
384385 # Call the appropriate XML-RPC method.
385386 handler = xmlrpc .RoundupDispatcher (self .db ,
@@ -437,6 +438,11 @@ def inner_main(self):
437438 # figure out the context and desired content template
438439 self .determine_context ()
439440
441+ # if we've made it this far the context is to a bit of
442+ # Roundup's real web interface (not a file being served up)
443+ # so do the Anonymous Web Acess check now
444+ self .check_web_access ()
445+
440446 # possibly handle a form submit action (may change self.classname
441447 # and self.template, and may also append error/ok_messages)
442448 html = self .handle_action ()
@@ -711,15 +717,21 @@ def determine_user(self):
711717 # make sure the anonymous user is valid if we're using it
712718 if user == 'anonymous' :
713719 self .make_user_anonymous ()
714- if not self .db .security .hasPermission ('Web Access' , self .userid ):
715- raise Unauthorised , self ._ ("Anonymous users are not "
716- "allowed to use the web interface" )
717720 else :
718721 self .user = user
719722
720723 # reopen the database as the correct user
721724 self .opendb (self .user )
722725
726+ def check_web_access (self ):
727+ """Check that the Anonymous user is actually allowed to use the web
728+ interface and short-circuit all further processing if they're not.
729+ """
730+ if self .user == 'anonymous' :
731+ if not self .db .security .hasPermission ('Web Access' , self .userid ):
732+ raise Unauthorised , self ._ ("Anonymous users are not "
733+ "allowed to use the web interface" )
734+
723735 def opendb (self , username ):
724736 """Open the database and set the current user.
725737
@@ -865,6 +877,8 @@ def serve_file(self, designator, dre=re.compile(r'([^\d]+)(\d+)')):
865877 # The classname was not valid.
866878 raise NotFound , str (designator )
867879
880+ # perform the Anonymous user access check
881+ self .check_web_access ()
868882
869883 # make sure we have the appropriate properties
870884 props = klass .getprops ()
0 commit comments