File: //opt/alt/python27/lib/python2.7/site-packages/paste/auth/digest.pyo
�
|��Wc           @   s  d  Z  d d l m Z d d l Ty d d l m Z Wn! e k
 rW d d l m Z n Xd d l Z d d l Z d d l	 m
 Z d �  Z d �  Z
 d	 �  Z d
 e f d �  �  YZ d e f d
 �  �  YZ e Z d d g Z d �  Z d e k rd d l Z e j d e j � n  d S(   s  
Digest HTTP/1.1 Authentication
This module implements ``Digest`` authentication as described by
RFC 2617 [1]_ .
Basically, you just put this module before your application, and it
takes care of requesting and handling authentication requests.  This
module has been tested with several common browsers "out-in-the-wild".
>>> from paste.wsgilib import dump_environ
>>> from paste.httpserver import serve
>>> # from paste.auth.digest import digest_password, AuthDigestHandler
>>> realm = 'Test Realm'
>>> def authfunc(environ, realm, username):
...     return digest_password(realm, username, username)
>>> serve(AuthDigestHandler(dump_environ, realm, authfunc))
serving on...
This code has not been audited by a security expert, please use with
caution (or better yet, report security holes). At this time, this
implementation does not provide for further challenges, nor does it
support Authentication-Info header.  It also uses md5, and an option
to use sha would be a good thing.
.. [1] http://www.faqs.org/rfcs/rfc2617.html
i����(   t   HTTPUnauthorized(   t   *(   t   md5N(   t   quotec         c   s�   d } x� |  j d � D]x } y/ | j d � d k rJ d | | f } w n  Wn/ t k
 r| | d k rs | } q q} t � n X| j �  V| } q W| j �  Vt � d S(   s>