<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: How-To: Dynamic WWW-Authentication (.htaccess style) on Google App Engine</title>
	<atom:link href="http://www.eriksmartt.com/blog/archives/882/feed" rel="self" type="application/rss+xml" />
	<link>http://www.eriksmartt.com/blog/archives/882</link>
	<description>my little chunk of bandwidth</description>
	<lastBuildDate>Tue, 27 Dec 2011 16:52:38 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.4-alpha-19814</generator>
	<item>
		<title>By: erik</title>
		<link>http://www.eriksmartt.com/blog/archives/882#comment-42666</link>
		<dc:creator>erik</dc:creator>
		<pubDate>Mon, 03 Jan 2011 22:45:37 +0000</pubDate>
		<guid isPermaLink="false">http://www.eriksmartt.com/blog/?p=882#comment-42666</guid>
		<description>:-)  Some cats like privacy...</description>
		<content:encoded><![CDATA[<p>:-)  Some cats like privacy&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Shane Spencer</title>
		<link>http://www.eriksmartt.com/blog/archives/882#comment-42663</link>
		<dc:creator>Shane Spencer</dc:creator>
		<pubDate>Mon, 03 Jan 2011 06:15:49 +0000</pubDate>
		<guid isPermaLink="false">http://www.eriksmartt.com/blog/?p=882#comment-42663</guid>
		<description>Restricted cat photos?</description>
		<content:encoded><![CDATA[<p>Restricted cat photos?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Charly</title>
		<link>http://www.eriksmartt.com/blog/archives/882#comment-39432</link>
		<dc:creator>Charly</dc:creator>
		<pubDate>Wed, 17 Feb 2010 14:46:58 +0000</pubDate>
		<guid isPermaLink="false">http://www.eriksmartt.com/blog/?p=882#comment-39432</guid>
		<description>Hey Erik , thanks for the tips, I&#039;m trying to figure out how to redirect my main site on Google appengine based on the ip range of the client (like with .htaccess) and just have no clue how to do this, could you direct me on this? thanks</description>
		<content:encoded><![CDATA[<p>Hey Erik , thanks for the tips, I&#8217;m trying to figure out how to redirect my main site on Google appengine based on the ip range of the client (like with .htaccess) and just have no clue how to do this, could you direct me on this? thanks</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: erik</title>
		<link>http://www.eriksmartt.com/blog/archives/882#comment-39253</link>
		<dc:creator>erik</dc:creator>
		<pubDate>Wed, 20 Jan 2010 15:00:23 +0000</pubDate>
		<guid isPermaLink="false">http://www.eriksmartt.com/blog/?p=882#comment-39253</guid>
		<description>Very nice!  Thanks!!</description>
		<content:encoded><![CDATA[<p>Very nice!  Thanks!!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Maarten</title>
		<link>http://www.eriksmartt.com/blog/archives/882#comment-39252</link>
		<dc:creator>Maarten</dc:creator>
		<pubDate>Wed, 20 Jan 2010 14:28:28 +0000</pubDate>
		<guid isPermaLink="false">http://www.eriksmartt.com/blog/?p=882#comment-39252</guid>
		<description>Thx for the post.. I rewrote your script into a decorator:

&lt;pre&gt;&lt;code&gt;
def basicAuth(func):
  def callf(webappRequest, *args, **kwargs):
    # Parse the header to extract a user/password combo.
    # We&#039;re expecting something like &quot;Basic XZxgZRTpbjpvcGVuIHYlc4FkZQ==&quot;
    auth_header = webappRequest.request.headers.get(&#039;Authorization&#039;)
    
    if auth_header == None:
      webappRequest.response.set_status(401, message=&quot;Authorization Required&quot;)
      webappRequest.response.headers[&#039;WWW-Authenticate&#039;] = &#039;Basic realm=&quot;Kalydo School&quot;&#039;
    else:
      # Isolate the encoded user/passwd and decode it
      auth_parts = auth_header.split(&#039; &#039;)
      user_pass_parts = base64.b64decode(auth_parts[1]).split(&#039;:&#039;)
      user_arg = user_pass_parts[0]
      pass_arg = user_pass_parts[1]
  
      if user_arg != &quot;admin&quot; or pass_arg != &quot;foobar&quot;:
        webappRequest.response.set_status(401, message=&quot;Authorization Required&quot;)
        webappRequest.response.headers[&#039;WWW-Authenticate&#039;] = &#039;Basic realm=&quot;Secure Area&quot;&#039;
        # Rendering a 401 Error page is a good way to go...
        self.response.out.write(template.render(&#039;templates/error/401.html&#039;, {}))
      else:
        return func(webappRequest, *args, **kwargs)
  
  return callf

class AuthTest(webapp.RequestHandler):
  @basicAuth
  def get(self):
     ....
&lt;/code&gt;&lt;/pre&gt;
</description>
		<content:encoded><![CDATA[<p>Thx for the post.. I rewrote your script into a decorator:</p>
<pre><code>
def basicAuth(func):
  def callf(webappRequest, *args, **kwargs):
    # Parse the header to extract a user/password combo.
    # We're expecting something like "Basic XZxgZRTpbjpvcGVuIHYlc4FkZQ=="
    auth_header = webappRequest.request.headers.get('Authorization')

    if auth_header == None:
      webappRequest.response.set_status(401, message="Authorization Required")
      webappRequest.response.headers['WWW-Authenticate'] = 'Basic realm="Kalydo School"'
    else:
      # Isolate the encoded user/passwd and decode it
      auth_parts = auth_header.split(' ')
      user_pass_parts = base64.b64decode(auth_parts[1]).split(':')
      user_arg = user_pass_parts[0]
      pass_arg = user_pass_parts[1]

      if user_arg != "admin" or pass_arg != "foobar":
        webappRequest.response.set_status(401, message="Authorization Required")
        webappRequest.response.headers['WWW-Authenticate'] = 'Basic realm="Secure Area"'
        # Rendering a 401 Error page is a good way to go...
        self.response.out.write(template.render('templates/error/401.html', {}))
      else:
        return func(webappRequest, *args, **kwargs)

  return callf

class AuthTest(webapp.RequestHandler):
  @basicAuth
  def get(self):
     ....
</code></pre>
]]></content:encoded>
	</item>
</channel>
</rss>

