# HG changeset patch # User paulb # Date 1194828694 0 # Node ID 26865b172666db0d755f07e22cea55ff086e36d9 # Parent 7f1f02b485f8eb33dc41c070922619abb79e14d9 [project @ 2007-11-12 00:51:34 by paulb] Added a StringResource class for simple static resources. Introduced base classes for common authentication activities. Merged "app", "path" and "qs" fields into a single "app" field for login and redirection. Added support for OpenID authentication. diff -r 7f1f02b485f8 -r 26865b172666 WebStack/Resources/Login.py --- a/WebStack/Resources/Login.py Mon Nov 12 00:50:03 2007 +0000 +++ b/WebStack/Resources/Login.py Mon Nov 12 00:51:34 2007 +0000 @@ -22,7 +22,7 @@ """ import WebStack.Generic -from WebStack.Helpers.Auth import get_token +from WebStack.Helpers.Auth import LoginAuthenticator class LoginResource: @@ -59,57 +59,59 @@ "Respond using the transaction 'trans'." - app, path, qs = get_target(trans, self.urlencoding, self.encoding) - # Check for a submitted login form. fields_body = trans.get_fields_from_body(self.encoding) if fields_body.has_key("login"): if self.authenticator.authenticate(trans, fields_body.get("username", [None])[0], fields_body.get("password", [None])[0]): - self._redirect(trans, app, path, qs) + app = fields_body.get("app", [""])[0] + + self._redirect(trans, app) # The above method does not return. # Otherwise, show the login form. - self.show_login(trans, app, path, qs) + fields_path = trans.get_fields_from_path(self.urlencoding) + app = fields_path.get("app", [""])[0] - def _redirect(self, trans, app, path, qs): + self.show_login(trans, app) + + def _redirect(self, trans, app): """ - Redirect the client using 'trans' and the given 'app', 'path' and 'qs' - details. + Redirect the client using 'trans' and the given 'app' details. """ # Show the success page anyway. - self.show_success(trans, app, path, qs) + self.show_success(trans, app) if self.use_redirect: - trans.redirect(app + trans.encode_path(path, self.urlencoding) + qs) + trans.redirect(app) else: raise WebStack.Generic.EndOfResponse - def show_login(self, trans, app, path, qs): + def show_login(self, trans, app): """ Writes a login screen using the transaction 'trans', including details - of the 'app', 'path' and 'qs' which the client was attempting to access. + of the 'app' which the client was attempting to access. """ trans.set_content_type(WebStack.Generic.ContentType("text/html", self.encoding)) out = trans.get_response_stream() - out.write(self.login_page % (app, path, qs)) + out.write(self.login_page % app) - def show_success(self, trans, app, path, qs): + def show_success(self, trans, app): """ Writes a success screen using the transaction 'trans', including details - of the 'app', 'path' and 'qs' which the client was attempting to access. + of the 'app' which the client was attempting to access. """ trans.set_content_type(WebStack.Generic.ContentType("text/html", self.encoding)) out = trans.get_response_stream() - out.write(self.success_page % (app, trans.encode_path(path, self.urlencoding), qs)) + out.write(self.success_page % (app, app)) login_page = """ @@ -123,8 +125,6 @@
Password:
- -