Mercurial > hg
comparison mercurial/hgweb/hgweb_mod.py @ 36801:66de4555cefd
wireproto: formalize permissions checking as part of protocol interface
Per the inline comment desiring to formalize permissions checking
in the protocol interface, we do that.
I'm not convinced this is the best way to go about things. I would love
for there to e.g. be a better exception for denoting permissions
problems. But it does feel strictly better than snipping attributes
on the proto instance.
Differential Revision: https://phab.mercurial-scm.org/D2719
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Wed, 07 Mar 2018 16:18:52 -0800 |
parents | 0b18604db95e |
children | 7fc80c982656 |
comparison
equal
deleted
inserted
replaced
36800:0b18604db95e | 36801:66de4555cefd |
---|---|
348 query = req.env[r'QUERY_STRING'].partition(r'&')[0] | 348 query = req.env[r'QUERY_STRING'].partition(r'&')[0] |
349 query = query.partition(r';')[0] | 349 query = query.partition(r';')[0] |
350 | 350 |
351 # Route it to a wire protocol handler if it looks like a wire protocol | 351 # Route it to a wire protocol handler if it looks like a wire protocol |
352 # request. | 352 # request. |
353 protohandler = wireprotoserver.parsehttprequest(rctx.repo, req, query) | 353 protohandler = wireprotoserver.parsehttprequest(rctx, req, query, |
354 self.check_perm) | |
354 | 355 |
355 if protohandler: | 356 if protohandler: |
356 try: | 357 try: |
357 if query: | 358 if query: |
358 raise ErrorResponse(HTTP_NOT_FOUND) | 359 raise ErrorResponse(HTTP_NOT_FOUND) |
359 | 360 |
360 # TODO fold this into parsehttprequest | 361 return protohandler['dispatch']() |
361 checkperm = lambda op: self.check_perm(rctx, req, op) | |
362 protohandler['proto'].checkperm = checkperm | |
363 | |
364 return protohandler['dispatch'](checkperm) | |
365 except ErrorResponse as inst: | 362 except ErrorResponse as inst: |
366 return protohandler['handleerror'](inst) | 363 return protohandler['handleerror'](inst) |
367 | 364 |
368 # translate user-visible url structure to internal structure | 365 # translate user-visible url structure to internal structure |
369 | 366 |