chiark / gitweb /
ersatz fake-dw gives correct messages on username and password failure
authorMarnanel Thurman <marnanel@thurman.org.uk>
Mon, 29 Nov 2021 21:29:51 +0000 (21:29 +0000)
committerMarnanel Thurman <marnanel@thurman.org.uk>
Mon, 29 Nov 2021 21:29:51 +0000 (21:29 +0000)
fake-dw/fake-dw.py
fake-dw/templates/login-fail-password [new file with mode: 0644]
fake-dw/templates/login-fail-username [new file with mode: 0644]
fake-dw/templates/login-success [moved from fake-dw/templates/logged-in with 100% similarity]

index 21d69a0606f0e7688ad25c032e21e47a56a9f3c9..9b80c8e42c6899cbb0d28c94cb82e5a9a545d1c7 100644 (file)
@@ -159,17 +159,17 @@ class ErsatzHandler(http.server.BaseHTTPRequestHandler):
 
             elif method=='POST':
 
-                if not self.check_headers(query,
+                fields['template-name'] = self.check_headers(query,
                         [
-                            ('user', 'wombat', 'Unknown user'),
-                            ('password', 'hunter2', 'Wrong password'),
+                            ('user', 'wombat', 'Unknown user',
+                                'login-fail-username'),
+                            ('password', 'hunter2', 'Wrong password',
+                                'login-fail-password'),
                             ('lj_form_auth', self.server.lj_form_auth,
-                                'Wrong auth string'),
+                                'Wrong auth string',
+                                'login-fail-username'), # apparently
                             ],
-                        ):
-                   return
-
-                fields['template-name'] = 'logged-in'
+                        )
             else:
                 self.send_error(405, 'Unknown method')
 
@@ -217,22 +217,20 @@ class ErsatzHandler(http.server.BaseHTTPRequestHandler):
 
     def check_headers(self, query, checks):
 
-        for (field, value, message) in checks:
+        for (field, value, message, failure_template) in checks:
 
             field = bytes(field, encoding='ascii')
             value = [bytes(value, encoding='ascii')]
 
             if field not in query:
-                self.send_error(410,
-                        f'{message}: {field} missing')
-                return False
+                print(f'{message}: {field} missing')
+                return failure_template
 
             elif query[field]!=value:
-                self.send_error(410,
-                        f'{message}: got {query[field]}, wanted {value}')
-                return False
+                print(f'{message}: got {query[field]}, wanted {value}')
+                return failure_template
 
-        return True
+        return 'login-success'
 
 
 class TCPServerWithSettings(socketserver.TCPServer):
