<br><br><div class="gmail_quote">On Mon, Aug 17, 2009 at 11:45 AM, Reza Lotun <span dir="ltr"><<a href="mailto:rlotun@gmail.com">rlotun@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
The short answer is that you need to use twisted.cred. </blockquote><div><br>You don't need to do that at all, it just happens to be the best way. <br> </div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
wrapper = guard.HTTPAuthSessionWrapper(<br>
Portal(SimpleRealm(), checkers),<br>
[guard.BasicCredentialFactory('<a href="http://yoursite.com" target="_blank">yoursite.com</a>')])<br>
</blockquote><div><br>Where is Portal and SimpleRealm in your example? Those are actually quite large constructs which are crucial to guard doing anything useful at all. <br><br>Since there are numerous circumstances that people need Htauth, it is implemented as follows<br>
<br>from twisted.web import http<br># and other stuff...<br><br>class HTTPAuthPage(rend.Page):<br> def renderHTTP(self, ctx):<br> request = inevow.IRequest(ctx)<br> username, password = request.getUser(), request.getPassword()<br>
<br> if [My auth details check out]:<br> return rend.Page.renderHTTP(self, ctx) <br><br> else:<br> request.setHeader('WWW-Authenticate', 'Basic realm="My realm name"')<br>
request.setResponseCode(http.UNAUTHORIZED)<br> return "Authentication required."<br><br>
</div></div>