comparison mercurial/hgweb/common.py @ 50442:4bddc2f72879

hgweb: move ismember from `hgweb.common` to `scmutil` To implement hidden access control for other protocol than http, we need code outside of hgweb to access this logic.
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Sat, 13 Apr 2019 01:53:59 +0200
parents 4077d6222cf1
children 18c8c18993f0
comparison
equal deleted inserted replaced
50441:315f537627c1 50442:4bddc2f72879
19 open, 19 open,
20 ) 20 )
21 from .. import ( 21 from .. import (
22 encoding, 22 encoding,
23 pycompat, 23 pycompat,
24 scmutil,
24 templater, 25 templater,
25 util, 26 util,
26 ) 27 )
27 28
28 httpserver = util.httpserver 29 httpserver = util.httpserver
37 HTTP_METHOD_NOT_ALLOWED = 405 38 HTTP_METHOD_NOT_ALLOWED = 405
38 HTTP_NOT_ACCEPTABLE = 406 39 HTTP_NOT_ACCEPTABLE = 406
39 HTTP_UNSUPPORTED_MEDIA_TYPE = 415 40 HTTP_UNSUPPORTED_MEDIA_TYPE = 415
40 HTTP_SERVER_ERROR = 500 41 HTTP_SERVER_ERROR = 500
41 42
42 43 ismember = scmutil.ismember
43 def ismember(ui, username, userlist):
44 """Check if username is a member of userlist.
45
46 If userlist has a single '*' member, all users are considered members.
47 Can be overridden by extensions to provide more complex authorization
48 schemes.
49 """
50 return userlist == [b'*'] or username in userlist
51 44
52 45
53 def hashiddenaccess(repo, req): 46 def hashiddenaccess(repo, req):
54 if bool(req.qsparams.get(b'access-hidden')): 47 if bool(req.qsparams.get(b'access-hidden')):
55 # Disable this by default for now. Main risk is to get critical 48 # Disable this by default for now. Main risk is to get critical