exchange: enforce permission on new wireprotocol command
authorPierre-Yves David <pierre-yves.david@fb.com>
Thu, 06 Mar 2014 12:15:04 -0800
changeset 869 e9eeef0d07ec
parent 868 3ec90de03562
child 870 1a23c7c52a43
exchange: enforce permission on new wireprotocol command hgweb needs an explicit declaration of the permission level of each commands.
hgext/evolve.py
hgext/simple4server.py
--- a/hgext/evolve.py	Wed Mar 05 19:08:58 2014 -0800
+++ b/hgext/evolve.py	Thu Mar 06 12:15:04 2014 -0800
@@ -64,6 +64,7 @@
 from mercurial.node import nullid
 from mercurial import wireproto
 from mercurial import localrepo
+from mercurial.hgweb import hgweb_mod
 
 _pack = struct.pack
 
@@ -2448,6 +2449,9 @@
 @eh.extsetup
 def _installwireprotocol(ui):
     localrepo.MODERNCAPS.add('_evoext_pullobsmarkers_0')
+    hgweb_mod.perms['evoext_pushobsmarkers_0'] = 'push'
+    hgweb_mod.perms['evoext_pullobsmarkers_0'] = 'pull'
+    hgweb_mod.perms['evoext_obshash'] = 'pull'
     wireproto.commands['evoext_pushobsmarkers_0'] = (srv_pushobsmarkers, '')
     wireproto.commands['evoext_pullobsmarkers_0'] = (srv_pullobsmarkers, '*')
     wireproto.commands['evoext_obshash'] = (srv_obshash, 'nodes')
--- a/hgext/simple4server.py	Wed Mar 05 19:08:58 2014 -0800
+++ b/hgext/simple4server.py	Thu Mar 06 12:15:04 2014 -0800
@@ -17,6 +17,7 @@
 from mercurial import obsolete
 from cStringIO import StringIO
 from mercurial import node
+from mercurial.hgweb import hgweb_mod
 _pack = struct.pack
 
 def srv_pushobsmarkers(repo, proto):
@@ -178,6 +179,9 @@
 def extsetup(ui):
     obsolete.obsstore = pruneobsstore
     obsolete.obsstore.relevantmarkers = relevantmarkers
+    hgweb_mod.perms['evoext_pushobsmarkers_0'] = 'push'
+    hgweb_mod.perms['evoext_pullobsmarkers_0'] = 'pull'
+    hgweb_mod.perms['evoext_obshash'] = 'pull'
     wireproto.commands['evoext_pushobsmarkers_0'] = (srv_pushobsmarkers, '')
     wireproto.commands['evoext_pullobsmarkers_0'] = (srv_pullobsmarkers, '*')
     extensions.wrapfunction(wireproto, 'capabilities', capabilities)