Mercurial > public > mercurial-scm > hg
comparison mercurial/wireproto.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 | 5bc7ff103081 |
comparison
equal
deleted
inserted
replaced
36800:0b18604db95e | 36801:66de4555cefd |
---|---|
729 if a: | 729 if a: |
730 n, v = a.split('=') | 730 n, v = a.split('=') |
731 vals[unescapearg(n)] = unescapearg(v) | 731 vals[unescapearg(n)] = unescapearg(v) |
732 func, spec = commands[op] | 732 func, spec = commands[op] |
733 | 733 |
734 # If the protocol supports permissions checking, perform that | 734 # Validate that client has permissions to perform this command. |
735 # checking on each batched command. | 735 perm = commands[op].permission |
736 # TODO formalize permission checking as part of protocol interface. | 736 assert perm in ('push', 'pull') |
737 if util.safehasattr(proto, 'checkperm'): | 737 proto.checkperm(perm) |
738 perm = commands[op].permission | |
739 assert perm in ('push', 'pull') | |
740 proto.checkperm(perm) | |
741 | 738 |
742 if spec: | 739 if spec: |
743 keys = spec.split() | 740 keys = spec.split() |
744 data = {} | 741 data = {} |
745 for k in keys: | 742 for k in keys: |