Show More
@@ -46,7 +46,7 b' def checkauthz(hgweb, req, op):' | |||
|
46 | 46 | authentication info). Return if op allowed, else raise an ErrorResponse |
|
47 | 47 | exception.''' |
|
48 | 48 | |
|
49 | user = req.env.get(r'REMOTE_USER') | |
|
49 | user = req.remoteuser | |
|
50 | 50 | |
|
51 | 51 | deny_read = hgweb.configlist('web', 'deny_read') |
|
52 | 52 | if deny_read and (not user or ismember(hgweb.repo.ui, user, deny_read)): |
@@ -62,14 +62,13 b' def checkauthz(hgweb, req, op):' | |||
|
62 | 62 | return |
|
63 | 63 | |
|
64 | 64 | # enforce that you can only push using POST requests |
|
65 |
if req. |
|
|
65 | if req.method != 'POST': | |
|
66 | 66 | msg = 'push requires POST request' |
|
67 | 67 | raise ErrorResponse(HTTP_METHOD_NOT_ALLOWED, msg) |
|
68 | 68 | |
|
69 | 69 | # require ssl by default for pushing, auth info cannot be sniffed |
|
70 | 70 | # and replayed |
|
71 | scheme = req.env.get('wsgi.url_scheme') | |
|
72 | if hgweb.configbool('web', 'push_ssl') and scheme != 'https': | |
|
71 | if hgweb.configbool('web', 'push_ssl') and req.urlscheme != 'https': | |
|
73 | 72 | raise ErrorResponse(HTTP_FORBIDDEN, 'ssl required') |
|
74 | 73 | |
|
75 | 74 | deny = hgweb.configlist('web', 'deny_push') |
@@ -322,7 +322,7 b' class hgweb(object):' | |||
|
322 | 322 | res.headers['Content-Security-Policy'] = rctx.csp |
|
323 | 323 | |
|
324 | 324 | handled = wireprotoserver.handlewsgirequest( |
|
325 |
rctx |
|
|
325 | rctx, req, res, self.check_perm) | |
|
326 | 326 | if handled: |
|
327 | 327 | return res.sendresponse() |
|
328 | 328 | |
@@ -380,7 +380,7 b' class hgweb(object):' | |||
|
380 | 380 | |
|
381 | 381 | # check read permissions non-static content |
|
382 | 382 | if cmd != 'static': |
|
383 |
self.check_perm(rctx, |
|
|
383 | self.check_perm(rctx, req, None) | |
|
384 | 384 | |
|
385 | 385 | if cmd == '': |
|
386 | 386 | req.qsparams['cmd'] = tmpl.cache['default'] |
@@ -148,13 +148,12 b' class httpv1protocolhandler(wireprototyp' | |||
|
148 | 148 | def iscmd(cmd): |
|
149 | 149 | return cmd in wireproto.commands |
|
150 | 150 | |
|
151 |
def handlewsgirequest(rctx |
|
|
151 | def handlewsgirequest(rctx, req, res, checkperm): | |
|
152 | 152 | """Possibly process a wire protocol request. |
|
153 | 153 | |
|
154 | 154 | If the current request is a wire protocol request, the request is |
|
155 | 155 | processed by this function. |
|
156 | 156 | |
|
157 | ``wsgireq`` is a ``wsgirequest`` instance. | |
|
158 | 157 | ``req`` is a ``parsedrequest`` instance. |
|
159 | 158 | ``res`` is a ``wsgiresponse`` instance. |
|
160 | 159 | |
@@ -197,7 +196,7 b' def handlewsgirequest(rctx, wsgireq, req' | |||
|
197 | 196 | return True |
|
198 | 197 | |
|
199 | 198 | proto = httpv1protocolhandler(req, repo.ui, |
|
200 |
lambda perm: checkperm(rctx, |
|
|
199 | lambda perm: checkperm(rctx, req, perm)) | |
|
201 | 200 | |
|
202 | 201 | # The permissions checker should be the only thing that can raise an |
|
203 | 202 | # ErrorResponse. It is kind of a layer violation to catch an hgweb |
@@ -177,7 +177,7 b' test http authentication' | |||
|
177 | 177 | > import base64 |
|
178 | 178 | > from mercurial.hgweb import common |
|
179 | 179 | > def perform_authentication(hgweb, req, op): |
|
180 |
> auth = req. |
|
|
180 | > auth = req.headers.get('Authorization') | |
|
181 | 181 | > if not auth: |
|
182 | 182 | > raise common.ErrorResponse(common.HTTP_UNAUTHORIZED, 'who', |
|
183 | 183 | > [('WWW-Authenticate', 'Basic Realm="mercurial"')]) |
@@ -168,7 +168,7 b' test http authentication' | |||
|
168 | 168 | > import base64 |
|
169 | 169 | > from mercurial.hgweb import common |
|
170 | 170 | > def perform_authentication(hgweb, req, op): |
|
171 |
> auth = req. |
|
|
171 | > auth = req.headers.get('Authorization') | |
|
172 | 172 | > if not auth: |
|
173 | 173 | > raise common.ErrorResponse(common.HTTP_UNAUTHORIZED, 'who', |
|
174 | 174 | > [('WWW-Authenticate', 'Basic Realm="mercurial"')]) |
@@ -510,7 +510,7 b' We raise HTTP 500 because its message is' | |||
|
510 | 510 | > from mercurial import util |
|
511 | 511 | > from mercurial.hgweb import common |
|
512 | 512 | > def perform_authentication(hgweb, req, op): |
|
513 |
> cookie = req. |
|
|
513 | > cookie = req.headers.get('Cookie') | |
|
514 | 514 | > if not cookie: |
|
515 | 515 | > raise common.ErrorResponse(common.HTTP_SERVER_ERROR, 'no-cookie') |
|
516 | 516 | > raise common.ErrorResponse(common.HTTP_SERVER_ERROR, 'Cookie: %s' % cookie) |
@@ -424,7 +424,7 b' a large file from the server rather than' | |||
|
424 | 424 | > import base64 |
|
425 | 425 | > from mercurial.hgweb import common |
|
426 | 426 | > def perform_authentication(hgweb, req, op): |
|
427 |
> auth = req. |
|
|
427 | > auth = req.headers.get('Authorization') | |
|
428 | 428 | > if not auth: |
|
429 | 429 | > raise common.ErrorResponse(common.HTTP_UNAUTHORIZED, 'who', |
|
430 | 430 | > [('WWW-Authenticate', 'Basic Realm="mercurial"')]) |
General Comments 0
You need to be logged in to leave comments.
Login now