equal
deleted
inserted
replaced
422 $ cd .. |
422 $ cd .. |
423 $ cat << EOT > userpass.py |
423 $ cat << EOT > userpass.py |
424 > import base64 |
424 > import base64 |
425 > from mercurial.hgweb import common |
425 > from mercurial.hgweb import common |
426 > def perform_authentication(hgweb, req, op): |
426 > def perform_authentication(hgweb, req, op): |
427 > auth = req.env.get('HTTP_AUTHORIZATION') |
427 > auth = req.headers.get('Authorization') |
428 > if not auth: |
428 > if not auth: |
429 > raise common.ErrorResponse(common.HTTP_UNAUTHORIZED, 'who', |
429 > raise common.ErrorResponse(common.HTTP_UNAUTHORIZED, 'who', |
430 > [('WWW-Authenticate', 'Basic Realm="mercurial"')]) |
430 > [('WWW-Authenticate', 'Basic Realm="mercurial"')]) |
431 > if base64.b64decode(auth.split()[1]).split(':', 1) != ['user', 'pass']: |
431 > if base64.b64decode(auth.split()[1]).split(':', 1) != ['user', 'pass']: |
432 > raise common.ErrorResponse(common.HTTP_FORBIDDEN, 'no') |
432 > raise common.ErrorResponse(common.HTTP_FORBIDDEN, 'no') |