diff --git a/fake-dw/templates/login-fail-password b/fake-dw/templates/login-fail-password
new file mode 100644 (file)
index 0000000..a716e0b
--- /dev/null
@@ -0,0 +1,167 @@
+<!DOCTYPE html>
+<html lang="en"><head>
+    <title>Log in</title>
+
+    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
+    
+            <script type="text/javascript" async="" src="/ga.js"></script><script type="text/javascript">
+                var Site;
+                if (!Site)
+                    Site = {};
+
+                var site_p = {"ctx_popup_icons": 1,
+"imgprefix": "/img",
+"user_domain": "dreamwidth.org",
+"inbox_update_poll": 1,
+"has_remote": 0,
+"siteroot": "",
+"ctx_popup_userhead": 1,
+"iconprefix": "https://v.dreamwidth.org",
+"statprefix": "/stc",
+"ctx_popup": 1,
+"media_embed_enabled": 1,
+"cmax_comment": 16000,
+"currentJournalBase": "",
+"currentJournal": "",
+"esn_async": 1};
+                var site_k = ["ctx_popup_icons", "imgprefix", "user_domain", "inbox_update_poll", "has_remote", "siteroot", "ctx_popup_userhead", "iconprefix", "statprefix", "ctx_popup", "media_embed_enabled", "cmax_comment", "currentJournalBase", "currentJournal", "esn_async"];
+                for (var i = 0; site_k.length > i; i++) {
+                    Site[site_k[i]] = site_p[site_k[i]];
+                }
+           </script>
+        <link rel="stylesheet" type="text/css" href="/a.css">
+<link rel="stylesheet" type="text/css" href="/a_002.css">
+<script type="text/javascript" src="/a.js"></script>
+
+    
+
+    <script type="text/javascript">
+  var _gaq = _gaq || [];
+  _gaq.push(['_setAccount', 'UA-4595135-1']);
+  _gaq.push(['_trackPageview']);</script>
+
+    <!--[if lte IE 8]>
+    <script src="//www.dreamwidth.org/js/html5.js" type="text/javascript"></script>
+    <![endif]-->
+</head>
+    <body>
+        <div id="canvas">
+            <div id="page">
+<div id="skip">
+     <a href="#content" tabindex="1">Skip to Main Content</a>
+</div>
+                
+                <div id="masthead" role="banner">
+                    <span id="logo">
+                        <a href="/"><img alt="Dreamwidth Studios" src="/dw_logo.png"></a>
+                    </span>
+                </div>
+
+                <div id="content" role="main">                <h1>Log in</h1>
+                <div style="clear: both">
+<blockquote>
+<hr>
+<strong>There was an error processing your request:</strong><ul><li>You typed the wrong password. If you make too many wrong login attempts in a row, your account access will be temporarily blocked, so you may want to <a href='/lostinfo'>reset your password</a> if you aren't sure what it is. If you're sure you typed the right password, but are still having trouble logging in, you may need to <a href="http://www.dreamwidth.org/support/faqbrowse?faqid=241">update or disable your browser extensions</a>.</li>
+ </ul>
+<hr>
+</blockquote>
+</div>
+<table summary="" cellspacing="0" cellpadding="0"><tbody><tr><td style="padding-right:20px; vertical-align: top"><div class="columns-2-r300 pkg">
+<div class="columns-2-left">
+<div class="appwidget appwidget-login" id="LJWidget_50">
+<form action="/login" method="post" class="lj_login_form pkg">
+<input type="hidden" name="lj_form_auth" value="c0:1638219600:738:86400:7h3ipELqrn-0-wIZrDcZ19RhG76W:405106016e7e078caf4d5cc52ce28a84"><h2>Welcome to Dreamwidth!</h2>
+<fieldset class="pkg nostyle">
+<label for="user" class="left">Account name:</label>
+<input type="text" value="obviously_not" name="user" id="user" class="text" size="18" maxlength="27" style="" tabindex="11">
+</fieldset>
+<fieldset class="pkg nostyle">
+<label for="lj_loginwidget_password" class="left">Password</label>
+<input type="password" id="lj_loginwidget_password" name="password" class="lj_login_password text" size="20" maxlength="72" tabindex="12"><a href="/lostinfo" class="small-link" tabindex="16">Forgot your password?</a>
+</fieldset>
+<p><input type="checkbox" name="remember_me" id="remember_me" value="1" tabindex="13"> <label for="remember_me">Remember me</label></p><p><input name="action:login" type="submit" value="Log in" tabindex="14"> <a href="/openid/" class="small-link" tabindex="15">Log in with OpenID</a></p></form>
+</div><!-- end .appwidget-login -->
+<div class="login-create-account">
+<hr class="hr">
+<h4>Not a Dreamwidth Studios member?</h4>
+<form action="/create" method="get"><input type="submit" value="Create an Account" class="submit"></form>
+<ul>
+<li>Read filtered entries that you have access to.</li><li>Leave comments in any journal or community.</li><li>Post entries in your own journal.</li><li>Add any journal or community to your Reading Page.</li><li>Use features that are only visible when you're logged in.</li></ul>
+</div><!-- end .login-create-account -->
+</div><!-- end .columns-2-left -->
+</div></td></tr></tbody></table>
+                </div>
+
+                 
+<div id="account-links" role="navigation" aria-label="Account Links"> <form action="/login?ret=1" method="post" class="lj_login_form"><input type="hidden" name="returnto" value=""><input type="hidden" name="chal" class="lj_login_chal" value="c0:1638219600:738:300:MAoDDY6ywzipGqibfrdy:eae5608af3a5a04a733e2265a8436a1c">
+    <input type="hidden" name="response" class="lj_login_response" value="">
+    <table summary="" id="login-table"><tbody><tr><td><label for="login_user">Account name:</label></td><td class="input-cell" colspan="2"><input name="user" id="login_user" size="20" maxlength="27" tabindex="1" aria-required="true"> <a href="/openid/" tabindex="5">Log in with OpenID?</a></td></tr><tr><td><label for="login_password">Password:</label></td><td class="input-cell" colspan="2"><input type="password" name="password" id="login_password" size="20" tabindex="2" aria-required="true" class="lj_login_password"> <a href="/lostinfo" tabindex="6">Forget your password?</a></td></tr><tr><td>&nbsp;</td><td class="remember-me-cell"><input type="checkbox" name="remember_me" id="login_remember_me" value="1" tabindex="3"> <label for="login_remember_me">Remember me</label></td><td><input type="submit" name="login" value="Log in" tabindex="4"></td></tr></tbody></table></form> 
+</div> 
+                
+                <nav role="navigation" aria-label="Site Navigation">
+                    <ul class="left"><li id="create_topnav" class="topnav has-dropdown"><a href="/nav/create">Create</a>
+<ul id="create_subnav" class="subnav_container dropdown">
+                <li class="subnav"><a href="/create">Create Account</a></li>
+                <li class="subnav"><a href="/manage/settings/?cat=display">Display Preferences</a></li>
+</ul>
+</li><li id="explore_topnav" class="topnav has-dropdown"><a href="/nav/explore">Explore</a>
+<ul id="explore_subnav" class="subnav_container dropdown">
+                <li class="subnav"><a href="/interests">Interests</a></li>
+                <li class="subnav"><a href="/directorysearch">Directory Search</a></li>
+                <li class="subnav"><a href="/search">Site and Journal Search</a></li>
+                <li class="subnav"><a href="/latest">Latest Things</a></li>
+                <li class="subnav"><a href="/random">Random Journal</a></li>
+                <li class="subnav"><a href="/community/random">Random Community</a></li>
+                <li class="subnav"><a href="/support/faq">FAQ</a></li>
+</ul>
+</li><li id="shop_topnav" class="topnav has-dropdown"><a href="/nav/shop">Shop</a>
+<ul id="shop_subnav" class="subnav_container dropdown">
+                <li class="subnav"><a href="/shop">Buy Dreamwidth Services</a></li>
+                <li class="subnav"><a href="/shop/randomgift">Gift a Random User</a></li>
+                <li class="subnav"><a href="https://www.zazzle.com/dreamwidth*">DW Merchandise</a></li>
+</ul>
+</li>
+</ul>
+                    <div role="search">
+                    <div class="appwidget appwidget-search" id="LJWidget_51">
+<form action="/multisearch" method="post">
+<input type="text" size="20" title="Search" class="text" id="search" name="q"> <select class="select" name="type">
+<option value="int" selected="selected">Interest</option>
+<option value="region">Region</option>
+<option value="nav_and_user">Site and Account</option>
+<option value="faq">FAQ</option>
+<option value="email">Email</option>
+<option value="im">IM Info</option>
+</select> <input type="submit" value="Go"></form></div><!-- end .appwidget-search -->
+
+                    </div>
+                </nav>
+                <footer role="contentinfo">
+                    <ul>
+    <li><a href="/legal/privacy">Privacy Policy</a> • </li>
+    <li><a href="/legal/tos">Terms of Service</a> • </li>
+    <li><a href="/legal/diversity">Diversity Statement</a> • </li>
+    <li><a href="/legal/principles">Guiding Principles</a> • </li>
+    <li><a href="/site/">Site Map</a> • </li>
+    <li><a href="/site/suggest">Make a Suggestion</a> • </li>
+    <li><a href="/site/opensource">Open Source</a> • </li>
+    <li><a href="/support">Help/Support</a></li>
+</ul>
+<p>Copyright © 2009-2021 Dreamwidth Studios, LLC. <a href="/site/opensource">Some</a> rights reserved.</p>
+                </footer>
+            </div>
+        </div>
+        <div id="statistics" style="text-align: left; font-size:0; line-height:0; height:0; overflow:hidden;"><script type="text/javascript">
+  (function() {
+    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+  })();
+
+</script>
+</div>
+     <div id="shim-alpha"> </div>
+    
+
+
+</body></html>
diff --git a/fake-dw/templates/login-fail-username b/fake-dw/templates/login-fail-username
new file mode 100644 (file)
index 0000000..6038654
--- /dev/null
@@ -0,0 +1,167 @@
+<!DOCTYPE html>
+<html lang="en"><head>
+    <title>Log in</title>
+
+    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
+    
+            <script type="text/javascript" async="" src="/ga.js"></script><script type="text/javascript">
+                var Site;
+                if (!Site)
+                    Site = {};
+
+                var site_p = {"ctx_popup_icons": 1,
+"imgprefix": "/img",
+"user_domain": "dreamwidth.org",
+"inbox_update_poll": 1,
+"has_remote": 0,
+"siteroot": "",
+"ctx_popup_userhead": 1,
+"iconprefix": "https://v.dreamwidth.org",
+"statprefix": "/stc",
+"ctx_popup": 1,
+"media_embed_enabled": 1,
+"cmax_comment": 16000,
+"currentJournalBase": "",
+"currentJournal": "",
+"esn_async": 1};
+                var site_k = ["ctx_popup_icons", "imgprefix", "user_domain", "inbox_update_poll", "has_remote", "siteroot", "ctx_popup_userhead", "iconprefix", "statprefix", "ctx_popup", "media_embed_enabled", "cmax_comment", "currentJournalBase", "currentJournal", "esn_async"];
+                for (var i = 0; site_k.length > i; i++) {
+                    Site[site_k[i]] = site_p[site_k[i]];
+                }
+           </script>
+        <link rel="stylesheet" type="text/css" href="/a.css">
+<link rel="stylesheet" type="text/css" href="/a_002.css">
+<script type="text/javascript" src="/a.js"></script>
+
+    
+
+    <script type="text/javascript">
+  var _gaq = _gaq || [];
+  _gaq.push(['_setAccount', 'UA-4595135-1']);
+  _gaq.push(['_trackPageview']);</script>
+
+    <!--[if lte IE 8]>
+    <script src="//www.dreamwidth.org/js/html5.js" type="text/javascript"></script>
+    <![endif]-->
+</head>
+    <body>
+        <div id="canvas">
+            <div id="page">
+<div id="skip">
+     <a href="#content" tabindex="1">Skip to Main Content</a>
+</div>
+                
+                <div id="masthead" role="banner">
+                    <span id="logo">
+                        <a href="/"><img alt="Dreamwidth Studios" src="/dw_logo.png"></a>
+                    </span>
+                </div>
+
+                <div id="content" role="main">                <h1>Log in</h1>
+                <div style="clear: both">
+<blockquote>
+<hr>
+<strong>There was an error processing your request:</strong><ul><li>This account name was not found.  Would you like to <a href="/create?user=obviously_not">create an account</a> using this account name?</li>
+ </ul>
+<hr>
+</blockquote>
+</div>
+<table summary="" cellspacing="0" cellpadding="0"><tbody><tr><td style="padding-right:20px; vertical-align: top"><div class="columns-2-r300 pkg">
+<div class="columns-2-left">
+<div class="appwidget appwidget-login" id="LJWidget_50">
+<form action="/login" method="post" class="lj_login_form pkg">
+<input type="hidden" name="lj_form_auth" value="c0:1638219600:738:86400:7h3ipELqrn-0-wIZrDcZ19RhG76W:405106016e7e078caf4d5cc52ce28a84"><h2>Welcome to Dreamwidth!</h2>
+<fieldset class="pkg nostyle">
+<label for="user" class="left">Account name:</label>
+<input type="text" value="obviously_not" name="user" id="user" class="text" size="18" maxlength="27" style="" tabindex="11">
+</fieldset>
+<fieldset class="pkg nostyle">
+<label for="lj_loginwidget_password" class="left">Password</label>
+<input type="password" id="lj_loginwidget_password" name="password" class="lj_login_password text" size="20" maxlength="72" tabindex="12"><a href="/lostinfo" class="small-link" tabindex="16">Forgot your password?</a>
+</fieldset>
+<p><input type="checkbox" name="remember_me" id="remember_me" value="1" tabindex="13"> <label for="remember_me">Remember me</label></p><p><input name="action:login" type="submit" value="Log in" tabindex="14"> <a href="/openid/" class="small-link" tabindex="15">Log in with OpenID</a></p></form>
+</div><!-- end .appwidget-login -->
+<div class="login-create-account">
+<hr class="hr">
+<h4>Not a Dreamwidth Studios member?</h4>
+<form action="/create" method="get"><input type="submit" value="Create an Account" class="submit"></form>
+<ul>
+<li>Read filtered entries that you have access to.</li><li>Leave comments in any journal or community.</li><li>Post entries in your own journal.</li><li>Add any journal or community to your Reading Page.</li><li>Use features that are only visible when you're logged in.</li></ul>
+</div><!-- end .login-create-account -->
+</div><!-- end .columns-2-left -->
+</div></td></tr></tbody></table>
+                </div>
+
+                 
+<div id="account-links" role="navigation" aria-label="Account Links"> <form action="/login?ret=1" method="post" class="lj_login_form"><input type="hidden" name="returnto" value=""><input type="hidden" name="chal" class="lj_login_chal" value="c0:1638219600:738:300:MAoDDY6ywzipGqibfrdy:eae5608af3a5a04a733e2265a8436a1c">
+    <input type="hidden" name="response" class="lj_login_response" value="">
+    <table summary="" id="login-table"><tbody><tr><td><label for="login_user">Account name:</label></td><td class="input-cell" colspan="2"><input name="user" id="login_user" size="20" maxlength="27" tabindex="1" aria-required="true"> <a href="/openid/" tabindex="5">Log in with OpenID?</a></td></tr><tr><td><label for="login_password">Password:</label></td><td class="input-cell" colspan="2"><input type="password" name="password" id="login_password" size="20" tabindex="2" aria-required="true" class="lj_login_password"> <a href="/lostinfo" tabindex="6">Forget your password?</a></td></tr><tr><td>&nbsp;</td><td class="remember-me-cell"><input type="checkbox" name="remember_me" id="login_remember_me" value="1" tabindex="3"> <label for="login_remember_me">Remember me</label></td><td><input type="submit" name="login" value="Log in" tabindex="4"></td></tr></tbody></table></form> 
+</div> 
+                
+                <nav role="navigation" aria-label="Site Navigation">
+                    <ul class="left"><li id="create_topnav" class="topnav has-dropdown"><a href="/nav/create">Create</a>
+<ul id="create_subnav" class="subnav_container dropdown">
+                <li class="subnav"><a href="/create">Create Account</a></li>
+                <li class="subnav"><a href="/manage/settings/?cat=display">Display Preferences</a></li>
+</ul>
+</li><li id="explore_topnav" class="topnav has-dropdown"><a href="/nav/explore">Explore</a>
+<ul id="explore_subnav" class="subnav_container dropdown">
+                <li class="subnav"><a href="/interests">Interests</a></li>
+                <li class="subnav"><a href="/directorysearch">Directory Search</a></li>
+                <li class="subnav"><a href="/search">Site and Journal Search</a></li>
+                <li class="subnav"><a href="/latest">Latest Things</a></li>
+                <li class="subnav"><a href="/random">Random Journal</a></li>
+                <li class="subnav"><a href="/community/random">Random Community</a></li>
+                <li class="subnav"><a href="/support/faq">FAQ</a></li>
+</ul>
+</li><li id="shop_topnav" class="topnav has-dropdown"><a href="/nav/shop">Shop</a>
+<ul id="shop_subnav" class="subnav_container dropdown">
+                <li class="subnav"><a href="/shop">Buy Dreamwidth Services</a></li>
+                <li class="subnav"><a href="/shop/randomgift">Gift a Random User</a></li>
+                <li class="subnav"><a href="https://www.zazzle.com/dreamwidth*">DW Merchandise</a></li>
+</ul>
+</li>
+</ul>
+                    <div role="search">
+                    <div class="appwidget appwidget-search" id="LJWidget_51">
+<form action="/multisearch" method="post">
+<input type="text" size="20" title="Search" class="text" id="search" name="q"> <select class="select" name="type">
+<option value="int" selected="selected">Interest</option>
+<option value="region">Region</option>
+<option value="nav_and_user">Site and Account</option>
+<option value="faq">FAQ</option>
+<option value="email">Email</option>
+<option value="im">IM Info</option>
+</select> <input type="submit" value="Go"></form></div><!-- end .appwidget-search -->
+
+                    </div>
+                </nav>
+                <footer role="contentinfo">
+                    <ul>
+    <li><a href="/legal/privacy">Privacy Policy</a> • </li>
+    <li><a href="/legal/tos">Terms of Service</a> • </li>
+    <li><a href="/legal/diversity">Diversity Statement</a> • </li>
+    <li><a href="/legal/principles">Guiding Principles</a> • </li>
+    <li><a href="/site/">Site Map</a> • </li>
+    <li><a href="/site/suggest">Make a Suggestion</a> • </li>
+    <li><a href="/site/opensource">Open Source</a> • </li>
+    <li><a href="/support">Help/Support</a></li>
+</ul>
+<p>Copyright © 2009-2021 Dreamwidth Studios, LLC. <a href="/site/opensource">Some</a> rights reserved.</p>
+                </footer>
+            </div>
+        </div>
+        <div id="statistics" style="text-align: left; font-size:0; line-height:0; height:0; overflow:hidden;"><script type="text/javascript">
+  (function() {
+    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+  })();
+
+</script>
+</div>
+     <div id="shim-alpha"> </div>
+    
+
+
+</body></html>