diff mercurial/wireprototypes.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 6e585bca962e
children 1cfef5693203
line wrap: on
line diff
--- a/mercurial/wireprototypes.py	Wed Mar 07 16:02:24 2018 -0800
+++ b/mercurial/wireprototypes.py	Wed Mar 07 16:18:52 2018 -0800
@@ -146,3 +146,12 @@
 
         Returns a list of capabilities. The passed in argument can be returned.
         """
+
+    @abc.abstractmethod
+    def checkperm(self, perm):
+        """Validate that the client has permissions to perform a request.
+
+        The argument is the permission required to proceed. If the client
+        doesn't have that permission, the exception should raise or abort
+        in a protocol specific manner.
+        """