Mercurial > public > mercurial-scm > hg-stable
diff mercurial/hgweb/protocol.py @ 6779:d3147b4e3e8a
hgweb: centralize permission checks for protocol commands
Consistently enforces authorization checks set up in hgrc up front, so that
the actual commands don't have to worry about them and implementers of
hgweb alternatives can easily implement their own permission checks.
author | Dirkjan Ochtman <dirkjan@ochtman.nl> |
---|---|
date | Sun, 29 Jun 2008 11:35:06 +0200 |
parents | 8542fac26f63 |
children | 4c1d67e0fa8c |
line wrap: on
line diff
--- a/mercurial/hgweb/protocol.py Sun Jun 29 11:02:19 2008 +0200 +++ b/mercurial/hgweb/protocol.py Sun Jun 29 11:35:06 2008 +0200 @@ -62,8 +62,6 @@ def changegroup(web, req): req.respond(HTTP_OK, HGTYPE) nodes = [] - if not web.allowpull: - return if 'roots' in req.form: nodes = map(bin, req.form['roots'][0].split(" ")) @@ -82,8 +80,6 @@ req.respond(HTTP_OK, HGTYPE) bases = [] heads = [] - if not web.allowpull: - return if 'bases' in req.form: bases = [bin(x) for x in req.form['bases'][0].split(' ')] @@ -120,28 +116,7 @@ req.write('0\n') req.write(response) - # enforce that you can only unbundle with POST requests - if req.env['REQUEST_METHOD'] != 'POST': - headers = {'status': '405 Method Not Allowed'} - bail('unbundle requires POST request\n', headers) - return - - # require ssl by default, auth info cannot be sniffed and - # replayed - ssl_req = web.configbool('web', 'push_ssl', True) - if ssl_req: - if req.env.get('wsgi.url_scheme') != 'https': - bail('ssl required\n') - return - proto = 'https' - else: - proto = 'http' - - # do not allow push unless explicitly allowed - if not web.check_perm(req, 'push', False): - bail('push not authorized\n', headers={'status': '401 Unauthorized'}) - return - + proto = req.env.get('wsgi.url_scheme') or 'http' their_heads = req.form['heads'][0].split(' ') def check_heads(): @@ -224,7 +199,5 @@ os.unlink(tempname) def stream_out(web, req): - if not web.allowpull: - return req.respond(HTTP_OK, HGTYPE) streamclone.stream_out(web.repo, req, untrusted=True)