1.1 --- a/examples/Common/LoginRedirect/__init__.py Sun May 30 15:32:29 2004 +0000
1.2 +++ b/examples/Common/LoginRedirect/__init__.py Sun May 30 15:33:10 2004 +0000
1.3 @@ -15,8 +15,8 @@
1.4 the application being protected should be reachable, and an 'authenticator'.
1.5
1.6 If the optional 'anonymous_parameter_name' is set, clients providing a parameter
1.7 - of that name in the URL will not be authenticated, but then such clients will not
1.8 - get a user identity associated with them.
1.9 + of that name in the URL will have that parameter sent specially to the login
1.10 + application.
1.11 """
1.12
1.13 self.login_url = login_url
1.14 @@ -27,22 +27,25 @@
1.15
1.16 def respond(self, trans):
1.17
1.18 - # Check for the anonymous parameter, if appropriate.
1.19 -
1.20 - fields = trans.get_fields_from_path()
1.21 - if self.anonymous_parameter_name is not None and fields.has_key(self.anonymous_parameter_name):
1.22 - is_anonymous = 1
1.23 - else:
1.24 - is_anonymous = 0
1.25 -
1.26 # Check the authentication details with the specified authenticator.
1.27
1.28 - if is_anonymous or self.authenticator.authenticate(trans):
1.29 + if self.authenticator.authenticate(trans):
1.30 self.resource.respond(trans)
1.31 else:
1.32 + # Define anonymous mode, if appropriate.
1.33 +
1.34 + fields_path = trans.get_fields_from_path()
1.35 +
1.36 + if self.anonymous_parameter_name is not None and fields_path.has_key(self.anonymous_parameter_name):
1.37 + anonymous_parameter = "%s=%s&" % (self.anonymous_parameter_name, fields_path[self.anonymous_parameter_name][0])
1.38 + else:
1.39 + anonymous_parameter = ""
1.40 +
1.41 # Redirect to the login URL.
1.42
1.43 - trans.set_header_value("Location", "%s?redirect=%s%s" % (self.login_url, self.app_url, self._encode(trans.get_path())))
1.44 + trans.set_header_value("Location", "%s?%sredirect=%s%s" % (
1.45 + self.login_url, anonymous_parameter, self.app_url, self._encode(trans.get_path()))
1.46 + )
1.47 trans.set_response_code(307)
1.48
1.49 def _encode(self, url):